[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:
@@ -29,6 +29,8 @@ import android.os.UserHandle
|
||||
import android.util.Log
|
||||
import androidx.annotation.VisibleForTesting
|
||||
import androidx.compose.runtime.Composable
|
||||
import com.android.settings.Utils
|
||||
import com.android.settings.applications.appinfo.AppInfoDashboardFragment
|
||||
import com.android.settings.flags.FeatureFlags
|
||||
import com.android.settings.flags.FeatureFlagsImpl
|
||||
import com.android.settings.overlay.FeatureFactory.Companion.featureFactory
|
||||
@@ -116,6 +118,16 @@ class PackageInfoPresenter(
|
||||
|
||||
private fun isForThisApp(intent: Intent) = packageName == intent.data?.schemeSpecificPart
|
||||
|
||||
private fun requireAuthAndExecute(action: () -> Unit) {
|
||||
if (Utils.isProtectedPackage(context, packageName)) {
|
||||
AppInfoDashboardFragment.showLockScreen(context) {
|
||||
action()
|
||||
}
|
||||
} else {
|
||||
action()
|
||||
}
|
||||
}
|
||||
|
||||
/** Enables this package. */
|
||||
fun enable() {
|
||||
logAction(SettingsEnums.ACTION_SETTINGS_ENABLE_APP)
|
||||
@@ -129,17 +141,21 @@ class PackageInfoPresenter(
|
||||
/** Disables this package. */
|
||||
fun disable() {
|
||||
logAction(SettingsEnums.ACTION_SETTINGS_DISABLE_APP)
|
||||
coroutineScope.launch(Dispatchers.IO) {
|
||||
userPackageManager.setApplicationEnabledSetting(
|
||||
packageName, PackageManager.COMPONENT_ENABLED_STATE_DISABLED_USER, 0
|
||||
)
|
||||
requireAuthAndExecute {
|
||||
coroutineScope.launch(Dispatchers.IO) {
|
||||
userPackageManager.setApplicationEnabledSetting(
|
||||
packageName, PackageManager.COMPONENT_ENABLED_STATE_DISABLED_USER, 0
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Starts the uninstallation activity. */
|
||||
fun startUninstallActivity(forAllUsers: Boolean = false) {
|
||||
logAction(SettingsEnums.ACTION_SETTINGS_UNINSTALL_APP)
|
||||
context.startUninstallActivity(packageName, userHandle, forAllUsers)
|
||||
requireAuthAndExecute {
|
||||
context.startUninstallActivity(packageName, userHandle, forAllUsers)
|
||||
}
|
||||
}
|
||||
|
||||
/** Clears this instant app. */
|
||||
@@ -153,17 +169,19 @@ class PackageInfoPresenter(
|
||||
/** Force stops this package. */
|
||||
fun forceStop() {
|
||||
logAction(SettingsEnums.ACTION_APP_FORCE_STOP)
|
||||
coroutineScope.launch(Dispatchers.Default) {
|
||||
Log.d(TAG, "Stopping package $packageName")
|
||||
if (android.app.Flags.appRestrictionsApi()) {
|
||||
val uid = userPackageManager.getPackageUid(packageName, 0)
|
||||
context.activityManager.noteAppRestrictionEnabled(
|
||||
packageName, uid,
|
||||
ActivityManager.RESTRICTION_LEVEL_FORCE_STOPPED, true,
|
||||
ActivityManager.RESTRICTION_REASON_USER, "settings",
|
||||
ActivityManager.RESTRICTION_SOURCE_USER, 0)
|
||||
requireAuthAndExecute {
|
||||
coroutineScope.launch(Dispatchers.Default) {
|
||||
Log.d(TAG, "Stopping package $packageName")
|
||||
if (android.app.Flags.appRestrictionsApi()) {
|
||||
val uid = userPackageManager.getPackageUid(packageName, 0)
|
||||
context.activityManager.noteAppRestrictionEnabled(
|
||||
packageName, uid,
|
||||
ActivityManager.RESTRICTION_LEVEL_FORCE_STOPPED, true,
|
||||
ActivityManager.RESTRICTION_REASON_USER, "settings",
|
||||
ActivityManager.RESTRICTION_SOURCE_USER, 0)
|
||||
}
|
||||
context.activityManager.forceStopPackageAsUser(packageName, userId)
|
||||
}
|
||||
context.activityManager.forceStopPackageAsUser(packageName, userId)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user