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

Unverified Commit 87052f70 authored by Kevin F. Haggerty's avatar Kevin F. Haggerty
Browse files

Merge tag 'android-security-13.0.0_r9' of...

Merge tag 'android-security-13.0.0_r9' of https://android.googlesource.com/platform/frameworks/base into staging/lineage-20.0_merge_android-security-13.0.0_r9

Android security 13.0.0 release 9

* tag 'android-security-13.0.0_r9' of https://android.googlesource.com/platform/frameworks/base:
  Improve user handling when querying for resumable media
  Update AccountManagerService checkKeyIntentParceledCorrectly.
  [DO NOT MERGE] Update quickshare intent rather than recreating
  Forbid granting access to NLSes with too-long component names
  Ignore virtual presentation windows - RESTRICT AUTOMERGE
  DO NOT MERGE Revert "Verify URI permissions for EXTRA_REMOTE_INPUT_HISTORY_ITEMS."

Conflicts:
	packages/SystemUI/src/com/android/systemui/media/controls/resume/MediaResumeListener.kt
	packages/SystemUI/src/com/android/systemui/screenshot/SaveImageInBackgroundTask.java
	packages/SystemUI/tests/src/com/android/systemui/media/controls/resume/MediaResumeListenerTest.kt
	packages/SystemUI/tests/src/com/android/systemui/media/controls/resume/ResumeMediaBrowserTest.kt

Change-Id: I1779378e2d096c363f0766d637f570319addad67
parents eb2f4d32 3e09cce1
Loading
Loading
Loading
Loading
+0 −11
Original line number Original line Diff line number Diff line
@@ -2857,17 +2857,6 @@ public class Notification implements Parcelable
            if (person != null) {
            if (person != null) {
                visitor.accept(person.getIconUri());
                visitor.accept(person.getIconUri());
            }
            }
            final RemoteInputHistoryItem[] history = (RemoteInputHistoryItem[])
                    extras.getParcelableArray(Notification.EXTRA_REMOTE_INPUT_HISTORY_ITEMS);
            if (history != null) {
                for (int i = 0; i < history.length; i++) {
                    RemoteInputHistoryItem item = history[i];
                    if (item.getUri() != null) {
                        visitor.accept(item.getUri());
                    }
                }
            }
        }
        }
        if (isStyle(MessagingStyle.class) && extras != null) {
        if (isStyle(MessagingStyle.class) && extras != null) {
+6 −0
Original line number Original line Diff line number Diff line
@@ -571,6 +571,12 @@ public class NotificationManager {
     */
     */
    public static final int BUBBLE_PREFERENCE_SELECTED = 2;
    public static final int BUBBLE_PREFERENCE_SELECTED = 2;


    /**
     * Maximum length of the component name of a registered NotificationListenerService.
     * @hide
     */
    public static int MAX_SERVICE_COMPONENT_NAME_LENGTH = 500;

    @UnsupportedAppUsage
    @UnsupportedAppUsage
    private static INotificationManager sService;
    private static INotificationManager sService;


+6 −2
Original line number Original line Diff line number Diff line
@@ -243,7 +243,9 @@ public class RestrictedSwitchPreference extends SwitchPreference {
        return mHelper != null ? mHelper.packageName : null;
        return mHelper != null ? mHelper.packageName : null;
    }
    }


    public void updateState(@NonNull String packageName, int uid, boolean isEnabled) {
    /** Updates enabled state based on associated package. */
    public void updateState(
            @NonNull String packageName, int uid, boolean isEnableAllowed, boolean isEnabled) {
        mHelper.updatePackageDetails(packageName, uid);
        mHelper.updatePackageDetails(packageName, uid);
        if (mAppOpsManager == null) {
        if (mAppOpsManager == null) {
            mAppOpsManager = getContext().getSystemService(AppOpsManager.class);
            mAppOpsManager = getContext().getSystemService(AppOpsManager.class);
@@ -254,7 +256,9 @@ public class RestrictedSwitchPreference extends SwitchPreference {
        final boolean ecmEnabled = getContext().getResources().getBoolean(
        final boolean ecmEnabled = getContext().getResources().getBoolean(
                com.android.internal.R.bool.config_enhancedConfirmationModeEnabled);
                com.android.internal.R.bool.config_enhancedConfirmationModeEnabled);
        final boolean appOpsAllowed = !ecmEnabled || mode == AppOpsManager.MODE_ALLOWED;
        final boolean appOpsAllowed = !ecmEnabled || mode == AppOpsManager.MODE_ALLOWED;
        if (isEnabled) {
        if (!isEnableAllowed && !isEnabled) {
            setEnabled(false);
        } else if (isEnabled) {
            setEnabled(true);
            setEnabled(true);
        } else if (appOpsAllowed && isDisabledByAppOps()) {
        } else if (appOpsAllowed && isDisabledByAppOps()) {
            setEnabled(true);
            setEnabled(true);
+27 −9
Original line number Original line Diff line number Diff line
@@ -122,9 +122,9 @@ constructor(
                    Log.e(TAG, "Error getting package information", e)
                    Log.e(TAG, "Error getting package information", e)
                }
                }


                Log.d(TAG, "Adding resume controls $desc")
                Log.d(TAG, "Adding resume controls for ${browser.userId}: $desc")
                mediaDataManager.addResumptionControls(
                mediaDataManager.addResumptionControls(
                    currentUserId,
                    browser.userId,
                    desc,
                    desc,
                    resumeAction,
                    resumeAction,
                    token,
                    token,
@@ -196,7 +196,11 @@ constructor(
                }
                }
            resumeComponents.add(component to lastPlayed)
            resumeComponents.add(component to lastPlayed)
        }
        }
        Log.d(TAG, "loaded resume components ${resumeComponents.toArray().contentToString()}")
        Log.d(
            TAG,
            "loaded resume components for $currentUserId: " +
                "${resumeComponents.toArray().contentToString()}"
        )


        if (needsUpdate) {
        if (needsUpdate) {
            // Save any missing times that we had to fill in
            // Save any missing times that we had to fill in
@@ -210,11 +214,21 @@ constructor(
            return
            return
        }
        }


        val pm = context.packageManager
        val now = systemClock.currentTimeMillis()
        val now = systemClock.currentTimeMillis()
        resumeComponents.forEach {
        resumeComponents.forEach {
            if (now.minus(it.second) <= RESUME_MEDIA_TIMEOUT) {
            if (now.minus(it.second) <= RESUME_MEDIA_TIMEOUT) {
                val browser = mediaBrowserFactory.create(mediaBrowserCallback, it.first)
                // Verify that the service exists for this user
                val intent = Intent(MediaBrowserService.SERVICE_INTERFACE)
                intent.component = it.first
                val inf = pm.resolveServiceAsUser(intent, 0, currentUserId)
                if (inf != null) {
                    val browser =
                        mediaBrowserFactory.create(mediaBrowserCallback, it.first, currentUserId)
                    browser.findRecentMedia()
                    browser.findRecentMedia()
                } else {
                    Log.d(TAG, "User $currentUserId does not have component ${it.first}")
                }
            }
            }
        }
        }
    }
    }
@@ -244,7 +258,7 @@ constructor(
                Log.d(TAG, "Checking for service component for " + data.packageName)
                Log.d(TAG, "Checking for service component for " + data.packageName)
                val pm = context.packageManager
                val pm = context.packageManager
                val serviceIntent = Intent(MediaBrowserService.SERVICE_INTERFACE)
                val serviceIntent = Intent(MediaBrowserService.SERVICE_INTERFACE)
                val resumeInfo = pm.queryIntentServices(serviceIntent, 0)
                val resumeInfo = pm.queryIntentServicesAsUser(serviceIntent, 0, currentUserId)


                val inf = resumeInfo?.filter { it.serviceInfo.packageName == data.packageName }
                val inf = resumeInfo?.filter { it.serviceInfo.packageName == data.packageName }
                if (inf != null && inf.size > 0) {
                if (inf != null && inf.size > 0) {
@@ -280,13 +294,17 @@ constructor(
                        browser: ResumeMediaBrowser
                        browser: ResumeMediaBrowser
                    ) {
                    ) {
                        // Since this is a test, just save the component for later
                        // Since this is a test, just save the component for later
                        Log.d(TAG, "Can get resumable media from $componentName")
                        Log.d(
                            TAG,
                            "Can get resumable media for ${browser.userId} from $componentName"
                        )
                        mediaDataManager.setResumeAction(key, getResumeAction(componentName))
                        mediaDataManager.setResumeAction(key, getResumeAction(componentName))
                        updateResumptionList(componentName)
                        updateResumptionList(componentName)
                        mediaBrowser = null
                        mediaBrowser = null
                    }
                    }
                },
                },
                componentName
                componentName,
                currentUserId
            )
            )
        mediaBrowser?.testConnection()
        mediaBrowser?.testConnection()
    }
    }
@@ -326,7 +344,7 @@ constructor(
    /** Get a runnable which will resume media playback */
    /** Get a runnable which will resume media playback */
    private fun getResumeAction(componentName: ComponentName): Runnable {
    private fun getResumeAction(componentName: ComponentName): Runnable {
        return Runnable {
        return Runnable {
            mediaBrowser = mediaBrowserFactory.create(null, componentName)
            mediaBrowser = mediaBrowserFactory.create(null, componentName, currentUserId)
            mediaBrowser?.restart()
            mediaBrowser?.restart()
        }
        }
    }
    }
+14 −1
Original line number Original line Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.systemui.media.controls.resume;
package com.android.systemui.media.controls.resume;


import android.annotation.Nullable;
import android.annotation.Nullable;
import android.annotation.UserIdInt;
import android.app.PendingIntent;
import android.app.PendingIntent;
import android.content.ComponentName;
import android.content.ComponentName;
import android.content.Context;
import android.content.Context;
@@ -53,6 +54,7 @@ public class ResumeMediaBrowser {
    private final ResumeMediaBrowserLogger mLogger;
    private final ResumeMediaBrowserLogger mLogger;
    private final ComponentName mComponentName;
    private final ComponentName mComponentName;
    private final MediaController.Callback mMediaControllerCallback = new SessionDestroyCallback();
    private final MediaController.Callback mMediaControllerCallback = new SessionDestroyCallback();
    @UserIdInt private final int mUserId;


    private MediaBrowser mMediaBrowser;
    private MediaBrowser mMediaBrowser;
    @Nullable private MediaController mMediaController;
    @Nullable private MediaController mMediaController;
@@ -62,18 +64,21 @@ public class ResumeMediaBrowser {
     * @param context the context
     * @param context the context
     * @param callback used to report media items found
     * @param callback used to report media items found
     * @param componentName Component name of the MediaBrowserService this browser will connect to
     * @param componentName Component name of the MediaBrowserService this browser will connect to
     * @param userId ID of the current user
     */
     */
    public ResumeMediaBrowser(
    public ResumeMediaBrowser(
            Context context,
            Context context,
            @Nullable Callback callback,
            @Nullable Callback callback,
            ComponentName componentName,
            ComponentName componentName,
            MediaBrowserFactory browserFactory,
            MediaBrowserFactory browserFactory,
            ResumeMediaBrowserLogger logger) {
            ResumeMediaBrowserLogger logger,
            @UserIdInt int userId) {
        mContext = context;
        mContext = context;
        mCallback = callback;
        mCallback = callback;
        mComponentName = componentName;
        mComponentName = componentName;
        mBrowserFactory = browserFactory;
        mBrowserFactory = browserFactory;
        mLogger = logger;
        mLogger = logger;
        mUserId = userId;
    }
    }


    /**
    /**
@@ -284,6 +289,14 @@ public class ResumeMediaBrowser {
        return new MediaController(mContext, token);
        return new MediaController(mContext, token);
    }
    }


    /**
     * Get the ID of the user associated with this broswer
     * @return the user ID
     */
    public @UserIdInt int getUserId() {
        return mUserId;
    }

    /**
    /**
     * Get the media session token
     * Get the media session token
     * @return the token, or null if the MediaBrowser is null or disconnected
     * @return the token, or null if the MediaBrowser is null or disconnected
Loading