Refactor LocationSettings
- Extends BasePreferenceController in LocationBasePreferenceController which binds preference key based on xml file instead of writing the key in java code. Then the controller can be used in many xmls. - Modify LocationServicePreferenceController to support only personal or profile user. Bug: 141601408 Test: manual, robolectric Change-Id: I51ee950dfb87474df84a8dc3db55fb911edcf599
This commit is contained in:
@@ -13,7 +13,6 @@
|
||||
*/
|
||||
package com.android.settings.location;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ActivityInfo;
|
||||
@@ -24,7 +23,6 @@ import android.content.pm.ResolveInfo;
|
||||
import android.location.LocationManager;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceCategory;
|
||||
|
||||
@@ -41,23 +39,16 @@ import java.util.List;
|
||||
public class LocationFooterPreferenceController extends LocationBasePreferenceController {
|
||||
|
||||
private static final String TAG = "LocationFooter";
|
||||
private static final String KEY_LOCATION_FOOTER = "location_footer";
|
||||
private static final Intent INJECT_INTENT =
|
||||
new Intent(LocationManager.SETTINGS_FOOTER_DISPLAYED_ACTION);
|
||||
|
||||
private final PackageManager mPackageManager;
|
||||
|
||||
public LocationFooterPreferenceController(Context context) {
|
||||
// we don't care location mode changes, so pass in a null lifecycle to disable listening
|
||||
super(context, null);
|
||||
public LocationFooterPreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
mPackageManager = context.getPackageManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPreferenceKey() {
|
||||
return KEY_LOCATION_FOOTER;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert footer preferences.
|
||||
*/
|
||||
@@ -97,8 +88,8 @@ public class LocationFooterPreferenceController extends LocationBasePreferenceCo
|
||||
* inject.
|
||||
*/
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
return !getFooterData().isEmpty();
|
||||
public int getAvailabilityStatus() {
|
||||
return !getFooterData().isEmpty() ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user