Prevent the disabling of specified apps

Prevent the disabling of specified apps, avoiding cases
where disabling the app may result in an unusable system.

Bug: 200043113
Test: make RunSettingsRoboTests ROBOTEST_FILTER=ApplicationFeatureProviderImplTest

(cherry picked from https://android-review.googlesource.com/q/commit:e6279dd6a20ee254bab9a66e545b9dbaf1895db0)
Change-Id: I0b298af76cec20e4f31ec7411bbf3200a2869035
This commit is contained in:
Edward Savage-Jones
2024-01-04 22:40:27 +00:00
committed by Chris Antol
parent d4d9c4fe59
commit 03bde3d8c6
2 changed files with 22 additions and 0 deletions

View File

@@ -32,6 +32,7 @@ import android.content.pm.ServiceInfo;
import android.content.pm.UserInfo;
import android.location.LocationManager;
import android.os.RemoteException;
import android.os.SystemConfigManager;
import android.os.UserManager;
import android.service.euicc.EuiccService;
import android.telecom.DefaultDialerManager;
@@ -58,6 +59,8 @@ public class ApplicationFeatureProviderImpl implements ApplicationFeatureProvide
private final DevicePolicyManager mDpm;
private final UserManager mUm;
private final WebViewUpdateServiceWrapper mWebViewUpdateServiceWrapper;
private final SystemConfigManager mSystemConfigManager;
/** Flags to use when querying PackageManager for Euicc component implementations. */
private static final int EUICC_QUERY_FLAGS =
PackageManager.MATCH_SYSTEM_ONLY | PackageManager.MATCH_DEBUG_TRIAGED_MISSING
@@ -75,6 +78,7 @@ public class ApplicationFeatureProviderImpl implements ApplicationFeatureProvide
mDpm = dpm;
mUm = UserManager.get(mContext);
mWebViewUpdateServiceWrapper = wvusWrapper;
mSystemConfigManager = context.getSystemService(SystemConfigManager.class);
}
@Override
@@ -184,6 +188,7 @@ public class ApplicationFeatureProviderImpl implements ApplicationFeatureProvide
if (locationHistoryPackage != null) {
keepEnabledPackages.add(locationHistoryPackage);
}
keepEnabledPackages.addAll(mSystemConfigManager.getPreventUserDisablePackages());
return keepEnabledPackages;
}