Remove obsolete constants.

These constants are not in use anywhere.

Test: na
Bug: 137675020
Change-Id: I9f1b2101b75779ff2f9c5f9d945189eccff782ae
This commit is contained in:
Soonil Nagarkar 2019-07-16 11:47:59 -07:00
parent e3d284e255
commit fb6b187bfb
3 changed files with 7 additions and 63 deletions

View File

@ -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.
*
* <p>This broadcast is used for two things:
* <ol>
* <li>For receivers to inject a footer with provided text. This is for use only by apps
* that are included in the system image. </li>
* <li>For receivers to know their footer is injected under location settings.</li>
* </ol>
*
* <p>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:
* <p>To inject a footer to location settings, you must declare a broadcast receiver for
* this action in the manifest:
* <pre>
* &lt;receiver android:name="com.example.android.footer.MyFooterInjector"&gt;
* &lt;intent-filter&gt;
@ -238,26 +218,14 @@ public class LocationManager {
* &lt;/receiver&gt;
* </pre>
*
* <p>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.
* <p>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.
*
* <p>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

View File

@ -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));
}

View File

@ -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);