Compare commits

...
2 Commits
6 changed files with 52 additions and 15 deletions
+12
View File
@@ -19,3 +19,15 @@
# If you keep the line number information, uncomment this to
# hide the original source file name.
-renamesourcefileattribute SourceFile
# Capacitor plugin annotations. Without this, R8 sees no class implementing the
# @CapacitorPlugin annotation interface (runtime proxies are invisible to it),
# concludes PluginHandle.pluginAnnotation is always null, and compiles
# Plugin.getPermissionStates() to a NullPointerException. Every plugin's
# checkPermissions()/requestPermissions() then crashes release builds only.
-keep @interface com.getcapacitor.annotation.** { *; }
-keep @interface com.getcapacitor.NativePlugin { *; }
-keepclassmembers class com.getcapacitor.PluginHandle {
private com.getcapacitor.annotation.CapacitorPlugin pluginAnnotation;
private com.getcapacitor.NativePlugin legacyPluginAnnotation;
}
+5 -4
View File
@@ -67,14 +67,15 @@
/>
<!-- BootReceiver: reschedule daily notification after device restart.
Two intent-filters: BOOT_COMPLETED has no Uri, so must not share a filter with <data scheme="package"/> or the boot broadcast never matches. -->
Two intent-filters: BOOT_COMPLETED has no Uri, so must not share a filter with <data scheme="package"/> or the boot broadcast never matches.
Not directBootAware and no LOCKED_BOOT_COMPLETED: before first unlock, credential-encrypted storage is
unavailable, and both TimeSafariApplication (via TimeSafariNativeFetcher) and BootReceiver read
SharedPreferences, which throws IllegalStateException and crashes the process. -->
<receiver
android:name="org.timesafari.dailynotification.BootReceiver"
android:enabled="true"
android:exported="true"
android:directBootAware="true">
android:exported="true">
<intent-filter android:priority="1000">
<action android:name="android.intent.action.LOCKED_BOOT_COMPLETED" />
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
<intent-filter android:priority="1000">
@@ -54,7 +54,6 @@ public class TimeSafariNativeFetcher implements NativeNotificationContentFetcher
private final Gson gson = new Gson();
private final Context appContext;
private final SharedPreferences prefs;
private volatile String apiBaseUrl;
private volatile String activeDid;
@@ -65,7 +64,17 @@ public class TimeSafariNativeFetcher implements NativeNotificationContentFetcher
public TimeSafariNativeFetcher(Context context) {
this.appContext = context.getApplicationContext();
this.prefs = appContext.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
}
/**
* Opened on use, never in the constructor: this object is built in
* Application.onCreate, which also runs when a direct-boot-aware component
* (e.g. Firebase messaging) starts the process before the user's first unlock,
* and credential-encrypted SharedPreferences throw until then.
* getSharedPreferences caches the instance, so repeated calls are cheap.
*/
private SharedPreferences prefs() {
return appContext.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
}
@Override
@@ -291,7 +300,7 @@ public class TimeSafariNativeFetcher implements NativeNotificationContentFetcher
private List<String> getStarredPlanIds() {
try {
String idsJson = prefs.getString(KEY_STARRED_PLAN_IDS, "[]");
String idsJson = prefs().getString(KEY_STARRED_PLAN_IDS, "[]");
if (idsJson == null || idsJson.isEmpty() || "[]".equals(idsJson)) {
return new ArrayList<>();
}
@@ -308,7 +317,7 @@ public class TimeSafariNativeFetcher implements NativeNotificationContentFetcher
}
private String getLastAcknowledgedJwtId() {
return prefs.getString(KEY_LAST_ACKED_JWT_ID, null);
return prefs().getString(KEY_LAST_ACKED_JWT_ID, null);
}
/**
@@ -330,7 +339,7 @@ public class TimeSafariNativeFetcher implements NativeNotificationContentFetcher
}
}
if (jwtId != null) {
prefs.edit().putString(KEY_LAST_ACKED_JWT_ID, jwtId).apply();
prefs().edit().putString(KEY_LAST_ACKED_JWT_ID, jwtId).apply();
}
} catch (Exception e) {
Log.w(TAG, "Could not extract JWT ID from response", e);
+2
View File
@@ -572,6 +572,7 @@
DEVELOPMENT_TEAM = GM3FS5JQPH;
ENABLE_APP_SANDBOX = NO;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "";
FIREBASE_ENABLED = YES;
INFOPLIST_FILE = App/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = Giftopia;
@@ -603,6 +604,7 @@
DEVELOPMENT_TEAM = GM3FS5JQPH;
ENABLE_APP_SANDBOX = NO;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "";
FIREBASE_ENABLED = YES;
INFOPLIST_FILE = App/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = Giftopia;
@@ -30,7 +30,7 @@
shouldAutocreateTestPlan = "YES">
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
buildConfiguration = "Release"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
+18 -5
View File
@@ -762,13 +762,26 @@ export default class ContactQRScanFull extends Vue {
await this.pendingPauseStop;
this.pendingPauseStop = null;
if (this.resumeScanOnResume && this.isMounted) {
logger.debug("App resumed, restarting scanner");
this.resumeScanOnResume = false;
await this.startScanning();
} else {
if (!this.resumeScanOnResume || !this.isMounted) {
this.isScanning = false;
return;
}
this.resumeScanOnResume = false;
// The Android camera permission dialog itself pauses the app. Restart only
// when the permission is granted: after a denial, startScanning() would
// show the dialog a second time, and the denied start already warned.
const scanner = QRScannerFactory.getInstance();
if (!(await scanner.checkPermissions())) {
logger.debug("App resumed without camera permission; not restarting");
this.isScanning = false;
this.error = "Camera permission denied";
return;
}
if (!this.isMounted) return;
logger.debug("App resumed, restarting scanner");
await this.startScanning();
}
/**