From 6d85c0ac3e744e56069aaf9e5f01de7af586711a Mon Sep 17 00:00:00 2001 From: James Babcock Date: Fri, 11 Sep 2026 21:58:31 -0700 Subject: [PATCH] Onboarding "Disconnect Other Apps" page handles case where Even app isn't installed --- .../faceclaw/app/FaceclawEvenAppDetector.java | 22 +++++++++++++------ app/native/even-app-conflict.ts | 20 ++++++++++++----- app/phone-ui/onboarding-unpair-page.xml | 7 ++++-- app/phone-ui/onboarding-unpair-view-model.ts | 4 ++++ 4 files changed, 38 insertions(+), 15 deletions(-) diff --git a/App_Resources/Android/src/main/java/com/faceclaw/app/FaceclawEvenAppDetector.java b/App_Resources/Android/src/main/java/com/faceclaw/app/FaceclawEvenAppDetector.java index 6fc488d1..bb3e952d 100644 --- a/App_Resources/Android/src/main/java/com/faceclaw/app/FaceclawEvenAppDetector.java +++ b/App_Resources/Android/src/main/java/com/faceclaw/app/FaceclawEvenAppDetector.java @@ -3,6 +3,7 @@ package com.faceclaw.app; import android.content.ComponentName; import android.content.Context; import android.content.Intent; +import android.content.pm.PackageManager; import android.net.Uri; import android.provider.Settings; import android.util.Log; @@ -47,19 +48,26 @@ public final class FaceclawEvenAppDetector { return hasNotfication; } - public static void openEvenAppSettings(Context context) { + /** Returns "opened", "not-installed", or "failed" for the phone UI. */ + public static String openEvenAppSettings(Context context) { if (context == null) { - return; + return "failed"; } Context appContext = context.getApplicationContext(); - Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); - intent.setData(Uri.parse("package:" + EVEN_PACKAGE_NAME)); - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); try { + // Settings may launch successfully and then immediately close for a + // missing package, so check before starting the activity. + appContext.getPackageManager().getApplicationInfo(EVEN_PACKAGE_NAME, 0); + Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); + intent.setData(Uri.parse("package:" + EVEN_PACKAGE_NAME)); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); appContext.startActivity(intent); - } catch (Throwable t) { + return "opened"; + } catch (PackageManager.NameNotFoundException e) { + return "not-installed"; + } catch (Exception t) { Log.w(TAG, "failed to open Even app settings", t); - openNotificationAccessSettings(appContext); + return "failed"; } } diff --git a/app/native/even-app-conflict.ts b/app/native/even-app-conflict.ts index c01642fd..d1b3fc7a 100644 --- a/app/native/even-app-conflict.ts +++ b/app/native/even-app-conflict.ts @@ -1,4 +1,4 @@ -import { Utils } from "@nativescript/core"; +import { Dialogs, Utils } from "@nativescript/core"; declare const com: any; @@ -23,11 +23,19 @@ export function readEvenAppNotificationState(): EvenAppNotificationState { } export function openEvenAppSettings(): void { - if (!global.isAndroid) return; - const context = Utils.android.getApplicationContext(); - if (context) { - com.faceclaw.app.FaceclawEvenAppDetector.openEvenAppSettings(context); - } + const context = global.isAndroid ? Utils.android.getApplicationContext() : null; + const result = context + ? com.faceclaw.app.FaceclawEvenAppDetector.openEvenAppSettings(context) + : "failed"; + if (result === "opened") return; + const notInstalled = result === "not-installed"; + void Dialogs.alert({ + title: notInstalled ? "Even app not installed" : "Unable to open Even app settings", + message: notInstalled + ? "The official Even Realities app isn't installed on this phone. If your glasses are connected to another app or phone, disconnect them there. Otherwise, you can continue." + : "Open your phone's settings manually to manage the Even app, or disconnect your glasses from within the app that's connected to them.", + okButtonText: "OK", + }); } export function openNotificationAccessSettings(): void { diff --git a/app/phone-ui/onboarding-unpair-page.xml b/app/phone-ui/onboarding-unpair-page.xml index 558f2a1a..d11c9ee6 100644 --- a/app/phone-ui/onboarding-unpair-page.xml +++ b/app/phone-ui/onboarding-unpair-page.xml @@ -4,9 +4,12 @@