Loading core/java/android/provider/Settings.java +22 −0 Original line number Diff line number Diff line Loading @@ -5509,6 +5509,27 @@ public final class Settings { @Deprecated public static final String LOCATION_MODE = "location_mode"; /** * The App or module that changes the location mode. * @hide */ public static final String LOCATION_CHANGER = "location_changer"; /** * The location changer is unknown or unable to detect. * @hide */ public static final int LOCATION_CHANGER_UNKNOWN = 0; /** * Location settings in system settings. * @hide */ public static final int LOCATION_CHANGER_SYSTEM_SETTINGS = 1; /** * The location icon in drop down notification drawer. * @hide */ public static final int LOCATION_CHANGER_QUICK_SETTINGS = 2; /** * Location access disabled. * Loading Loading @@ -7881,6 +7902,7 @@ public final class Settings { CLONE_TO_MANAGED_PROFILE.add(DEFAULT_INPUT_METHOD); CLONE_TO_MANAGED_PROFILE.add(ENABLED_ACCESSIBILITY_SERVICES); CLONE_TO_MANAGED_PROFILE.add(ENABLED_INPUT_METHODS); CLONE_TO_MANAGED_PROFILE.add(LOCATION_CHANGER); CLONE_TO_MANAGED_PROFILE.add(LOCATION_MODE); CLONE_TO_MANAGED_PROFILE.add(LOCATION_PROVIDERS_ALLOWED); CLONE_TO_MANAGED_PROFILE.add(SELECTED_INPUT_METHOD_SUBTYPE); Loading core/tests/coretests/src/android/provider/SettingsBackupTest.java +1 −0 Original line number Diff line number Diff line Loading @@ -497,6 +497,7 @@ public class SettingsBackupTest { Settings.Secure.INPUT_METHODS_SUBTYPE_HISTORY, Settings.Secure.INSTALL_NON_MARKET_APPS, Settings.Secure.LAST_SETUP_SHOWN, Settings.Secure.LOCATION_CHANGER, Settings.Secure.LOCATION_MODE, Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, // Candidate? Settings.Secure.LOCK_SCREEN_ALLOW_REMOTE_INPUT, // Candidate? Loading packages/SettingsLib/src/com/android/settingslib/Utils.java +10 −2 Original line number Diff line number Diff line Loading @@ -44,7 +44,11 @@ public class Utils { com.android.internal.R.drawable.ic_wifi_signal_4 }; public static void updateLocationEnabled(Context context, boolean enabled, int userId) { public static void updateLocationEnabled(Context context, boolean enabled, int userId, int source) { Settings.Secure.putIntForUser( context.getContentResolver(), Settings.Secure.LOCATION_CHANGER, source, userId); Intent intent = new Intent(LocationManager.MODE_CHANGING_ACTION); final int oldMode = Settings.Secure.getIntForUser(context.getContentResolver(), Loading @@ -62,7 +66,11 @@ public class Utils { wrapper.setLocationEnabledForUser(enabled, UserHandle.of(userId)); } public static boolean updateLocationMode(Context context, int oldMode, int newMode, int userId) { public static boolean updateLocationMode(Context context, int oldMode, int newMode, int userId, int source) { Settings.Secure.putIntForUser( context.getContentResolver(), Settings.Secure.LOCATION_CHANGER, source, userId); Intent intent = new Intent(LocationManager.MODE_CHANGING_ACTION); intent.putExtra(CURRENT_MODE_KEY, oldMode); intent.putExtra(NEW_MODE_KEY, newMode); Loading packages/SettingsLib/tests/robotests/src/com/android/settingslib/UtilsTest.java +10 −2 Original line number Diff line number Diff line Loading @@ -84,23 +84,31 @@ public class UtilsTest { mContext, Secure.LOCATION_MODE_OFF, Secure.LOCATION_MODE_HIGH_ACCURACY, currentUserId); 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); } @Test public void testUpdateLocationEnabled_sendBroadcast() { int currentUserId = ActivityManager.getCurrentUser(); Utils.updateLocationEnabled(mContext, true, currentUserId); 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); } @Test Loading packages/SystemUI/src/com/android/systemui/statusbar/policy/LocationControllerImpl.java +3 −1 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import android.os.Message; import android.os.Process; import android.os.UserHandle; import android.os.UserManager; import android.provider.Settings; import android.support.annotation.VisibleForTesting; import com.android.systemui.util.Utils; import java.util.ArrayList; Loading Loading @@ -105,7 +106,8 @@ public class LocationControllerImpl extends BroadcastReceiver implements Locatio } // When enabling location, a user consent dialog will pop up, and the // setting won't be fully enabled until the user accepts the agreement. updateLocationEnabled(mContext, enabled, currentUserId); updateLocationEnabled(mContext, enabled, currentUserId, Settings.Secure.LOCATION_CHANGER_QUICK_SETTINGS); return true; } Loading Loading
core/java/android/provider/Settings.java +22 −0 Original line number Diff line number Diff line Loading @@ -5509,6 +5509,27 @@ public final class Settings { @Deprecated public static final String LOCATION_MODE = "location_mode"; /** * The App or module that changes the location mode. * @hide */ public static final String LOCATION_CHANGER = "location_changer"; /** * The location changer is unknown or unable to detect. * @hide */ public static final int LOCATION_CHANGER_UNKNOWN = 0; /** * Location settings in system settings. * @hide */ public static final int LOCATION_CHANGER_SYSTEM_SETTINGS = 1; /** * The location icon in drop down notification drawer. * @hide */ public static final int LOCATION_CHANGER_QUICK_SETTINGS = 2; /** * Location access disabled. * Loading Loading @@ -7881,6 +7902,7 @@ public final class Settings { CLONE_TO_MANAGED_PROFILE.add(DEFAULT_INPUT_METHOD); CLONE_TO_MANAGED_PROFILE.add(ENABLED_ACCESSIBILITY_SERVICES); CLONE_TO_MANAGED_PROFILE.add(ENABLED_INPUT_METHODS); CLONE_TO_MANAGED_PROFILE.add(LOCATION_CHANGER); CLONE_TO_MANAGED_PROFILE.add(LOCATION_MODE); CLONE_TO_MANAGED_PROFILE.add(LOCATION_PROVIDERS_ALLOWED); CLONE_TO_MANAGED_PROFILE.add(SELECTED_INPUT_METHOD_SUBTYPE); Loading
core/tests/coretests/src/android/provider/SettingsBackupTest.java +1 −0 Original line number Diff line number Diff line Loading @@ -497,6 +497,7 @@ public class SettingsBackupTest { Settings.Secure.INPUT_METHODS_SUBTYPE_HISTORY, Settings.Secure.INSTALL_NON_MARKET_APPS, Settings.Secure.LAST_SETUP_SHOWN, Settings.Secure.LOCATION_CHANGER, Settings.Secure.LOCATION_MODE, Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, // Candidate? Settings.Secure.LOCK_SCREEN_ALLOW_REMOTE_INPUT, // Candidate? Loading
packages/SettingsLib/src/com/android/settingslib/Utils.java +10 −2 Original line number Diff line number Diff line Loading @@ -44,7 +44,11 @@ public class Utils { com.android.internal.R.drawable.ic_wifi_signal_4 }; public static void updateLocationEnabled(Context context, boolean enabled, int userId) { public static void updateLocationEnabled(Context context, boolean enabled, int userId, int source) { Settings.Secure.putIntForUser( context.getContentResolver(), Settings.Secure.LOCATION_CHANGER, source, userId); Intent intent = new Intent(LocationManager.MODE_CHANGING_ACTION); final int oldMode = Settings.Secure.getIntForUser(context.getContentResolver(), Loading @@ -62,7 +66,11 @@ public class Utils { wrapper.setLocationEnabledForUser(enabled, UserHandle.of(userId)); } public static boolean updateLocationMode(Context context, int oldMode, int newMode, int userId) { public static boolean updateLocationMode(Context context, int oldMode, int newMode, int userId, int source) { Settings.Secure.putIntForUser( context.getContentResolver(), Settings.Secure.LOCATION_CHANGER, source, userId); Intent intent = new Intent(LocationManager.MODE_CHANGING_ACTION); intent.putExtra(CURRENT_MODE_KEY, oldMode); intent.putExtra(NEW_MODE_KEY, newMode); Loading
packages/SettingsLib/tests/robotests/src/com/android/settingslib/UtilsTest.java +10 −2 Original line number Diff line number Diff line Loading @@ -84,23 +84,31 @@ public class UtilsTest { mContext, Secure.LOCATION_MODE_OFF, Secure.LOCATION_MODE_HIGH_ACCURACY, currentUserId); 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); } @Test public void testUpdateLocationEnabled_sendBroadcast() { int currentUserId = ActivityManager.getCurrentUser(); Utils.updateLocationEnabled(mContext, true, currentUserId); 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); } @Test Loading
packages/SystemUI/src/com/android/systemui/statusbar/policy/LocationControllerImpl.java +3 −1 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import android.os.Message; import android.os.Process; import android.os.UserHandle; import android.os.UserManager; import android.provider.Settings; import android.support.annotation.VisibleForTesting; import com.android.systemui.util.Utils; import java.util.ArrayList; Loading Loading @@ -105,7 +106,8 @@ public class LocationControllerImpl extends BroadcastReceiver implements Locatio } // When enabling location, a user consent dialog will pop up, and the // setting won't be fully enabled until the user accepts the agreement. updateLocationEnabled(mContext, enabled, currentUserId); updateLocationEnabled(mContext, enabled, currentUserId, Settings.Secure.LOCATION_CHANGER_QUICK_SETTINGS); return true; } Loading