Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1f255895 authored by Hani Kazmi's avatar Hani Kazmi
Browse files

Replace ECM AppOps call with service

A new ECM service was introcuded in changeId
I831391e4437b51b3312b5273a2360bd029a3d8ee.

We begin calling it, and update/cleanup method signatures to match.

Note: There are two feature flags:

1. enhancedConfirmationModeApisEnabled - read only, protects the
   mainline API.

2. extendEcmToAllSettings - runtime - gates calls to the above APIs.

We use both so we can ramp up in teamfood as needed.

Bug: 297372999
Test: Tested on device
Test: atest SpaPrivilegedLibTests
Test: atest com.android.settings.applications.specialaccess.notificationaccess
Test: atest com.android.settings.datausage
Test: atest PremiumSmsAccessTest
Test: atest RestrictedPreferenceHelperTest
Change-Id: I4125e71078a1a06e954bfc317c344e1016406ffb
parent 65f8b5ac
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -219,7 +219,6 @@ public class RestrictedLockUtils {
        }
    }


    /**
     * Shows restricted setting dialog.
     *
+1 −2
Original line number Diff line number Diff line
@@ -31,7 +31,6 @@ import kotlinx.coroutines.flow.flowOn

data class EnhancedConfirmation(
    val key: String,
    val uid: Int,
    val packageName: String,
)
data class Restrictions(
@@ -91,7 +90,7 @@ internal class RestrictionsProviderImpl(
        restrictions.enhancedConfirmation?.let { ec ->
            RestrictedLockUtilsInternal
                    .checkIfRequiresEnhancedConfirmation(context, ec.key,
                        ec.uid, ec.packageName)
                        ec.packageName)
                    ?.let { intent -> return BlockedByEcmImpl(context = context, intent = intent) }
        }

+0 −1
Original line number Diff line number Diff line
@@ -159,7 +159,6 @@ internal fun <T : AppRecord> TogglePermissionAppListModel<T>.TogglePermissionApp
            keys = switchRestrictionKeys,
            enhancedConfirmation = enhancedConfirmationKey?.let { EnhancedConfirmation(
                key = it,
                uid = checkNotNull(applicationInfo).uid,
                packageName = packageName) })
        RestrictedSwitchPreference(switchModel, restrictions, restrictionsProviderFactory)
        InfoPageAdditionalContent(record, isAllowed)
+1 −3
Original line number Diff line number Diff line
@@ -150,15 +150,13 @@ internal class TogglePermissionInternalAppListModel<T : AppRecord>(

    @Composable
    fun getSummary(record: T): () -> String {
        val restrictions = remember(record.app.userId,
                record.app.uid, record.app.packageName) {
        val restrictions = remember(record.app.userId, record.app.packageName) {
            Restrictions(
                userId = record.app.userId,
                keys = listModel.switchRestrictionKeys,
                enhancedConfirmation = listModel.enhancedConfirmationKey?.let {
                    EnhancedConfirmation(
                        key = it,
                        uid = record.app.uid,
                        packageName = record.app.packageName)
                })
        }
+5 −7
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@ package com.android.settingslib;
import android.content.Context;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.preference.DropDownPreference;
import androidx.preference.PreferenceViewHolder;

@@ -34,13 +33,12 @@ public class RestrictedDropDownPreference extends DropDownPreference {
    /**
     * Checks if the given setting is subject to Enhanced Confirmation Mode restrictions for this
     * package. Marks the preference as disabled if so.
     * @param restriction The key identifying the setting
     * @param packageName the package to check the restriction for
     * @param uid the uid of the package
     * @param settingIdentifier The key identifying the setting
     * @param packageName the package to check the settingIdentifier for
     */
    public void checkEcmRestrictionAndSetDisabled(@NonNull String restriction,
            @Nullable String packageName, int uid) {
        mHelper.checkEcmRestrictionAndSetDisabled(restriction, packageName, uid);
    public void checkEcmRestrictionAndSetDisabled(@NonNull String settingIdentifier,
            @NonNull String packageName) {
        mHelper.checkEcmRestrictionAndSetDisabled(settingIdentifier, packageName);
    }

    @Override
Loading