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

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

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

Merge cherrypicks of ['googleplex-android-review.googlesource.com/27145545', 'googleplex-android-review.googlesource.com/27266232', 'googleplex-android-review.googlesource.com/27316786', 'googleplex-android-review.googlesource.com/27431144', 'googleplex-android-review.googlesource.com/27146225', 'googleplex-android-review.googlesource.com/27263999', 'googleplex-android-review.googlesource.com/27214657'] into security-aosp-udc-release.

Change-Id: I3313472c5c6f59d9a26397915d3cfb9d95db1aed
parents 08511dab 21d76480
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -88,7 +88,7 @@ class AppOpInfo {

    /**
     * This specifies whether each option is only allowed to be read
     * by apps with manage appops permission.
     * by apps with privileged appops permission.
     */
    public final boolean restrictRead;

+1 −1
Original line number Diff line number Diff line
@@ -2985,7 +2985,7 @@ public class AppOpsManager {
    }

    /**
     * Retrieve whether the op can be read by apps with manage appops permission.
     * Retrieve whether the op can be read by apps with privileged appops permission.
     * @hide
     */
    public static boolean opRestrictsRead(int op) {
+50 −0
Original line number Diff line number Diff line
@@ -24,6 +24,8 @@ import static android.util.XmlTest.doVerifyRead;
import static android.util.XmlTest.doVerifyWrite;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.fail;
import static org.xmlpull.v1.XmlPullParser.START_TAG;

import android.os.PersistableBundle;
@@ -41,12 +43,15 @@ import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;

@RunWith(AndroidJUnit4.class)
public class BinaryXmlTest {
    private static final int MAX_UNSIGNED_SHORT = 65_535;

    /**
     * Verify that we can write and read large numbers of interned
     * {@link String} values.
@@ -170,4 +175,49 @@ public class BinaryXmlTest {
            }
        }
    }

    @Test
    public void testAttributeBytes_BinaryDataOverflow() throws Exception {
        final TypedXmlSerializer out = Xml.newBinarySerializer();
        final ByteArrayOutputStream os = new ByteArrayOutputStream();
        out.setOutput(os, StandardCharsets.UTF_8.name());

        final byte[] testBytes = new byte[MAX_UNSIGNED_SHORT + 1];
        assertThrows(IOException.class,
                () -> out.attributeBytesHex(/* namespace */ null, /* name */ "attributeBytesHex",
                        testBytes));

        assertThrows(IOException.class,
                () -> out.attributeBytesBase64(/* namespace */ null, /* name */
                        "attributeBytesBase64", testBytes));
    }

    @Test
    public void testAttributeBytesHex_MaximumBinaryData() throws Exception {
        final TypedXmlSerializer out = Xml.newBinarySerializer();
        final ByteArrayOutputStream os = new ByteArrayOutputStream();
        out.setOutput(os, StandardCharsets.UTF_8.name());

        final byte[] testBytes = new byte[MAX_UNSIGNED_SHORT];
        try {
            out.attributeBytesHex(/* namespace */ null, /* name */ "attributeBytesHex", testBytes);
        } catch (Exception e) {
            fail("testAttributeBytesHex fails with exception: " + e.toString());
        }
    }

    @Test
    public void testAttributeBytesBase64_MaximumBinaryData() throws Exception {
        final TypedXmlSerializer out = Xml.newBinarySerializer();
        final ByteArrayOutputStream os = new ByteArrayOutputStream();
        out.setOutput(os, StandardCharsets.UTF_8.name());

        final byte[] testBytes = new byte[MAX_UNSIGNED_SHORT];
        try {
            out.attributeBytesBase64(/* namespace */ null, /* name */ "attributeBytesBase64",
                    testBytes);
        } catch (Exception e) {
            fail("testAttributeBytesBase64 fails with exception: " + e.toString());
        }
    }
}
+12 −1
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import com.android.systemui.common.shared.model.Icon
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.globalactions.GlobalActionsDialogLite
import com.android.systemui.plugins.ActivityStarter
import com.android.systemui.plugins.FalsingManager
import com.android.systemui.qs.dagger.QSFlagsModule.PM_LITE_ENABLED
import com.android.systemui.qs.footer.data.model.UserSwitcherStatusModel
@@ -54,6 +55,7 @@ class FooterActionsViewModel(
    private val footerActionsInteractor: FooterActionsInteractor,
    private val falsingManager: FalsingManager,
    private val globalActionsDialogLite: GlobalActionsDialogLite,
    private val activityStarter: ActivityStarter,
    showPowerButton: Boolean,
) {
    /** The context themed with the Quick Settings colors. */
@@ -222,7 +224,14 @@ class FooterActionsViewModel(
            return
        }

        activityStarter.dismissKeyguardThenExecute(
            {
                footerActionsInteractor.showForegroundServicesDialog(expandable)
                false /* if the dismiss should be deferred */
            },
            null /* cancelAction */,
            true /* afterKeyguardGone */
        )
    }

    private fun onUserSwitcherClicked(expandable: Expandable) {
@@ -283,6 +292,7 @@ class FooterActionsViewModel(
        private val falsingManager: FalsingManager,
        private val footerActionsInteractor: FooterActionsInteractor,
        private val globalActionsDialogLiteProvider: Provider<GlobalActionsDialogLite>,
        private val activityStarter: ActivityStarter,
        @Named(PM_LITE_ENABLED) private val showPowerButton: Boolean,
    ) {
        /** Create a [FooterActionsViewModel] bound to the lifecycle of [lifecycleOwner]. */
@@ -308,6 +318,7 @@ class FooterActionsViewModel(
                footerActionsInteractor,
                falsingManager,
                globalActionsDialogLite,
                activityStarter,
                showPowerButton,
            )
        }
+3 −1
Original line number Diff line number Diff line
@@ -68,6 +68,7 @@ class FooterActionsTestUtils(
    private val testableLooper: TestableLooper,
    private val scheduler: TestCoroutineScheduler,
) {
    private val mockActivityStarter: ActivityStarter = mock<ActivityStarter>()
    /** Enable or disable the user switcher in the settings. */
    fun setUserSwitcherEnabled(settings: GlobalSettings, enabled: Boolean, userId: Int) {
        settings.putBoolForUser(Settings.Global.USER_SWITCHER_ENABLED, enabled, userId)
@@ -90,13 +91,14 @@ class FooterActionsTestUtils(
            footerActionsInteractor,
            falsingManager,
            globalActionsDialogLite,
            mockActivityStarter,
            showPowerButton,
        )
    }

    /** Create a [FooterActionsInteractor] to be used in tests. */
    fun footerActionsInteractor(
        activityStarter: ActivityStarter = mock(),
        activityStarter: ActivityStarter = mockActivityStarter,
        metricsLogger: MetricsLogger = FakeMetricsLogger(),
        uiEventLogger: UiEventLogger = UiEventLoggerFake(),
        deviceProvisionedController: DeviceProvisionedController = mock(),
Loading