<string name="location_mode_battery_saving_description">Use Wi\u2011Fi, Bluetooth, or mobile networks to determine location</string>
<!-- [CHAR LIMIT=130] Location mode screen, description for sensors only mode -->
<string name="location_mode_sensors_only_description">Use GPS to determine location</string>
- <!-- Help menu label [CHAR LIMIT=20] Location settings screen, overflow menu that takes the user
- to scanning settings activity -->
- <string name="location_menu_scanning">Scanning</string>
<!-- [CHAR LIMIT=30] Wireless background scanning settings screen, screen title -->
<string name="location_scanning_screen_title">Scanning</string>
<!-- [CHAR LIMIT=130] Preference title for Wi-Fi always scanning -->
package com.android.settings.location;
import android.app.Activity;
-import android.app.admin.DevicePolicyManager;
import android.content.BroadcastReceiver;
-import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.os.UserHandle;
import android.os.UserManager;
-import android.provider.Settings;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceCategory;
import android.support.v7.preference.PreferenceGroup;
import android.support.v7.preference.PreferenceScreen;
import android.util.Log;
-import android.view.Menu;
-import android.view.MenuInflater;
-import android.view.MenuItem;
import android.widget.Switch;
+
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.DimmableIconPreference;
import com.android.settings.R;
/** Key for preference category "Location services" */
private static final String KEY_LOCATION_SERVICES = "location_services";
- private static final int MENU_SCANNING = Menu.FIRST;
-
private SwitchBar mSwitchBar;
private Switch mSwitch;
private boolean mValidListener = false;
injector = new SettingsInjector(context);
// If location access is locked down by device policy then we only show injected settings
// for the primary profile.
- List<Preference> locationServices = injector.getInjectedSettings(lockdownOnLocationAccess ?
- UserHandle.myUserId() : UserHandle.USER_CURRENT);
+ final Context prefContext = categoryLocationServices.getContext();
+ final List<Preference> locationServices = injector.getInjectedSettings(prefContext,
+ lockdownOnLocationAccess ? UserHandle.myUserId() : UserHandle.USER_CURRENT);
mReceiver = new BroadcastReceiver() {
@Override
}
@Override
- public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
- menu.add(0, MENU_SCANNING, 0, R.string.location_menu_scanning);
- // The super class adds "Help & Feedback" menu item.
- super.onCreateOptionsMenu(menu, inflater);
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- final SettingsActivity activity = (SettingsActivity) getActivity();
- switch (item.getItemId()) {
- case MENU_SCANNING:
- activity.startPreferencePanel(
- this,
- ScanningSettings.class.getName(), null,
- R.string.location_scanning_screen_title, null, LocationSettings.this,
- 0);
- return true;
- default:
- return super.onOptionsItemSelected(item);
- }
- }
-
- @Override
public int getHelpResource() {
return R.string.help_url_location_access;
}
* @param profileId Identifier of the user/profile to obtain the injected settings for or
* UserHandle.USER_CURRENT for all profiles associated with current user.
*/
- public List<Preference> getInjectedSettings(final int profileId) {
+ public List<Preference> getInjectedSettings(Context prefContext, final int profileId) {
final UserManager um = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
final List<UserHandle> profiles = um.getUserProfiles();
- ArrayList<Preference> prefs = new ArrayList<Preference>();
+ ArrayList<Preference> prefs = new ArrayList<>();
final int profileCount = profiles.size();
for (int i = 0; i < profileCount; ++i) {
final UserHandle userHandle = profiles.get(i);
if (profileId == UserHandle.USER_CURRENT || profileId == userHandle.getIdentifier()) {
Iterable<InjectedSetting> settings = getSettings(userHandle);
for (InjectedSetting setting : settings) {
- Preference pref = addServiceSetting(prefs, setting);
+ Preference pref = addServiceSetting(prefContext, prefs, setting);
mSettings.add(new Setting(setting, pref));
}
}
/**
* Adds an injected setting to the root.
*/
- private Preference addServiceSetting(List<Preference> prefs, InjectedSetting info) {
+ private Preference addServiceSetting(Context prefContext, List<Preference> prefs,
+ InjectedSetting info) {
PackageManager pm = mContext.getPackageManager();
Drawable appIcon = pm.getDrawable(info.packageName, info.iconId, null);
Drawable icon = pm.getUserBadgedIcon(appIcon, info.mUserHandle);
// a separate content description.
badgedAppLabel = null;
}
- Preference pref = new DimmableIconPreference(mContext, badgedAppLabel);
+ Preference pref = new DimmableIconPreference(prefContext, badgedAppLabel);
pref.setTitle(info.title);
pref.setSummary(null);
pref.setIcon(icon);