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

Commit a8717feb authored by Soonil Nagarkar's avatar Soonil Nagarkar
Browse files

Add location notification and target sdk checks

Check target SDKs to disallow using setSecureSetting with LOCATION_MODE
and point clients to setLocationEnabled() instead. Show notifications to
users when location settings are changed by the admin.

Bug: 136219903
Test: manual - triggered setLocationEnabled and observed notification
Change-Id: I07c150e62230b06f76ec7bd5197a23e703ffb918
parent b642e394
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -8951,7 +8951,8 @@ public class DevicePolicyManager {
     *
     * <strong>Note: Starting from Android R, apps should no longer call this method with the
     * setting {@link android.provider.Settings.Secure#LOCATION_MODE}, which is deprecated. Instead,
     * device owners should call {@link #setLocationEnabled(ComponentName, boolean)}.
     * device owners should call {@link #setLocationEnabled(ComponentName, boolean)}. This will be
     * enforced for all apps targeting Android R or above.
     * </strong>
     *
     * @param admin Which {@link DeviceAdminReceiver} this request is associated with.
@@ -8961,6 +8962,7 @@ public class DevicePolicyManager {
     */
    public void setSecureSetting(@NonNull ComponentName admin, String setting, String value) {
        throwIfParentInstance("setSecureSetting");
        if (mService != null) {
            try {
                mService.setSecureSetting(admin, setting, value);
+8 −0
Original line number Diff line number Diff line
@@ -414,6 +414,14 @@
         logging. [CHAR LIMIT=NONE]-->
    <string name="network_logging_notification_text">Your organization manages this device and may monitor network traffic. Tap for details.</string>

    <!-- Content title for a notification. This notification indicates that the device owner has
         changed the location settings. [CHAR LIMIT=NONE] -->
    <string name="location_changed_notification_title">Location settings changed by your admin</string>
    <!-- Content text for a notification. Tapping opens device location settings.
         [CHAR LIMIT=NONE] -->
    <string name="location_changed_notification_text">Tap to see your location settings.</string>


    <!-- Factory reset warning dialog strings--> <skip />
    <!-- Shows up in the dialog's title to warn about an impeding factory reset. [CHAR LIMIT=NONE] -->
    <string name="factory_reset_warning">Your device will be erased</string>
+2 −0
Original line number Diff line number Diff line
@@ -1213,6 +1213,8 @@
  <java-symbol type="string" name="device_ownership_relinquished" />
  <java-symbol type="string" name="network_logging_notification_title" />
  <java-symbol type="string" name="network_logging_notification_text" />
  <java-symbol type="string" name="location_changed_notification_title" />
  <java-symbol type="string" name="location_changed_notification_text" />
  <java-symbol type="string" name="personal_apps_suspended_notification_title" />
  <java-symbol type="string" name="personal_apps_suspended_notification_text" />
  <java-symbol type="string" name="factory_reset_warning" />
+4 −0
Original line number Diff line number Diff line
@@ -244,6 +244,10 @@ message SystemMessage {
    // Package: android
    NOTE_SOFTAP_AUTO_DISABLED = 58;

    // Notify the user that their admin has changed location settings.
    // Package: android
    NOTE_LOCATION_CHANGED = 59;

    // ADD_NEW_IDS_ABOVE_THIS_LINE
    // Legacy IDs with arbitrary values appear below
    // Legacy IDs existed as stable non-conflicting constants prior to the O release
+9 −0
Original line number Diff line number Diff line
{
  "presubmit": [
    {
      "name": "CtsLocationFineTestCases"
    },
    {
      "name": "CtsLocationCoarseTestCases"
    },
    {
      "name": "CtsLocationNoneTestCases"
    },
    {
      "name": "FrameworksMockingServicesTests",
      "options": [{
        "include-filter": "com.android.server.location"
      }]
    }
  ]
}
 No newline at end of file
Loading