Skip to content

Commit

Permalink
Catch JSON exception and return an error to get android to compile
Browse files Browse the repository at this point in the history
  • Loading branch information
shankari committed Oct 8, 2024
1 parent e062604 commit cc66591
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/android/verification/SensorControlForegroundDelegate.java
Original file line number Diff line number Diff line change
Expand Up @@ -777,14 +777,18 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {
case SensorControlConstants.ENABLE_NOTIFICATIONS:
Log.d(mAct, TAG, requestCode + " is our code, handling callback");
Log.d(mAct, TAG, "Got notification callback from launching app settings");
JSONObject jo = new JSONObject();
jo.put("ts", System.currentTimeMillis() / 1000);
UserCacheFactory.getUserCache(cordova.getActivity()).putLocalStorage(HAS_REQUESTED_NOTIFS_KEY, jo);
if (SensorControlChecks.checkNotificationsEnabled(cordova.getActivity())) {
SensorControlBackgroundChecker.restartFSMIfStartState(cordova.getActivity());
cordovaCallback.success();
} else {
cordovaCallback.error(cordova.getActivity().getString(R.string.notifications_blocked));
try {
JSONObject jo = new JSONObject();
jo.put("ts", System.currentTimeMillis() / 1000);
UserCacheFactory.getUserCache(cordova.getActivity()).putLocalStorage(HAS_REQUESTED_NOTIFS_KEY, jo);
if (SensorControlChecks.checkNotificationsEnabled(cordova.getActivity())) {
SensorControlBackgroundChecker.restartFSMIfStartState(cordova.getActivity());
cordovaCallback.success();
} else {
cordovaCallback.error(cordova.getActivity().getString(R.string.notifications_blocked));
}
} catch (JSONException e) {
cordovaCallback.error(e.getLocalizedMessage());
}
break;
case SensorControlConstants.REMOVE_UNUSED_APP_RESTRICTIONS:
Expand Down

0 comments on commit cc66591

Please sign in to comment.