[SPA] Add biometric authentication for package modification
Add an extra step of Lock Screen for disabling, force-stopping or uninstalling updates for protected packages UI Change Details : https://drive.google.com/drive/folders/1w7gKTmCxQ_j-9GQnIpEfF5_gmQ27b8l_?resourcekey=0-brLdN8VfqVPGm2FMwfrmkQ&usp=drive_link Bug: 352504490, 344865740 Test: atest AppButtonsPreferenceControllerTest PackageInfoPresenterTest Flag: EXEMPT High Security Bug Change-Id: I0c494e307b02229d751de118abcc89e4e61a6861
This commit is contained in:
@@ -53,6 +53,7 @@ import com.android.settings.R;
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.applications.ApplicationFeatureProvider;
|
||||
import com.android.settings.applications.appinfo.AppInfoDashboardFragment;
|
||||
import com.android.settings.applications.specialaccess.deviceadmin.DeviceAdminAdd;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.core.InstrumentedPreferenceFragment;
|
||||
@@ -240,13 +241,21 @@ public class AppButtonsPreferenceController extends BasePreferenceController imp
|
||||
} else if ((mAppEntry.info.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
|
||||
if (mAppEntry.info.enabled && !isDisabledUntilUsed()) {
|
||||
showDialogInner(ButtonActionDialogFragment.DialogType.DISABLE);
|
||||
} else if (mAppEntry.info.enabled) {
|
||||
requireAuthAndExecute(() -> {
|
||||
mMetricsFeatureProvider.action(
|
||||
mActivity,
|
||||
SettingsEnums.ACTION_SETTINGS_DISABLE_APP,
|
||||
getPackageNameForMetric());
|
||||
AsyncTask.execute(new DisableChangerRunnable(mPm,
|
||||
mAppEntry.info.packageName,
|
||||
PackageManager.COMPONENT_ENABLED_STATE_DEFAULT));
|
||||
});
|
||||
} else {
|
||||
mMetricsFeatureProvider.action(
|
||||
mActivity,
|
||||
mAppEntry.info.enabled
|
||||
? SettingsEnums.ACTION_SETTINGS_DISABLE_APP
|
||||
: SettingsEnums.ACTION_SETTINGS_ENABLE_APP,
|
||||
getPackageNameForMetric());
|
||||
SettingsEnums.ACTION_SETTINGS_ENABLE_APP,
|
||||
getPackageNameForMetric());
|
||||
AsyncTask.execute(new DisableChangerRunnable(mPm, mAppEntry.info.packageName,
|
||||
PackageManager.COMPONENT_ENABLED_STATE_DEFAULT));
|
||||
}
|
||||
@@ -289,17 +298,34 @@ public class AppButtonsPreferenceController extends BasePreferenceController imp
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs the given action with restricted lock authentication if it is a protected package.
|
||||
*
|
||||
* @param action The action to run.
|
||||
*/
|
||||
private void requireAuthAndExecute(Runnable action) {
|
||||
if (Utils.isProtectedPackage(mContext, mAppEntry.info.packageName)) {
|
||||
AppInfoDashboardFragment.showLockScreen(mContext, () -> action.run());
|
||||
} else {
|
||||
action.run();
|
||||
}
|
||||
}
|
||||
|
||||
public void handleDialogClick(int id) {
|
||||
switch (id) {
|
||||
case ButtonActionDialogFragment.DialogType.DISABLE:
|
||||
mMetricsFeatureProvider.action(mActivity,
|
||||
SettingsEnums.ACTION_SETTINGS_DISABLE_APP,
|
||||
getPackageNameForMetric());
|
||||
AsyncTask.execute(new DisableChangerRunnable(mPm, mAppEntry.info.packageName,
|
||||
PackageManager.COMPONENT_ENABLED_STATE_DISABLED_USER));
|
||||
requireAuthAndExecute(() -> {
|
||||
mMetricsFeatureProvider.action(mActivity,
|
||||
SettingsEnums.ACTION_SETTINGS_DISABLE_APP,
|
||||
getPackageNameForMetric());
|
||||
AsyncTask.execute(new DisableChangerRunnable(mPm, mAppEntry.info.packageName,
|
||||
PackageManager.COMPONENT_ENABLED_STATE_DISABLED_USER));
|
||||
});
|
||||
break;
|
||||
case ButtonActionDialogFragment.DialogType.FORCE_STOP:
|
||||
forceStopPackage(mAppEntry.info.packageName);
|
||||
requireAuthAndExecute(() -> {
|
||||
forceStopPackage(mAppEntry.info.packageName);
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -535,14 +561,16 @@ public class AppButtonsPreferenceController extends BasePreferenceController imp
|
||||
|
||||
@VisibleForTesting
|
||||
void uninstallPkg(String packageName, boolean allUsers) {
|
||||
stopListeningToPackageRemove();
|
||||
// Create new intent to launch Uninstaller activity
|
||||
Uri packageUri = Uri.parse("package:" + packageName);
|
||||
Intent uninstallIntent = new Intent(Intent.ACTION_UNINSTALL_PACKAGE, packageUri);
|
||||
uninstallIntent.putExtra(Intent.EXTRA_UNINSTALL_ALL_USERS, allUsers);
|
||||
requireAuthAndExecute(() -> {
|
||||
stopListeningToPackageRemove();
|
||||
// Create new intent to launch Uninstaller activity
|
||||
Uri packageUri = Uri.parse("package:" + packageName);
|
||||
Intent uninstallIntent = new Intent(Intent.ACTION_UNINSTALL_PACKAGE, packageUri);
|
||||
uninstallIntent.putExtra(Intent.EXTRA_UNINSTALL_ALL_USERS, allUsers);
|
||||
|
||||
mMetricsFeatureProvider.action(mActivity, SettingsEnums.ACTION_SETTINGS_UNINSTALL_APP);
|
||||
mFragment.startActivityForResult(uninstallIntent, mRequestUninstall);
|
||||
mMetricsFeatureProvider.action(mActivity, SettingsEnums.ACTION_SETTINGS_UNINSTALL_APP);
|
||||
mFragment.startActivityForResult(uninstallIntent, mRequestUninstall);
|
||||
});
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
|
Reference in New Issue
Block a user