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

Commit acb3a2c4 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Merge cherrypicks of ['googleplex-android-review.googlesource.com/35833850',...

Merge cherrypicks of ['googleplex-android-review.googlesource.com/35833850', 'googleplex-android-review.googlesource.com/36169947', 'googleplex-android-review.googlesource.com/36241944', 'googleplex-android-review.googlesource.com/36252743'] into 25Q4-release.

Change-Id: I18766ba632782c1ba39fba6950775058251dee40
parents 318be802 17dfdef8
Loading
Loading
Loading
Loading
+3 −12
Original line number Diff line number Diff line
@@ -178,16 +178,7 @@ public class InstallStart extends Activity {
            mAbortInstall = true;
        }

        // Bypass the unknown source user restrictions check when either of the following
        // two conditions is met:
        // 1. the installation is not triggered via ACTION_VIEW or ACTION_INSTALL_PACKAGE
        // 2. the value of the Intent.EXTRA_NOT_UNKNOWN_SOURCE is TRUE and the caller is
        //    a privileged app
        final boolean isIntentInstall =
                Intent.ACTION_VIEW.equals(intentAction)
                        || Intent.ACTION_INSTALL_PACKAGE.equals(intentAction);
        final boolean bypassUnknownSourceRestrictions = !isIntentInstall || isPrivilegedAndKnown;
        checkDevicePolicyRestrictions(bypassUnknownSourceRestrictions);
        checkDevicePolicyRestrictions(isTrustedSource);

        final String installerPackageNameFromIntent = getIntent().getStringExtra(
                Intent.EXTRA_INSTALLER_PACKAGE_NAME);
@@ -353,9 +344,9 @@ public class InstallStart extends Activity {
        return callingUid == installerUid;
    }

    private void checkDevicePolicyRestrictions(boolean bypassUnknownSourceRestrictions) {
    private void checkDevicePolicyRestrictions(boolean isTrustedSource) {
        String[] restrictions;
        if (bypassUnknownSourceRestrictions) {
        if(isTrustedSource) {
            restrictions = new String[] { UserManager.DISALLOW_INSTALL_APPS };
        } else {
            restrictions =  new String[] {
+17 −19
Original line number Diff line number Diff line
@@ -253,13 +253,7 @@ class InstallRepository(private val context: Context) : EventResultPersister.Eve
            return InstallAborted(ABORT_REASON_INTERNAL_ERROR)
        }

        val isPrivilegedAndKnown = sourceInfo != null && sourceInfo.isPrivilegedApp &&
                intent.getBooleanExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE, false)
        val isInstallPkgPermissionGranted = originatingUid != Process.INVALID_UID &&
                isPermissionGranted(context, Manifest.permission.INSTALL_PACKAGES, originatingUid)

        isTrustedSource = isPrivilegedAndKnown || isInstallPkgPermissionGranted

        isTrustedSource = isInstallRequestFromTrustedSource(sourceInfo, this.intent, originatingUid)
        // In general case, the originatingUid is callingUid. If callingUid is INVALID_UID, return
        // InstallAborted in the check above. When the originatingUid is INVALID_UID here, it means
        // the originatingUid is from the system download manager or the system documents manager,
@@ -270,16 +264,7 @@ class InstallRepository(private val context: Context) : EventResultPersister.Eve
            return InstallAborted(ABORT_REASON_INTERNAL_ERROR)
        }

        // Bypass the unknown source user restrictions check when either of the following
        // two conditions is met:
        // 1. the installation is not triggered via ACTION_VIEW or ACTION_INSTALL_PACKAGE
        // 2. the value of the Intent.EXTRA_NOT_UNKNOWN_SOURCE is TRUE and the caller is
        //    a privileged app
        val isIntentInstall =
            Intent.ACTION_VIEW == intent.action
                    || Intent.ACTION_INSTALL_PACKAGE == intent.action
        val bypassUnknownSourceRestrictions = !isIntentInstall || isPrivilegedAndKnown
        val restriction = getDevicePolicyRestrictions(bypassUnknownSourceRestrictions)
        val restriction = getDevicePolicyRestrictions(isTrustedSource)
        if (restriction != null) {
            val adminSupportDetailsIntent =
                devicePolicyManager!!.createAdminSupportIntent(restriction)
@@ -305,8 +290,21 @@ class InstallRepository(private val context: Context) : EventResultPersister.Eve
        }
    }

    private fun getDevicePolicyRestrictions(bypassUnknownSourceRestrictions: Boolean): String? {
        val restrictions: Array<String> = if (bypassUnknownSourceRestrictions) {
    private fun isInstallRequestFromTrustedSource(
        sourceInfo: ApplicationInfo?,
        intent: Intent,
        callingUid: Int,
    ): Boolean {
        val isPrivilegedAndKnown = sourceInfo != null && sourceInfo.isPrivilegedApp &&
            intent.getBooleanExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE, false)
        val isInstallPkgPermissionGranted = callingUid != Process.INVALID_UID
                && isPermissionGranted(context, Manifest.permission.INSTALL_PACKAGES, callingUid)

        return isPrivilegedAndKnown || isInstallPkgPermissionGranted
    }

    private fun getDevicePolicyRestrictions(isTrustedSource: Boolean): String? {
        val restrictions: Array<String> = if (isTrustedSource) {
            arrayOf(UserManager.DISALLOW_INSTALL_APPS)
        } else {
            arrayOf(
+5 −0
Original line number Diff line number Diff line
@@ -183,6 +183,11 @@ open class SettingsPreferenceGroupAdapter(preferenceGroup: PreferenceGroup) :
        val v = holder.itemView
        val drawableStateLayout = holder.itemView as? DrawableStateLayout
        if (drawableStateLayout != null && mItemPositionStates[position] != 0) {
            if (v.background == null) {
                // Make sure the stateful drawable is set for expressive UI
                v.setBackgroundResource(R.drawable.settingslib_round_background_stateful)
            }

            val background = v.background
            if (background != null) {
                val backgroundPadding = Rect()
+31 −2
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@ import com.android.systemui.res.R
import com.android.systemui.res.R.string.kg_too_many_failed_attempts_countdown
import com.android.systemui.res.R.string.kg_trust_agent_disabled
import com.android.systemui.securelockdevice.data.repository.fakeSecureLockDeviceRepository
import com.android.systemui.securelockdevice.domain.interactor.secureLockDeviceInteractor
import com.android.systemui.testKosmos
import com.android.systemui.user.data.repository.fakeUserRepository
import com.android.systemui.util.mockito.KotlinArgumentCaptor
@@ -103,7 +104,7 @@ class BouncerMessageInteractorTest : SysuiTestCase() {
    suspend fun TestScope.init(
        faceAuthCurrentlyAllowed: Boolean = false,
        faceAuthEnrolledAndEnabled: Boolean = false,
        hasStrongFace: Boolean = true,
        hasStrongFace: Boolean = false,
        fingerprintAuthCurrentlyAllowed: Boolean = true,
        fingerprintAuthEnrolledAndEnabled: Boolean = true,
        secureLockDeviceEnabled: Boolean? = null,
@@ -172,6 +173,20 @@ class BouncerMessageInteractorTest : SysuiTestCase() {
        }
        kosmos.fakeKeyguardBouncerRepository.setPrimaryShow(true)
        runCurrent()

        if (secureLockDeviceEnabled == true) {
            val hasFingerprint by collectLastValue(kosmos.secureLockDeviceInteractor.hasFingerprint)
            val hasFace by collectLastValue(kosmos.secureLockDeviceInteractor.hasFace)

            runCurrent()
            if (fingerprintAuthEnrolledAndEnabled) {
                assertThat(hasFingerprint).isTrue()
            }

            if (hasStrongFace) {
                assertThat(hasFace).isTrue()
            }
        }
    }

    @Test
@@ -236,6 +251,7 @@ class BouncerMessageInteractorTest : SysuiTestCase() {
            init(
                faceAuthCurrentlyAllowed = true,
                faceAuthEnrolledAndEnabled = true,
                hasStrongFace = true,
                fingerprintAuthCurrentlyAllowed = false,
                fingerprintAuthEnrolledAndEnabled = false,
                secureLockDeviceEnabled = true,
@@ -258,6 +274,7 @@ class BouncerMessageInteractorTest : SysuiTestCase() {
            init(
                faceAuthCurrentlyAllowed = true,
                faceAuthEnrolledAndEnabled = true,
                hasStrongFace = true,
                fingerprintAuthCurrentlyAllowed = true,
                fingerprintAuthEnrolledAndEnabled = true,
                secureLockDeviceEnabled = true,
@@ -322,6 +339,7 @@ class BouncerMessageInteractorTest : SysuiTestCase() {
            init(
                faceAuthCurrentlyAllowed = true,
                faceAuthEnrolledAndEnabled = true,
                hasStrongFace = true,
                secureLockDeviceEnabled = true,
                secureLockDeviceBiometricAuthActive = true,
            )
@@ -586,6 +604,7 @@ class BouncerMessageInteractorTest : SysuiTestCase() {
            init(
                faceAuthEnrolledAndEnabled = true,
                faceAuthCurrentlyAllowed = false,
                hasStrongFace = true,
                secureLockDeviceEnabled = true,
                secureLockDeviceBiometricAuthActive = false,
            )
@@ -605,7 +624,13 @@ class BouncerMessageInteractorTest : SysuiTestCase() {
    @Test
    fun onFaceLockout_whenItIsClass3_propagatesState() =
        testScope.runTest {
            init(faceAuthEnrolledAndEnabled = true)
            init(
                faceAuthCurrentlyAllowed = true,
                faceAuthEnrolledAndEnabled = true,
                hasStrongFace = true,
                fingerprintAuthCurrentlyAllowed = true,
                fingerprintAuthEnrolledAndEnabled = true,
            )
            val lockoutMessage by collectLastValue(underTest.bouncerMessage)
            kosmos.fakeDeviceEntryFaceAuthRepository.setLockedOut(true)
            runCurrent()
@@ -719,6 +744,7 @@ class BouncerMessageInteractorTest : SysuiTestCase() {
                fingerprintAuthEnrolledAndEnabled = false,
                faceAuthCurrentlyAllowed = true,
                faceAuthEnrolledAndEnabled = true,
                hasStrongFace = true,
                secureLockDeviceEnabled = true,
                secureLockDeviceBiometricAuthActive = true,
            )
@@ -756,6 +782,7 @@ class BouncerMessageInteractorTest : SysuiTestCase() {
                fingerprintAuthEnrolledAndEnabled = false,
                faceAuthCurrentlyAllowed = true,
                faceAuthEnrolledAndEnabled = true,
                hasStrongFace = true,
                secureLockDeviceEnabled = true,
                secureLockDeviceBiometricAuthActive = true,
            )
@@ -782,6 +809,7 @@ class BouncerMessageInteractorTest : SysuiTestCase() {
                fingerprintAuthEnrolledAndEnabled = false,
                faceAuthCurrentlyAllowed = true,
                faceAuthEnrolledAndEnabled = true,
                hasStrongFace = true,
                secureLockDeviceEnabled = true,
                secureLockDeviceBiometricAuthActive = true,
            )
@@ -810,6 +838,7 @@ class BouncerMessageInteractorTest : SysuiTestCase() {
                fingerprintAuthEnrolledAndEnabled = true,
                faceAuthCurrentlyAllowed = true,
                faceAuthEnrolledAndEnabled = true,
                hasStrongFace = true,
                secureLockDeviceEnabled = true,
                secureLockDeviceBiometricAuthActive = true,
            )
+1 −1
Original line number Diff line number Diff line
@@ -66,7 +66,7 @@ interface SecureLockDeviceModule {
            secureLockDeviceRepository: SecureLockDeviceRepository,
            biometricSettingsInteractor: DeviceEntryBiometricSettingsInteractor,
            deviceEntryFaceAuthInteractor: SystemUIDeviceEntryFaceAuthInteractor,
            fingerprintPropertyInteractor: FingerprintPropertyInteractor,
            fingerprintPropertyInteractor: Lazy<FingerprintPropertyInteractor>,
            facePropertyInteractor: FacePropertyInteractor,
            lockPatternUtils: LockPatternUtils,
            authenticationPolicyManager: AuthenticationPolicyManager?,
Loading