Skip to content

Commit

Permalink
prevent removed permissions from crashing the app - disable the offen…
Browse files Browse the repository at this point in the history
…ding service and inform the user
  • Loading branch information
mathisdt committed Jan 3, 2024
1 parent 954842f commit 2809fb1
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion app/src/main/java/org/zephyrsoft/trackworktime/Basics.java
Expand Up @@ -523,7 +523,9 @@ private void checkLocationBasedTracking() {
private void startLocationTrackerService(double latitude, double longitude, double tolerance, Boolean vibrate) {
Set<String> missingPermissions = PermissionsUtil.missingPermissionsForTracking(context);
if (!missingPermissions.isEmpty()) {
Logger.debug("not starting location tracker service because of missing permissions: {}", missingPermissions);
Logger.warn("not starting location tracker service because of missing permissions, disabling automatic tracking: {}", missingPermissions);
PreferencesUtil.disableAutomaticTracking(context);
Toast.makeText(context, context.getString(R.string.locationPermissionsRemoved), Toast.LENGTH_LONG).show();
return;
}
try {
Expand Down Expand Up @@ -585,6 +587,13 @@ private void checkWifiBasedTracking() {
* start the wifi-based tracking service by serviceIntent
*/
private void startWifiTrackerService(String ssid, Boolean vibrate, Integer checkInterval) {
Set<String> missingPermissions = PermissionsUtil.missingPermissionsForTracking(context);
if (!missingPermissions.isEmpty()) {
Logger.warn("not starting WiFi tracker service because of missing permissions, disabling automatic tracking: {}", missingPermissions);
PreferencesUtil.disableAutomaticTracking(context);
Toast.makeText(context, context.getString(R.string.locationPermissionsRemoved), Toast.LENGTH_LONG).show();
return;
}
try {
Intent startIntent = buildWifiTrackerServiceIntent(ssid, vibrate, checkInterval);
Logger.debug("try to start wifi-based tracking service");
Expand Down

0 comments on commit 2809fb1

Please sign in to comment.