From cc6659131dac1e1d3d66489d9b91090f5d3633b5 Mon Sep 17 00:00:00 2001 From: Shankari Date: Tue, 8 Oct 2024 15:26:35 -0700 Subject: [PATCH] Catch JSON exception and return an error to get android to compile --- .../SensorControlForegroundDelegate.java | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/android/verification/SensorControlForegroundDelegate.java b/src/android/verification/SensorControlForegroundDelegate.java index 85f4d30..14b5617 100644 --- a/src/android/verification/SensorControlForegroundDelegate.java +++ b/src/android/verification/SensorControlForegroundDelegate.java @@ -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: