diff --git a/location/java/android/location/LocationManager.java b/location/java/android/location/LocationManager.java index f5330b444818f..1cc246b517657 100644 --- a/location/java/android/location/LocationManager.java +++ b/location/java/android/location/LocationManager.java @@ -190,19 +190,6 @@ public class LocationManager { */ public static final String MODE_CHANGED_ACTION = "android.location.MODE_CHANGED"; - /** - * Broadcast intent action when {@link android.provider.Settings.Secure#LOCATION_MODE} is - * about to be changed through Settings app or Quick Settings. - * For use with the {@link android.provider.Settings.Secure#LOCATION_MODE} API. - * If you're interacting with {@link #isProviderEnabled(String)}, use - * {@link #PROVIDERS_CHANGED_ACTION} instead. - * - * @deprecated Do not use. - * @hide - */ - @Deprecated - public static final String MODE_CHANGING_ACTION = "com.android.settings.location.MODE_CHANGING"; - /** * Broadcast intent action indicating that a high power location requests * has either started or stopped being active. The current state of @@ -216,17 +203,10 @@ public class LocationManager { /** * Broadcast intent action for Settings app to inject a footer at the bottom of location - * settings. + * settings. This is for use only by apps that are included in the system image. * - *

This broadcast is used for two things: - *

    - *
  1. For receivers to inject a footer with provided text. This is for use only by apps - * that are included in the system image.
  2. - *
  3. For receivers to know their footer is injected under location settings.
  4. - *
- * - *

To inject a footer to location settings, you must declare a broadcast receiver of - * {@link LocationManager#SETTINGS_FOOTER_DISPLAYED_ACTION} in the manifest as so: + *

To inject a footer to location settings, you must declare a broadcast receiver for + * this action in the manifest: *

      *     <receiver android:name="com.example.android.footer.MyFooterInjector">
      *         <intent-filter>
@@ -238,26 +218,14 @@ public class LocationManager {
      *     </receiver>
      * 
* - *

On entering location settings, Settings app will send a - * {@link #SETTINGS_FOOTER_DISPLAYED_ACTION} broadcast to receivers whose footer is successfully - * injected. On leaving location settings, the footer becomes not visible to users. Settings app - * will send a {@link #SETTINGS_FOOTER_REMOVED_ACTION} broadcast to those receivers. + *

This broadcast receiver will never actually be invoked. See also + * {#METADATA_SETTINGS_FOOTER_STRING}. * * @hide */ public static final String SETTINGS_FOOTER_DISPLAYED_ACTION = "com.android.settings.location.DISPLAYED_FOOTER"; - /** - * Broadcast intent action when location settings footer is not visible to users. - * - *

See {@link #SETTINGS_FOOTER_DISPLAYED_ACTION} for more detail on how to use. - * - * @hide - */ - public static final String SETTINGS_FOOTER_REMOVED_ACTION = - "com.android.settings.location.REMOVED_FOOTER"; - /** * Metadata name for {@link LocationManager#SETTINGS_FOOTER_DISPLAYED_ACTION} broadcast * receivers to specify a string resource id as location settings footer text. This is for use diff --git a/packages/SettingsLib/src/com/android/settingslib/Utils.java b/packages/SettingsLib/src/com/android/settingslib/Utils.java index eb5ca46b0d337..14f233d958e67 100644 --- a/packages/SettingsLib/src/com/android/settingslib/Utils.java +++ b/packages/SettingsLib/src/com/android/settingslib/Utils.java @@ -35,8 +35,6 @@ import java.text.NumberFormat; public class Utils { - private static final String CURRENT_MODE_KEY = "CURRENT_MODE"; - private static final String NEW_MODE_KEY = "NEW_MODE"; @VisibleForTesting static final String STORAGE_MANAGER_ENABLED_PROPERTY = "ro.storage_manager.enabled"; @@ -56,24 +54,11 @@ public class Utils { public static void updateLocationEnabled(Context context, boolean enabled, int userId, int source) { - LocationManager locationManager = context.getSystemService(LocationManager.class); - Settings.Secure.putIntForUser( context.getContentResolver(), Settings.Secure.LOCATION_CHANGER, source, userId); - Intent intent = new Intent(LocationManager.MODE_CHANGING_ACTION); - final int oldMode = locationManager.isLocationEnabled() - ? Settings.Secure.LOCATION_MODE_ON - : Settings.Secure.LOCATION_MODE_OFF; - final int newMode = enabled - ? Settings.Secure.LOCATION_MODE_ON - : Settings.Secure.LOCATION_MODE_OFF; - intent.putExtra(CURRENT_MODE_KEY, oldMode); - intent.putExtra(NEW_MODE_KEY, newMode); - context.sendBroadcastAsUser( - intent, UserHandle.of(userId), android.Manifest.permission.WRITE_SECURE_SETTINGS); - + LocationManager locationManager = context.getSystemService(LocationManager.class); locationManager.setLocationEnabledForUser(enabled, UserHandle.of(userId)); } diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/UtilsTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/UtilsTest.java index 4d76e44a3c50d..fc69b1a657d4b 100644 --- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/UtilsTest.java +++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/UtilsTest.java @@ -15,17 +15,13 @@ */ package com.android.settingslib; -import static android.Manifest.permission.WRITE_SECURE_SETTINGS; - import static com.android.settingslib.Utils.STORAGE_MANAGER_ENABLED_PROPERTY; import static com.google.common.truth.Truth.assertThat; -import static org.mockito.ArgumentMatchers.argThat; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.app.ActivityManager; @@ -45,7 +41,6 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.ArgumentMatcher; -import org.mockito.ArgumentMatchers; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.robolectric.RobolectricTestRunner; @@ -85,15 +80,11 @@ public class UtilsTest { } @Test - public void testUpdateLocationEnabled_sendBroadcast() { + public void testUpdateLocationEnabled() { int currentUserId = ActivityManager.getCurrentUser(); Utils.updateLocationEnabled(mContext, true, currentUserId, Settings.Secure.LOCATION_CHANGER_QUICK_SETTINGS); - verify(mContext).sendBroadcastAsUser( - argThat(actionMatches(LocationManager.MODE_CHANGING_ACTION)), - ArgumentMatchers.eq(UserHandle.of(currentUserId)), - ArgumentMatchers.eq(WRITE_SECURE_SETTINGS)); assertThat(Settings.Secure.getInt(mContext.getContentResolver(), Settings.Secure.LOCATION_CHANGER, Settings.Secure.LOCATION_CHANGER_UNKNOWN)) .isEqualTo(Settings.Secure.LOCATION_CHANGER_QUICK_SETTINGS);