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

Commit 87a6fd7a authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Merge cherrypicks of [12236535, 12236686, 12236706, 12236707, 12236708,...

Merge cherrypicks of [12236535, 12236686, 12236706, 12236707, 12236708, 12236709, 12236710, 12236711, 12236687, 12236608, 12236629, 12236688, 12236459, 12236460, 12236536, 12236412] into rvc-release

Change-Id: I27766eaf2a654e4676823df532a0c930dd385d6b
parents 954c8693 d58101e2
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -304,6 +304,7 @@ public final class VibrationAttributes implements Parcelable {
                @Nullable VibrationEffect effect) {
            mAudioAttributes = audio;
            setUsage(audio);
            setFlags(audio);
            applyHapticFeedbackHeuristics(effect);
        }

@@ -360,6 +361,12 @@ public final class VibrationAttributes implements Parcelable {
            }
        }

        private void setFlags(@NonNull AudioAttributes audio) {
            if ((audio.getAllFlags() & AudioAttributes.FLAG_BYPASS_INTERRUPTION_POLICY) != 0) {
                mFlags |= FLAG_BYPASS_INTERRUPTION_POLICY;
            }
        }

        /**
         * Combines all of the attributes that have been set and returns a new
         * {@link VibrationAttributes} object.
+4 −2
Original line number Diff line number Diff line
@@ -326,6 +326,7 @@ class NotificationSectionsManager @Inject internal constructor(
        // shade.
        for (i in parent.childCount - 1 downTo -1) {
            val child: View? = parent.getChildAt(i)

            child?.let {
                logShadeChild(i, child)
                // If this child is a header, update the tracked positions
@@ -339,7 +340,8 @@ class NotificationSectionsManager @Inject internal constructor(
                }
            }

            val row = child as? ExpandableNotificationRow
            val row = (child as? ExpandableNotificationRow)
                    ?.takeUnless { it.visibility == View.GONE }

            // Is there a section discontinuity? This usually occurs due to HUNs
            inIncomingSection = inIncomingSection || nextBucket?.let { next ->
@@ -386,7 +388,7 @@ class NotificationSectionsManager @Inject internal constructor(

            // Offset the target to account for the current position of the people header.
            peopleState?.targetPosition = peopleState?.currentPosition?.let { current ->
                peopleState?.targetPosition?.let { target ->
                peopleState.targetPosition?.let { target ->
                    if (current < target) target - 1 else target
                }
            }
+47 −38
Original line number Diff line number Diff line
@@ -380,7 +380,7 @@ public class NotificationSectionsManagerTest extends SysuiTestCase {

        setupMockStack(
                PEOPLE_HEADER,
                ALERTING.headsUp(),
                ALERTING,
                PERSON,
                ALERTING_HEADER,
                GENTLE_HEADER,
@@ -403,9 +403,9 @@ public class NotificationSectionsManagerTest extends SysuiTestCase {
        enablePeopleFiltering();

        setupMockStack(
                PERSON.headsUp(),
                PERSON,
                INCOMING_HEADER,
                ALERTING.headsUp(),
                ALERTING,
                PEOPLE_HEADER,
                PERSON
        );
@@ -425,7 +425,7 @@ public class NotificationSectionsManagerTest extends SysuiTestCase {
        enablePeopleFiltering();

        setupMockStack(
                PERSON.headsUp(),
                PERSON,
                PEOPLE_HEADER,
                PERSON
        );
@@ -443,8 +443,8 @@ public class NotificationSectionsManagerTest extends SysuiTestCase {
        enablePeopleFiltering();

        setupMockStack(
                ALERTING.headsUp(),
                PERSON.headsUp()
                ALERTING,
                PERSON
        );
        mSectionsManager.updateSectionBoundaries();
        verifyMockStack(
@@ -461,7 +461,7 @@ public class NotificationSectionsManagerTest extends SysuiTestCase {

        setupMockStack(
                INCOMING_HEADER,
                ALERTING.headsUp(),
                ALERTING,
                PEOPLE_HEADER,
                FSN,
                PERSON,
@@ -502,9 +502,9 @@ public class NotificationSectionsManagerTest extends SysuiTestCase {
    public void testMediaControls_AddWhenEnterKeyguardWithHeadsUp() {
        enableMediaControls();

        // GIVEN a stack that doesn't include media controls but includes HEADS_UP
        // GIVEN a stack that doesn't include media
        setupMockStack(
                ALERTING.headsUp(),
                ALERTING,
                ALERTING,
                GENTLE_HEADER,
                GENTLE);
@@ -584,6 +584,27 @@ public class NotificationSectionsManagerTest extends SysuiTestCase {
        );
    }

    @Test
    public void testIgnoreGoneView() {
        enablePeopleFiltering();

        setupMockStack(
                PERSON.gone(),
                ALERTING,
                GENTLE
        );

        mSectionsManager.updateSectionBoundaries();

        verifyMockStack(
                ChildType.ALERTING_HEADER,
                ChildType.PERSON,
                ChildType.ALERTING,
                ChildType.GENTLE_HEADER,
                ChildType.GENTLE
        );
    }

    private void enablePeopleFiltering() {
        when(mSectionsFeatureManager.isFilteringEnabled()).thenReturn(true);
    }
@@ -619,16 +640,16 @@ public class NotificationSectionsManagerTest extends SysuiTestCase {
                    child = mSectionsManager.getSilentHeaderView();
                    break;
                case FSN:
                    child = mockNotification(BUCKET_FOREGROUND_SERVICE, entry.mIsHeadsUp);
                    child = mockNotification(BUCKET_FOREGROUND_SERVICE, entry.mIsGone);
                    break;
                case PERSON:
                    child = mockNotification(BUCKET_PEOPLE, entry.mIsHeadsUp);
                    child = mockNotification(BUCKET_PEOPLE, entry.mIsGone);
                    break;
                case ALERTING:
                    child = mockNotification(BUCKET_ALERTING, entry.mIsHeadsUp);
                    child = mockNotification(BUCKET_ALERTING, entry.mIsGone);
                    break;
                case GENTLE:
                    child = mockNotification(BUCKET_SILENT, entry.mIsHeadsUp);
                    child = mockNotification(BUCKET_SILENT, entry.mIsGone);
                    break;
                case OTHER:
                    child = mock(View.class);
@@ -643,7 +664,7 @@ public class NotificationSectionsManagerTest extends SysuiTestCase {
        }
    }

    private View mockNotification(int bucket, boolean headsUp) {
    private View mockNotification(int bucket, boolean isGone) {
        ExpandableNotificationRow notifRow =
                mock(ExpandableNotificationRow.class, RETURNS_DEEP_STUBS);
        when(notifRow.getVisibility()).thenReturn(View.VISIBLE);
@@ -659,8 +680,7 @@ public class NotificationSectionsManagerTest extends SysuiTestCase {
            return null;
        }).when(mockEntry).setBucket(anyInt());

        when(notifRow.isHeadsUp()).thenReturn(headsUp);
        when(mockEntry.isRowHeadsUp()).thenReturn(headsUp);
        when(notifRow.getVisibility()).thenReturn(isGone ? View.GONE : View.VISIBLE);
        return notifRow;
    }

@@ -767,16 +787,16 @@ public class NotificationSectionsManagerTest extends SysuiTestCase {
                    child = mSectionsManager.getSilentHeaderView();
                    break;
                case FSN:
                    child = mockNotification(BUCKET_FOREGROUND_SERVICE, entry.mIsHeadsUp);
                    child = mockNotification(BUCKET_FOREGROUND_SERVICE, entry.mIsGone);
                    break;
                case PERSON:
                    child = mockNotification(BUCKET_PEOPLE, entry.mIsHeadsUp);
                    child = mockNotification(BUCKET_PEOPLE, entry.mIsGone);
                    break;
                case ALERTING:
                    child = mockNotification(BUCKET_ALERTING, entry.mIsHeadsUp);
                    child = mockNotification(BUCKET_ALERTING, entry.mIsGone);
                    break;
                case GENTLE:
                    child = mockNotification(BUCKET_SILENT, entry.mIsHeadsUp);
                    child = mockNotification(BUCKET_SILENT, entry.mIsGone);
                    break;
                case OTHER:
                    child = mock(View.class);
@@ -796,36 +816,25 @@ public class NotificationSectionsManagerTest extends SysuiTestCase {
    private static final StackEntry ALERTING_HEADER = new StackEntry(ChildType.ALERTING_HEADER);
    private static final StackEntry GENTLE_HEADER = new StackEntry(ChildType.GENTLE_HEADER);
    private static final StackEntry FSN = new StackEntry(ChildType.FSN);
    private static final StackEntry.Hunnable PERSON = new StackEntry.Hunnable(ChildType.PERSON);
    private static final StackEntry.Hunnable ALERTING = new StackEntry.Hunnable(ChildType.ALERTING);
    private static final StackEntry PERSON = new StackEntry(ChildType.PERSON);
    private static final StackEntry ALERTING = new StackEntry(ChildType.ALERTING);
    private static final StackEntry GENTLE = new StackEntry(ChildType.GENTLE);

    private static class StackEntry {
        final ChildType mChildType;
        final boolean mIsHeadsUp;
        final boolean mIsGone;

        StackEntry(ChildType childType) {
            this(childType, false);
        }

        StackEntry(ChildType childType, boolean isHeadsUp) {
        StackEntry(ChildType childType, boolean isGone) {
            mChildType = childType;
            mIsHeadsUp = isHeadsUp;
        }

        static class Hunnable extends StackEntry {

            Hunnable(ChildType childType) {
                super(childType, false);
            }

            Hunnable(ChildType childType, boolean isHeadsUp) {
                super(childType, isHeadsUp);
            mIsGone = isGone;
        }

            public Hunnable headsUp() {
                return new Hunnable(mChildType, true);
            }
        public StackEntry gone() {
            return new StackEntry(mChildType, true);
        }
    }
}
+44 −1
Original line number Diff line number Diff line
@@ -292,6 +292,7 @@ import android.util.ArrayMap;
import android.util.ArraySet;
import android.util.DebugUtils;
import android.util.EventLog;
import android.util.IntArray;
import android.util.Log;
import android.util.Pair;
import android.util.PrintWriterPrinter;
@@ -311,6 +312,7 @@ import android.view.autofill.AutofillManagerInternal;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.app.IAppOpsActiveCallback;
import com.android.internal.app.IAppOpsCallback;
import com.android.internal.app.IAppOpsService;
import com.android.internal.app.ProcessMap;
@@ -654,6 +656,14 @@ public class ActivityManagerService extends IActivityManager.Stub
    /** Total # of UID change events dispatched, shown in dumpsys. */
    int mUidChangeDispatchCount;
    /**
     * Uids of apps with current active camera sessions.  Access synchronized on
     * the IntArray instance itself, and no other locks must be acquired while that
     * one is held.
     */
    @GuardedBy("mActiveCameraUids")
    final IntArray mActiveCameraUids = new IntArray(4);
    /**
     * Helper class which strips out priority and proto arguments then calls the dump function with
     * the appropriate arguments. If priority arguments are omitted, function calls the legacy
@@ -2032,7 +2042,10 @@ public class ActivityManagerService extends IActivityManager.Stub
                    }
                    if (proc != null) {
                        long startTime = SystemClock.currentThreadTimeMillis();
                        long pss = Debug.getPss(pid, tmp, null);
                        // skip background PSS calculation of apps that are capturing
                        // camera imagery
                        final boolean usingCamera = isCameraActiveForUid(proc.uid);
                        long pss = usingCamera ? 0 : Debug.getPss(pid, tmp, null);
                        long endTime = SystemClock.currentThreadTimeMillis();
                        synchronized (ActivityManagerService.this) {
                            if (pss != 0 && proc.thread != null && proc.setProcState == procState
@@ -2045,6 +2058,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                                ProcessList.abortNextPssTime(proc.procStateMemTracker);
                                if (DEBUG_PSS) Slog.d(TAG_PSS, "Skipped pss collection of " + pid +
                                        ": " + (proc.thread == null ? "NO_THREAD " : "") +
                                        (usingCamera ? "CAMERA " : "") +
                                        (proc.pid != pid ? "PID_CHANGED " : "") +
                                        " initState=" + procState + " curState=" +
                                        proc.setProcState + " " +
@@ -2134,6 +2148,14 @@ public class ActivityManagerService extends IActivityManager.Stub
                        }
                    }
                });
        final int[] cameraOp = {AppOpsManager.OP_CAMERA};
        mAppOpsService.startWatchingActive(cameraOp, new IAppOpsActiveCallback.Stub() {
            @Override
            public void opActiveChanged(int op, int uid, String packageName, boolean active) {
                cameraActiveChanged(uid, active);
            }
        });
    }
    public void setWindowManager(WindowManagerService wm) {
@@ -18224,6 +18246,27 @@ public class ActivityManagerService extends IActivityManager.Stub
        }
    }
    final void cameraActiveChanged(@UserIdInt int uid, boolean active) {
        synchronized (mActiveCameraUids) {
            final int curIndex = mActiveCameraUids.indexOf(uid);
            if (active) {
                if (curIndex < 0) {
                    mActiveCameraUids.add(uid);
                }
            } else {
                if (curIndex >= 0) {
                    mActiveCameraUids.remove(curIndex);
                }
            }
        }
    }
    final boolean isCameraActiveForUid(@UserIdInt int uid) {
        synchronized (mActiveCameraUids) {
            return mActiveCameraUids.indexOf(uid) >= 0;
        }
    }
    @GuardedBy("this")
    final void doStopUidLocked(int uid, final UidRecord uidRec) {
        mServices.stopInBackgroundLocked(uid);
+41 −21
Original line number Diff line number Diff line
@@ -6432,9 +6432,14 @@ public class PackageManagerService extends IPackageManager.Stub
                    true /*allowDynamicSplits*/);
            Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER);
            final boolean queryMayBeFiltered =
                    UserHandle.getAppId(filterCallingUid) >= Process.FIRST_APPLICATION_UID
                            && !resolveForStart;
            final ResolveInfo bestChoice =
                    chooseBestActivity(
                            intent, resolvedType, flags, privateResolveFlags, query, userId);
                            intent, resolvedType, flags, privateResolveFlags, query, userId,
                            queryMayBeFiltered);
            final boolean nonBrowserOnly =
                    (privateResolveFlags & PackageManagerInternal.RESOLVE_NON_BROWSER_ONLY) != 0;
            if (nonBrowserOnly && bestChoice != null && bestChoice.handleAllWebDataURI) {
@@ -6598,7 +6603,8 @@ public class PackageManagerService extends IPackageManager.Stub
    }
    private ResolveInfo chooseBestActivity(Intent intent, String resolvedType,
            int flags, int privateResolveFlags, List<ResolveInfo> query, int userId) {
            int flags, int privateResolveFlags, List<ResolveInfo> query, int userId,
            boolean queryMayBeFiltered) {
        if (query != null) {
            final int N = query.size();
            if (N == 1) {
@@ -6623,7 +6629,7 @@ public class PackageManagerService extends IPackageManager.Stub
                // If we have saved a preference for a preferred activity for
                // this Intent, use that.
                ResolveInfo ri = findPreferredActivityNotLocked(intent, resolvedType,
                        flags, query, r0.priority, true, false, debug, userId);
                        flags, query, r0.priority, true, false, debug, userId, queryMayBeFiltered);
                if (ri != null) {
                    return ri;
                }
@@ -6805,11 +6811,19 @@ public class PackageManagerService extends IPackageManager.Stub
                && intent.hasCategory(CATEGORY_DEFAULT);
    }
    ResolveInfo findPreferredActivityNotLocked(Intent intent, String resolvedType, int flags,
            List<ResolveInfo> query, int priority, boolean always,
            boolean removeMatches, boolean debug, int userId) {
        return findPreferredActivityNotLocked(
                intent, resolvedType, flags, query, priority, always, removeMatches, debug, userId,
                UserHandle.getAppId(Binder.getCallingUid()) >= Process.FIRST_APPLICATION_UID);
    }
    // TODO: handle preferred activities missing while user has amnesia
    /** <b>must not hold {@link #mLock}</b> */
    ResolveInfo findPreferredActivityNotLocked(Intent intent, String resolvedType, int flags,
            List<ResolveInfo> query, int priority, boolean always,
            boolean removeMatches, boolean debug, int userId) {
            boolean removeMatches, boolean debug, int userId, boolean queryMayBeFiltered) {
        if (Thread.holdsLock(mLock)) {
            Slog.wtf(TAG, "Calling thread " + Thread.currentThread().getName()
                    + " is holding mLock", new Throwable());
@@ -6903,10 +6917,12 @@ public class PackageManagerService extends IPackageManager.Stub
                        }
                        final boolean excludeSetupWizardHomeActivity = isHomeIntent(intent)
                                && !isDeviceProvisioned;
                        final boolean allowSetMutation = !excludeSetupWizardHomeActivity
                                && !queryMayBeFiltered;
                        if (ai == null) {
                            // Do not remove launcher's preferred activity during SetupWizard
                            // due to it may not install yet
                            if (excludeSetupWizardHomeActivity) {
                            if (!allowSetMutation) {
                                continue;
                            }
@@ -6931,7 +6947,7 @@ public class PackageManagerService extends IPackageManager.Stub
                                continue;
                            }
                            if (removeMatches) {
                            if (removeMatches && allowSetMutation) {
                                pir.removeFilter(pa);
                                changed = true;
                                if (DEBUG_PREFERRED) {
@@ -6948,7 +6964,7 @@ public class PackageManagerService extends IPackageManager.Stub
                            if (always && !pa.mPref.sameSet(query, excludeSetupWizardHomeActivity)) {
                                if (pa.mPref.isSuperset(query, excludeSetupWizardHomeActivity)) {
                                    if (!excludeSetupWizardHomeActivity) {
                                    if (allowSetMutation) {
                                        // some components of the set are no longer present in
                                        // the query, but the preferred activity can still be reused
                                        if (DEBUG_PREFERRED) {
@@ -6969,24 +6985,28 @@ public class PackageManagerService extends IPackageManager.Stub
                                        changed = true;
                                    } else {
                                        if (DEBUG_PREFERRED) {
                                            Slog.i(TAG, "Do not remove preferred activity for launcher"
                                                    + " during SetupWizard");
                                            Slog.i(TAG, "Do not remove preferred activity");
                                        }
                                    }
                                } else {
                                    if (allowSetMutation) {
                                        Slog.i(TAG,
                                            "Result set changed, dropping preferred activity for "
                                                    + intent + " type " + resolvedType);
                                                "Result set changed, dropping preferred activity "
                                                        + "for " + intent + " type "
                                                        + resolvedType);
                                        if (DEBUG_PREFERRED) {
                                        Slog.v(TAG, "Removing preferred activity since set changed "
                                            Slog.v(TAG,
                                                    "Removing preferred activity since set changed "
                                                            + pa.mPref.mComponent);
                                        }
                                        pir.removeFilter(pa);
                                        // Re-add the filter as a "last chosen" entry (!always)
                                        PreferredActivity lastChosen = new PreferredActivity(
                                            pa, pa.mPref.mMatch, null, pa.mPref.mComponent, false);
                                                pa, pa.mPref.mMatch, null, pa.mPref.mComponent,
                                                false);
                                        pir.addFilter(lastChosen);
                                        changed = true;
                                    }
                                    return null;
                                }
                            }
Loading