Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3d33dcc0 authored by Eran Messeri's avatar Eran Messeri Committed by Automerger Merge Worker
Browse files

Merge "Only notify when admin enables location for the user" into rvc-dev am:...

Merge "Only notify when admin enables location for the user" into rvc-dev am: 35f33f42 am: 9b1c4372

Change-Id: Ia94fb6184c62fad9baec94ee6695f49cacb849fd
parents 31ecfdb0 9b1c4372
Loading
Loading
Loading
Loading
+10 −7
Original line number Original line Diff line number Diff line
@@ -11951,11 +11951,11 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
                    user);
                    user);
            mInjector.getLocationManager().setLocationEnabledForUser(locationEnabled, user);
            mInjector.getLocationManager().setLocationEnabledForUser(locationEnabled, user);
            // make a best effort to only show the notification if the admin is actually changing
            // make a best effort to only show the notification if the admin is actually enabling
            // something. this is subject to race conditions with settings changes, but those are
            // location. this is subject to race conditions with settings changes, but those are
            // unlikely to realistically interfere
            // unlikely to realistically interfere
            if (wasLocationEnabled != locationEnabled) {
            if (locationEnabled && (wasLocationEnabled != locationEnabled)) {
                showLocationSettingsChangedNotification(user);
                showLocationSettingsEnabledNotification(user);
            }
            }
        });
        });
@@ -11968,7 +11968,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
                .write();
                .write();
    }
    }
    private void showLocationSettingsChangedNotification(UserHandle user) {
    private void showLocationSettingsEnabledNotification(UserHandle user) {
        Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS)
        Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS)
                .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        // Fill the component explicitly to prevent the PendingIntent from being intercepted
        // Fill the component explicitly to prevent the PendingIntent from being intercepted
@@ -12100,8 +12100,11 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
                    saveSettingsLocked(callingUserId);
                    saveSettingsLocked(callingUserId);
                }
                }
                mInjector.settingsSecurePutStringForUser(setting, value, callingUserId);
                mInjector.settingsSecurePutStringForUser(setting, value, callingUserId);
                if (setting.equals(Settings.Secure.LOCATION_MODE)) {
                // Notify the user if it's the location mode setting that's been set, to any value
                    showLocationSettingsChangedNotification(UserHandle.of(callingUserId));
                // other than 'off'.
                if (setting.equals(Settings.Secure.LOCATION_MODE)
                        && (Integer.parseInt(value) != 0)) {
                    showLocationSettingsEnabledNotification(UserHandle.of(callingUserId));
                }
                }
            });
            });
        }
        }