Implement uninstall apps in CarSettings.
This follows as close as possible to the constraints implemented in Phone Settings. We don't yet have a mechanism for OEMs to define "keep enabled" packages, but it can be included in a later change. Phone Settings redirects to Device Admin pages which are not implemented in CarSettings for certain uninstall conditions. We disable the button for now pending adding those pages / direction from UX.
Bug: 79492615
Test: build and deploy, install/uninstall/enable/disable/force stop, RunCarSettingsRoboTests
Change-Id: I3a3f0a52eeb34f0b8708210a25b47f3ea75935e1
diff --git a/tests/robotests/src/com/android/car/settings/testutils/ShadowDevicePolicyManager.java b/tests/robotests/src/com/android/car/settings/testutils/ShadowDevicePolicyManager.java
index 85248af..5a6e713 100644
--- a/tests/robotests/src/com/android/car/settings/testutils/ShadowDevicePolicyManager.java
+++ b/tests/robotests/src/com/android/car/settings/testutils/ShadowDevicePolicyManager.java
@@ -18,18 +18,28 @@
import android.annotation.Nullable;
import android.app.admin.DevicePolicyManager;
+import android.util.ArraySet;
import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;
import org.robolectric.annotation.Resetter;
import java.util.List;
+import java.util.Set;
@Implements(value = DevicePolicyManager.class)
public class ShadowDevicePolicyManager extends org.robolectric.shadows.ShadowDevicePolicyManager {
@Nullable
private static List<String> sPermittedInputMethods;
+ private Set<String> mActiveAdminsPackages = new ArraySet<>();
+ private boolean mIsInstallInQueue;
+
+ @Resetter
+ public static void reset() {
+ sPermittedInputMethods = null;
+ }
+
@Implementation
@Nullable
protected List<String> getPermittedInputMethodsForCurrentUser() {
@@ -40,8 +50,25 @@
sPermittedInputMethods = inputMethods;
}
- @Resetter
- public static void reset() {
- sPermittedInputMethods = null;
+ @Implementation
+ protected boolean packageHasActiveAdmins(String packageName) {
+ return mActiveAdminsPackages.contains(packageName);
+ }
+
+ public void setPackageHasActiveAdmins(String packageName, boolean hasActiveAdmins) {
+ if (hasActiveAdmins) {
+ mActiveAdminsPackages.add(packageName);
+ } else {
+ mActiveAdminsPackages.remove(packageName);
+ }
+ }
+
+ @Implementation
+ protected boolean isUninstallInQueue(String packageName) {
+ return mIsInstallInQueue;
+ }
+
+ public void setIsUninstallInQueue(boolean isUninstallInQueue) {
+ mIsInstallInQueue = isUninstallInQueue;
}
}