Merge "Fix potential crash in AppAllServicesPreferenceController" am: ccfa7fa918
am: 0ecb9e76fe
am: cf573d51c6
Original change: https://android-review.googlesource.com/c/platform/packages/apps/Settings/+/2296917 Change-Id: Ic7a008dc9320d6687ec44a14ec0caa8f4bfd5b96 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -47,19 +47,10 @@ public class AppAllServicesPreferenceController extends AppInfoPreferenceControl
|
||||
|
||||
private String mPackageName;
|
||||
|
||||
private boolean mCanPackageHandleAllServicesIntent;
|
||||
private boolean mIsLocationProvider;
|
||||
|
||||
|
||||
public AppAllServicesPreferenceController(Context context,
|
||||
String preferenceKey) {
|
||||
super(context, preferenceKey);
|
||||
mPackageManager = context.getPackageManager();
|
||||
|
||||
// Set to false till we can confirm that the package can handle the intent.
|
||||
mCanPackageHandleAllServicesIntent = false;
|
||||
// Set to false till we can confirm that the package is a location provider.
|
||||
mIsLocationProvider = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -71,9 +62,8 @@ public class AppAllServicesPreferenceController extends AppInfoPreferenceControl
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
@Nullable
|
||||
CharSequence getStorageSummary() {
|
||||
private CharSequence getStorageSummary() {
|
||||
ResolveInfo resolveInfo = getResolveInfo(PackageManager.GET_META_DATA);
|
||||
if (resolveInfo == null) {
|
||||
Log.d(TAG, "mResolveInfo is null.");
|
||||
@@ -96,18 +86,20 @@ public class AppAllServicesPreferenceController extends AppInfoPreferenceControl
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
if (mCanPackageHandleAllServicesIntent && mIsLocationProvider) {
|
||||
if (canPackageHandleIntent() && isLocationProvider()) {
|
||||
return AVAILABLE;
|
||||
}
|
||||
return CONDITIONALLY_UNAVAILABLE;
|
||||
}
|
||||
|
||||
private boolean isLocationProvider() {
|
||||
@VisibleForTesting
|
||||
boolean isLocationProvider() {
|
||||
return Objects.requireNonNull(
|
||||
mContext.getSystemService(LocationManager.class)).isProviderPackage(mPackageName);
|
||||
}
|
||||
|
||||
private boolean canPackageHandleIntent() {
|
||||
@VisibleForTesting
|
||||
boolean canPackageHandleIntent() {
|
||||
return getResolveInfo(0) != null;
|
||||
}
|
||||
|
||||
@@ -127,14 +119,6 @@ public class AppAllServicesPreferenceController extends AppInfoPreferenceControl
|
||||
*/
|
||||
public void setPackageName(String packageName) {
|
||||
mPackageName = packageName;
|
||||
|
||||
//Once we have package name. Update conditions for availability.
|
||||
updateAvailabilityConditions();
|
||||
}
|
||||
|
||||
private void updateAvailabilityConditions() {
|
||||
mCanPackageHandleAllServicesIntent = canPackageHandleIntent();
|
||||
mIsLocationProvider = isLocationProvider();
|
||||
}
|
||||
|
||||
private void startAllServicesActivity() {
|
||||
|
Reference in New Issue
Block a user