Move intent action to xml
This is a follow-up change for ag/1798497 which move the implementation of OnPreferenceClickListener to the xml. Test: Manual bug: 34400189 Change-Id: I4691beecf829e8d98d5c6188b3ff74f4902104d2
This commit is contained in:
@@ -37,7 +37,12 @@
|
|||||||
<!-- This preference category gets removed if new_recent_location_ui is disabled -->
|
<!-- This preference category gets removed if new_recent_location_ui is disabled -->
|
||||||
<Preference
|
<Preference
|
||||||
android:key="app_level_permissions"
|
android:key="app_level_permissions"
|
||||||
android:title="@string/location_app_level_permissions" />
|
android:title="@string/location_app_level_permissions">
|
||||||
|
<intent android:action="android.intent.action.MANAGE_PERMISSION_APPS">
|
||||||
|
<extra android:name="android.intent.extra.PERMISSION_NAME"
|
||||||
|
android:value="android.permission-group.LOCATION" />
|
||||||
|
</intent>
|
||||||
|
</Preference>
|
||||||
|
|
||||||
<com.android.settings.DividedCategory
|
<com.android.settings.DividedCategory
|
||||||
android:key="recent_location_requests"
|
android:key="recent_location_requests"
|
||||||
|
@@ -18,7 +18,6 @@ package com.android.settings.location;
|
|||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.admin.DevicePolicyManager;
|
import android.app.admin.DevicePolicyManager;
|
||||||
import android.content.ActivityNotFoundException;
|
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@@ -96,14 +95,11 @@ public class LocationSettings extends LocationSettingsBase
|
|||||||
private static final String KEY_LOCATION_MODE = "location_mode";
|
private static final String KEY_LOCATION_MODE = "location_mode";
|
||||||
/** Key for preference category "Recent location requests" */
|
/** Key for preference category "Recent location requests" */
|
||||||
private static final String KEY_RECENT_LOCATION_REQUESTS = "recent_location_requests";
|
private static final String KEY_RECENT_LOCATION_REQUESTS = "recent_location_requests";
|
||||||
/** Key for preference "App-level permissions" */
|
|
||||||
private static final String KEY_APP_LEVEL_PERMISSIONS = "app_level_permissions";
|
|
||||||
/** Key for preference category "Location services" */
|
/** Key for preference category "Location services" */
|
||||||
private static final String KEY_LOCATION_SERVICES = "location_services";
|
private static final String KEY_LOCATION_SERVICES = "location_services";
|
||||||
|
|
||||||
private static final int MENU_SCANNING = Menu.FIRST;
|
private static final int MENU_SCANNING = Menu.FIRST;
|
||||||
|
|
||||||
private static final String KEY_LOCATION_PERMISSION = "android.permission-group.LOCATION";
|
|
||||||
private SwitchBar mSwitchBar;
|
private SwitchBar mSwitchBar;
|
||||||
private Switch mSwitch;
|
private Switch mSwitch;
|
||||||
private boolean mValidListener = false;
|
private boolean mValidListener = false;
|
||||||
@@ -211,11 +207,6 @@ public class LocationSettings extends LocationSettingsBase
|
|||||||
final AppLocationPermissionPreferenceController preferenceController =
|
final AppLocationPermissionPreferenceController preferenceController =
|
||||||
new AppLocationPermissionPreferenceController(activity);
|
new AppLocationPermissionPreferenceController(activity);
|
||||||
preferenceController.displayPreference(root);
|
preferenceController.displayPreference(root);
|
||||||
if (preferenceController.isAvailable()) {
|
|
||||||
Preference preferenceAppLevelPermissions =
|
|
||||||
root.findPreference(KEY_APP_LEVEL_PERMISSIONS);
|
|
||||||
setupAppLevelPermissionsPreference(preferenceAppLevelPermissions);
|
|
||||||
}
|
|
||||||
|
|
||||||
mCategoryRecentLocationRequests =
|
mCategoryRecentLocationRequests =
|
||||||
(PreferenceCategory) root.findPreference(KEY_RECENT_LOCATION_REQUESTS);
|
(PreferenceCategory) root.findPreference(KEY_RECENT_LOCATION_REQUESTS);
|
||||||
@@ -276,23 +267,6 @@ public class LocationSettings extends LocationSettingsBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupAppLevelPermissionsPreference(Preference preference) {
|
|
||||||
preference.setOnPreferenceClickListener(
|
|
||||||
new Preference.OnPreferenceClickListener() {
|
|
||||||
@Override
|
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
|
||||||
Intent intent = new Intent(Intent.ACTION_MANAGE_PERMISSION_APPS)
|
|
||||||
.putExtra(Intent.EXTRA_PERMISSION_NAME, KEY_LOCATION_PERMISSION);
|
|
||||||
try {
|
|
||||||
getActivity().startActivity(intent);
|
|
||||||
} catch (ActivityNotFoundException e) {
|
|
||||||
Log.w("Permission", "No app to handle " + intent);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void changeManagedProfileLocationAccessStatus(boolean mainSwitchOn) {
|
private void changeManagedProfileLocationAccessStatus(boolean mainSwitchOn) {
|
||||||
if (mManagedProfileSwitch == null) {
|
if (mManagedProfileSwitch == null) {
|
||||||
return;
|
return;
|
||||||
|
Reference in New Issue
Block a user