Provide SuspendDialogInfo when quarantining an app.
Customize the dialog to include a button to allow users to take an app out of the quarantine state. Bug: 297934650 Test: atest tests/robotests/src/com/android/settings/development/quarantine/QuarantinedAppsScreenControllerTest.java Change-Id: I1b6e9f057fed91ae131602fd6d6ddf5e23958a65
This commit is contained in:
@@ -12458,4 +12458,6 @@
|
||||
|
||||
<!-- Developer settings: Title for the screen allowing user to control Quarantined apps [CHAR LIMIT=50] -->
|
||||
<string name="quarantined_apps_title">Quarantined Apps</string>
|
||||
<!-- Developer settings: Button to unquarantine an app [CHAR LIMIT=20] -->
|
||||
<string name="unquarantine_app_button">Unquarantine app</string>
|
||||
</resources>
|
||||
|
@@ -19,6 +19,7 @@ package com.android.settings.development.quarantine;
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.SuspendDialogInfo;
|
||||
import android.os.UserHandle;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
@@ -181,8 +182,17 @@ public class QuarantinedAppsScreenController extends BasePreferenceController im
|
||||
private void setPackageQuarantined(String pkg, int uid, boolean quarantined) {
|
||||
final PackageManager pm = mContext.createContextAsUser(
|
||||
UserHandle.getUserHandleForUid(uid), 0).getPackageManager();
|
||||
final SuspendDialogInfo dialogInfo;
|
||||
if (quarantined) {
|
||||
dialogInfo = new SuspendDialogInfo.Builder()
|
||||
.setNeutralButtonText(R.string.unquarantine_app_button)
|
||||
.setNeutralButtonAction(SuspendDialogInfo.BUTTON_ACTION_UNSUSPEND)
|
||||
.build();
|
||||
} else {
|
||||
dialogInfo = null;
|
||||
}
|
||||
pm.setPackagesSuspended(new String[] {pkg}, quarantined, null /* appExtras */,
|
||||
null /* launcherExtras */, null /* dialogInfo */,
|
||||
null /* launcherExtras */, dialogInfo,
|
||||
PackageManager.FLAG_SUSPEND_QUARANTINED);
|
||||
}
|
||||
|
||||
|
@@ -20,6 +20,7 @@ import static org.mockito.AdditionalMatchers.aryEq;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.ArgumentMatchers.isNull;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.spy;
|
||||
@@ -28,6 +29,7 @@ import static org.mockito.Mockito.verify;
|
||||
import android.content.Context;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.SuspendDialogInfo;
|
||||
import android.os.UserHandle;
|
||||
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
@@ -70,12 +72,12 @@ public class QuarantinedAppsScreenControllerTest {
|
||||
|
||||
mController.onPreferenceChange(preference, true);
|
||||
verify(packageManager).setPackagesSuspended(aryEq(new String[] {TEST_PACKAGE}), eq(true),
|
||||
any(), any(), any(),
|
||||
isNull(), isNull(), any(SuspendDialogInfo.class),
|
||||
eq(PackageManager.FLAG_SUSPEND_QUARANTINED));
|
||||
|
||||
mController.onPreferenceChange(preference, false);
|
||||
verify(packageManager).setPackagesSuspended(aryEq(new String[] {TEST_PACKAGE}), eq(false),
|
||||
any(), any(), any(),
|
||||
isNull(), isNull(), isNull(),
|
||||
eq(PackageManager.FLAG_SUSPEND_QUARANTINED));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user