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

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

Snap for 11973804 from 1f1f4127 to 24Q3-release

Change-Id: I5b445d0da37a6b0cf659433844a0eb70c04cf6d7
parents f5565fca 1f1f4127
Loading
Loading
Loading
Loading
+69 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.perftests.permission

import android.app.AppOpsManager
import android.content.Context
import android.perftests.utils.PerfStatusReporter
import androidx.test.core.app.ApplicationProvider
import androidx.test.ext.junit.runners.AndroidJUnit4
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
class AppOpsPerfTest {
    @get:Rule val perfStatusReporter = PerfStatusReporter()
    private lateinit var appOpsManager: AppOpsManager
    private lateinit var opPackageName: String
    private var opPackageUid: Int = 0

    @Before
    fun setUp() {
        val context: Context = ApplicationProvider.getApplicationContext()
        appOpsManager = context.getSystemService(AppOpsManager::class.java)!!
        opPackageName = context.opPackageName
        opPackageUid = context.getPackageManager().getPackageUid(opPackageName, 0)
    }

    @Test
    fun testNoteOp() {
        val state = perfStatusReporter.benchmarkState
        while (state.keepRunning()) {
            appOpsManager.noteOp(
                AppOpsManager.OPSTR_FINE_LOCATION,
                opPackageUid,
                opPackageName,
                null,
                null
            )
        }
    }

    @Test
    fun testUnsafeCheckOp() {
        val state = perfStatusReporter.benchmarkState
        while (state.keepRunning()) {
            appOpsManager.unsafeCheckOp(
                AppOpsManager.OPSTR_FINE_LOCATION,
                opPackageUid,
                opPackageName
            )
        }
    }
}
+1 −0
Original line number Diff line number Diff line
@@ -282,6 +282,7 @@ package android.app {
    field public static final String OPSTR_ACTIVITY_RECOGNITION = "android:activity_recognition";
    field public static final String OPSTR_ACTIVITY_RECOGNITION_SOURCE = "android:activity_recognition_source";
    field public static final String OPSTR_MANAGE_ONGOING_CALLS = "android:manage_ongoing_calls";
    field @FlaggedApi("android.service.notification.redact_sensitive_notifications_from_untrusted_listeners") public static final String OPSTR_RECEIVE_SENSITIVE_NOTIFICATIONS = "android:receive_sensitive_notifications";
    field public static final String OPSTR_RECORD_AUDIO_HOTWORD = "android:record_audio_hotword";
    field public static final String OPSTR_RESERVED_FOR_TESTING = "android:reserved_for_testing";
    field public static final String OPSTR_USE_ICC_AUTH_WITH_DEVICE_IDENTIFIER = "android:use_icc_auth_with_device_identifier";
+15 −5
Original line number Diff line number Diff line
@@ -1150,6 +1150,11 @@ public class Activity extends ContextThemeWrapper
     *
     * <p>To keep the Intent instance for future use, call {@link #setIntent(Intent)}, and use
     * this method to retrieve it.
     *
     * <p>Note that in {@link #onNewIntent}, this method will return the original Intent. You can
     * use {@link #setIntent(Intent)} to update it to the new Intent.
     *
     * @return {@link Intent} instance that started this activity, or that was kept for future use
     */
    public Intent getIntent() {
        return mIntent;
@@ -1170,9 +1175,14 @@ public class Activity extends ContextThemeWrapper
    }

    /**
     * Returns the ComponentCaller instance of the app that launched this activity with the intent
     * from {@link #getIntent()}. To keep the value of the ComponentCaller instance for new intents,
     * call {@link #setIntent(Intent, ComponentCaller)} instead of {@link #setIntent(Intent)}.
     * Returns the ComponentCaller instance of the app that started this activity.
     *
     * <p>To keep the ComponentCaller instance for future use, call
     * {@link #setIntent(Intent, ComponentCaller)}, and use this method to retrieve it.
     *
     * <p>Note that in {@link #onNewIntent}, this method will return the original ComponentCaller.
     * You can use {@link #setIntent(Intent, ComponentCaller)} to update it to the new
     * ComponentCaller.
     *
     * @return {@link ComponentCaller} instance corresponding to the intent from
     *         {@link #getIntent()}, or {@code null} if the activity was not launched with that
@@ -7156,8 +7166,8 @@ public class Activity extends ContextThemeWrapper
    /**
     * Returns the ComponentCaller instance of the app that initially launched this activity.
     *
     * <p>Note that calls to {@link #onNewIntent} have no effect on the returned value of this
     * method.
     * <p>Note that calls to {@link #onNewIntent} and {@link #setIntent} have no effect on the
     * returned value of this method.
     *
     * @return {@link ComponentCaller} instance
     * @see ComponentCaller
+28 −1
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ package android.app;
import static android.location.flags.Flags.FLAG_LOCATION_BYPASS;
import static android.media.audio.Flags.roForegroundAudioControl;
import static android.permission.flags.Flags.FLAG_OP_ENABLE_MOBILE_DATA_BY_USER;
import static android.service.notification.Flags.FLAG_REDACT_SENSITIVE_NOTIFICATIONS_FROM_UNTRUSTED_LISTENERS;
import static android.view.contentprotection.flags.Flags.FLAG_CREATE_ACCESSIBILITY_OVERLAY_APP_OP_ENABLED;
import static android.view.contentprotection.flags.Flags.FLAG_RAPID_CLEAR_NOTIFICATIONS_BY_LISTENER_APP_OP_ENABLED;

@@ -1597,9 +1598,19 @@ public class AppOpsManager {
     */
    public static final int OP_EMERGENCY_LOCATION = AppProtoEnums.APP_OP_EMERGENCY_LOCATION;

    /**
     * Allows apps with a NotificationListenerService to receive notifications with sensitive
     * information
     * <p>Apps with a NotificationListenerService without this permission will not be able
     * to view certain types of sensitive information contained in notifications
     * @hide
     */
    public static final int OP_RECEIVE_SENSITIVE_NOTIFICATIONS =
            AppProtoEnums.APP_OP_RECEIVE_SENSITIVE_NOTIFICATIONS;

    /** @hide */
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
    public static final int _NUM_OP = 148;
    public static final int _NUM_OP = 149;

    /**
     * All app ops represented as strings.
@@ -1751,6 +1762,7 @@ public class AppOpsManager {
            OPSTR_ARCHIVE_ICON_OVERLAY,
            OPSTR_UNARCHIVAL_CONFIRMATION,
            OPSTR_EMERGENCY_LOCATION,
            OPSTR_RECEIVE_SENSITIVE_NOTIFICATIONS,
    })
    public @interface AppOpString {}

@@ -2476,6 +2488,18 @@ public class AppOpsManager {
    @FlaggedApi(FLAG_LOCATION_BYPASS)
    public static final String OPSTR_EMERGENCY_LOCATION = "android:emergency_location";

    /**
     * Allows apps with a NotificationListenerService to receive notifications with sensitive
     * information
     * <p>Apps with a NotificationListenerService without this permission will not be able
     * to view certain types of sensitive information contained in notifications
     * @hide
     */
    @TestApi
    @FlaggedApi(FLAG_REDACT_SENSITIVE_NOTIFICATIONS_FROM_UNTRUSTED_LISTENERS)
    public static final String OPSTR_RECEIVE_SENSITIVE_NOTIFICATIONS =
            "android:receive_sensitive_notifications";

    /** {@link #sAppOpsToNote} not initialized yet for this op */
    private static final byte SHOULD_COLLECT_NOTE_OP_NOT_INITIALIZED = 0;
    /** Should not collect noting of this app-op in {@link #sAppOpsToNote} */
@@ -3055,6 +3079,9 @@ public class AppOpsManager {
                // even though this has a permission associated, this op is only used for tracking,
                // and the client is responsible for checking the LOCATION_BYPASS permission.
                .setPermission(Manifest.permission.LOCATION_BYPASS).build(),
        new AppOpInfo.Builder(OP_RECEIVE_SENSITIVE_NOTIFICATIONS,
                OPSTR_RECEIVE_SENSITIVE_NOTIFICATIONS, "RECEIVE_SENSITIVE_NOTIFICATIONS")
                .setDefaultMode(MODE_IGNORED).build(),
    };

    // The number of longs needed to form a full bitmask of app ops
+10 −4
Original line number Diff line number Diff line
@@ -6109,11 +6109,17 @@ public class Intent implements Parcelable, Cloneable {
     * {@link ContentProvider#query(Uri, String[], Bundle, CancellationSignal)}
     * method will contains the original intent Chooser has been launched with under the
     * {@link #EXTRA_INTENT} key as a context for the current sharing session. The returned
     * {@link android.database.Cursor} should contain
     * {@link android.service.chooser.AdditionalContentContract.Columns#URI} column for the item URI
     * and, optionally, {@link AdditionalContentContract.CursorExtraKeys#POSITION} extra that
     * {@link android.database.Cursor} should contain:
     * <ul>
     * <li>{@link android.service.chooser.AdditionalContentContract.Columns#URI} column for the item
     * URI.</li>
     * <li>Optional columns {@link MediaStore.MediaColumns#WIDTH} and
     * {@link MediaStore.MediaColumns#HEIGHT} for the dimensions of the preview image.
     * These columns can also be returned for each {@link #EXTRA_STREAM} item metadata
     * {@link ContentProvider#query(Uri, String[], Bundle, CancellationSignal)} call.</li>
     * <li>Optional {@link AdditionalContentContract.CursorExtraKeys#POSITION} extra that
     * specifies the cursor starting position; the item at this position is expected to match the
     * item specified by {@link #EXTRA_CHOOSER_FOCUSED_ITEM_POSITION}.</p>
     * item specified by {@link #EXTRA_CHOOSER_FOCUSED_ITEM_POSITION}.</li></ul></p>
     *
     * <p>When the user makes a selection change,
     * {@link ContentProvider#call(String, String, Bundle)} method will be invoked with the "method"
Loading