Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 6 additions & 14 deletions desktop/ox-mobile/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -581,14 +581,10 @@ a prompt that may never answer. The prompt runs in a small pilot-only
transparent Activity because the shared GPUI host does not forward
`onRequestPermissionsResult`.

A cold notification tap whose FCM message sets
`android.notification.click_action` to `dev.ox.mobile.action.APPROVAL` starts
the existing exported GPUI activity. The pilot's debug manifest adds only an
overlay intent filter for that exact action with the `DEFAULT` category; the
base manifest keeps its launcher filter, the normal no-config APK never sees
the overlay, and no new exported component is added. The pilot captures the
typed `approval_ref` and optional `pairing_hint` extras at app start. Both
values use the canonical 43-character base64url spelling of a 32-byte digest.
The Firebase pilot keeps the GPUI launcher component as an alias. A tap
with the FCM click action `dev.ox.mobile.action.APPROVAL` reaches the same
activity as the launcher. Android can deliver a new intent to the running
activity, which checks the same reference and pairing fields as at startup.
The pilot keeps a bounded 16-entry set of recently seen tap envelopes. The
app applies the same saved-pairing and signed status checks used on iOS.

Expand All @@ -598,12 +594,8 @@ cannot also carry `approval_ref`, and a session without that hint is refused
rather than falling back to legacy unpaired routing. Only that valid explicit
launch reaches the shared signed follow-tap session branch. Received data
messages and background messages are not read, and no display or tap action
happens for them. The existing activity and capture remain in place: the
relay's `NEW_TASK | CLEAR_TOP` click action can recreate the standard-mode
activity for a background-warm tap, which uses the same capture path and is
to be verified on a device. A foreground tap delivered as `onNewIntent` is
not covered by this slice. The relay does not send a session reference yet,
and this slice adds no Android session alert opt-in control.
happens for them. Session alert delivery from the relay and its Android
settings remain follow-ups.

### Opt-in approval alerts in Android Settings

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Both opt-in APK variants register for Messaging only after user opt-in. -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<!-- The pilot is the only build that asks for alert display. The normal
no-config APK keeps its existing permission set. -->
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
Expand All @@ -16,16 +17,33 @@
android:name="firebase_messaging_installation_id_enabled"
android:value="true" />

<!-- A cold notification tap starts the existing exported GPUI activity
through the relay's click_action. This overlay adds only that
action filter; the base manifest keeps its launcher filter and
the normal no-config APK never sees this file. -->
<activity android:name="dev.gpui.mobile.GpuiInputActivity">
<!-- Keep the installed launcher component name. Use one GPUI
activity for launcher and alert intents, and deliver an alert
to an existing instance after Firebase's CLEAR_TOP. -->
<activity android:name="dev.gpui.mobile.GpuiInputActivity" tools:node="remove" />
<activity
android:name="dev.ox.mobile.OXAlertActivity"
android:configChanges="orientation|screenSize|screenLayout|smallestScreenSize|keyboardHidden|keyboard|navigation|uiMode|density|fontScale"
android:exported="false"
android:launchMode="singleTop"
android:windowSoftInputMode="adjustResize">
<meta-data android:name="android.app.lib_name" android:value="ox_mobile" />
</activity>
<activity-alias
android:name="dev.gpui.mobile.GpuiInputActivity"
android:exported="true"
android:targetActivity="dev.ox.mobile.OXAlertActivity">
<!-- GPUI reads native library metadata on the launcher component. -->
<meta-data android:name="android.app.lib_name" android:value="ox_mobile" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="dev.ox.mobile.action.APPROVAL" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</activity-alias>

<!-- The subclass receives onRegistered(String) only after an explicit
register() call. It never displays a notification. -->
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package dev.ox.mobile;

import android.content.Intent;
import dev.gpui.mobile.GpuiInputActivity;

/** Reuses the running GPUI activity when the Firebase click intent arrives. */
public final class OXAlertActivity extends GpuiInputActivity {
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
if (intent != null && OXApprovalIntents.ACTION_APPROVAL.equals(intent.getAction())) {
setIntent(intent);
nativeCaptureAlert();
}
}

private static native void nativeCaptureAlert();
}
12 changes: 5 additions & 7 deletions desktop/ox-mobile/build-android-fcm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -717,23 +717,21 @@ grep -F -A 1 "dev.ox.mobile.OXCloudMessagingService" <<<"$manifest_tree" |
grep -Fq "dev.ox.mobile.OXNotificationPermissionActivity" <<<"$manifest_tree" || die "the pilot has no notification permission activity"
grep -Fq "dev.ox.mobile.OXImagePickerActivity" <<<"$manifest_tree" || die "the pilot APK lost the image picker activity"
grep -Fq "dev.ox.mobile.OXQrScannerActivity" <<<"$manifest_tree" || die "the pilot APK lost the QR scanner activity"
# The overlay adds the relay's exact click_action to the existing exported GPUI
# activity, beside the launcher filter the base manifest still owns. The
# indentation of `aapt2 dump xmltree` shows which filter belongs to which
# component.
# Verify both intent filters on the original launcher component name in the
# merged manifest. aapt2 indentation keeps the checks on the same alias.
approval_activity="$(
awk '
function depth(line) { match(line, /[^ ]/); return RSTART ? RSTART - 1 : 0 }
function finish() {
if (block ~ /dev\.gpui\.mobile\.GpuiInputActivity/) {
if (block ~ /dev\.gpui\.mobile\.GpuiInputActivity/ && block ~ /dev\.ox\.mobile\.OXAlertActivity/) {
if (block ~ /dev\.ox\.mobile\.action\.APPROVAL/) approval = 1
if (block ~ /android\.intent\.category\.DEFAULT/) default_category = 1
if (block ~ /android\.intent\.action\.MAIN/) launcher_action = 1
if (block ~ /android\.intent\.category\.LAUNCHER/) launcher_category = 1
}
in_block = 0
}
/^[ ]*E: activity \(/ {
/^[ ]*E: activity-alias \(/ {
if (in_block) finish()
in_block = 1
block = $0 "\n"
Expand All @@ -751,7 +749,7 @@ approval_activity="$(
' <<<"$manifest_tree"
)"
[[ "$approval_activity" == ok ]] ||
die "the merged manifest does not attach the approval action and DEFAULT category to the existing GPUI activity alongside its launcher filter"
die "the merged manifest does not attach the approval action and DEFAULT category to the existing GPUI launcher alias"
grep -Fq "uses-permission: name='android.permission.POST_NOTIFICATIONS'" <<<"$badging" || die "the pilot APK lost the notification permission"
resources="$("$tools/aapt2" dump resources "$apk")"
grep -Fq "string/google_app_id" <<<"$resources" || die "the pilot APK has no generated Firebase app id"
Expand Down
43 changes: 25 additions & 18 deletions desktop/ox-mobile/check-android-fcm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,30 @@ if grep -Fq 'dev.ox.mobile.action.APPROVAL' "$manifest"; then
die "the normal no-config manifest must not carry the pilot approval action"
fi

# The pilot's debug overlay, and nothing else, adds the relay's exact
# click_action to the existing exported GPUI activity as an implicit-intent
# filter. The base manifest keeps the launcher filter, and no new exported
# component is introduced. Warm-intent behavior is not asserted here.
# The existing external launcher name is an alias in the pilot. Both entry
# points reach one activity, which accepts a new alert without rebooting GPUI.
pilot_manifest="$pilot/app/src/fcm/AndroidManifest.xml"
grep -Fq '<activity android:name="dev.gpui.mobile.GpuiInputActivity">' "$pilot_manifest" ||
die "the pilot overlay must extend the existing GPUI activity without changing its export"
grep -Fq '<action android:name="dev.ox.mobile.action.APPROVAL" />' "$pilot_manifest" ||
die "the pilot overlay has no exact approval launch action"
grep -Fq '<category android:name="android.intent.category.DEFAULT" />' "$pilot_manifest" ||
die "the approval launch action cannot resolve as an implicit intent without DEFAULT"
[[ "$(grep -c '<activity android:name="dev.gpui.mobile.GpuiInputActivity">' "$pilot_manifest")" == 1 ]] ||
die "the pilot overlay must extend the existing GPUI activity exactly once"
if grep -Fq 'android.intent.action.MAIN' "$pilot_manifest" ||
grep -Fq 'android.intent.category.LAUNCHER' "$pilot_manifest"; then
die "the pilot overlay must leave the launcher filter to the base manifest"
fi
python3 - "$pilot_manifest" <<'PYMANIFEST'
import sys
import xml.etree.ElementTree as ET

android = '{http://schemas.android.com/apk/res/android}'
app = ET.parse(sys.argv[1]).getroot().find('application')
activity = next(node for node in app.findall('activity')
if node.get(android + 'name') == 'dev.ox.mobile.OXAlertActivity')
alias = next(node for node in app.findall('activity-alias')
if node.get(android + 'name') == 'dev.gpui.mobile.GpuiInputActivity')
assert activity.get(android + 'exported') == 'false'
assert activity.get(android + 'launchMode') == 'singleTop'
assert alias.get(android + 'exported') == 'true'
assert alias.get(android + 'targetActivity') == activity.get(android + 'name')
assert any(node.get(android + 'name') == 'android.app.lib_name'
and node.get(android + 'value') == 'ox_mobile' for node in alias.findall('meta-data'))
filters = {(entry.find('action').get(android + 'name'), entry.find('category').get(android + 'name'))
for entry in alias.findall('intent-filter')}
assert filters == {('android.intent.action.MAIN', 'android.intent.category.LAUNCHER'),
('dev.ox.mobile.action.APPROVAL', 'android.intent.category.DEFAULT')}
PYMANIFEST

# The normal no-config build and the emulator check stay in place.
grep -Fq 'build-android.sh x86_64-linux-android' .github/workflows/mobile.yml || die "the Android CI build step is missing"
Expand Down Expand Up @@ -234,13 +241,13 @@ fi
fcm_java="$pilot/java/dev/ox/mobile"
for source in OXCloudMessaging.java OXCloudMessagingService.java \
OXNotificationPermission.java OXNotificationPermissionActivity.java \
OXApprovalIntents.java OXApprovalNotice.java; do
OXApprovalIntents.java OXApprovalNotice.java OXAlertActivity.java; do
[[ -f "$fcm_java/$source" ]] || die "the pilot bridge is missing $source"
done
for source in "$fcm_java"/*.java; do
case "$(basename "$source")" in
OXCloudMessaging.java|OXCloudMessagingService.java|OXNotificationPermission.java|\
OXNotificationPermissionActivity.java|OXApprovalIntents.java|OXApprovalNotice.java) ;;
OXNotificationPermissionActivity.java|OXApprovalIntents.java|OXApprovalNotice.java|OXAlertActivity.java) ;;
*) die "unexpected pilot Java source: $(basename "$source")" ;;
esac
done
Expand Down
Loading
Loading