diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2020-07-26 20:57:04 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2020-07-26 20:57:04 +0000 |
commit | 87a6fd7acd7ad2b128026082884e584ade5d95ed (patch) | |
tree | a3492da1eda893004578eab4636f5abf760a0958 | |
parent | 954c86932392b931dd7c07fb695b4515d3dd5cf9 (diff) | |
parent | d58101e2b2410f686b69de5d5a2dbbada198053a (diff) | |
download | base-87a6fd7acd7ad2b128026082884e584ade5d95ed.tar.gz |
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
7 files changed, 157 insertions, 67 deletions
diff --git a/core/java/android/os/VibrationAttributes.java b/core/java/android/os/VibrationAttributes.java index 27782fa74dab..171aef400b07 100644 --- a/core/java/android/os/VibrationAttributes.java +++ b/core/java/android/os/VibrationAttributes.java @@ -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. diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsManager.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsManager.kt index c87b9986ca55..56238d0a1b82 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsManager.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsManager.kt @@ -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 } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsManagerTest.java index 243503d1d8a6..7ca24789a29b 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsManagerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsManagerTest.java @@ -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; + mIsGone = isGone; } - static class Hunnable extends StackEntry { - - Hunnable(ChildType childType) { - super(childType, false); - } - - Hunnable(ChildType childType, boolean isHeadsUp) { - super(childType, isHeadsUp); - } - - public Hunnable headsUp() { - return new Hunnable(mChildType, true); - } + public StackEntry gone() { + return new StackEntry(mChildType, true); } } } diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index 9994f6647699..ec24014f77d7 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -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; @@ -655,6 +657,14 @@ public class ActivityManagerService extends IActivityManager.Stub 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 * dump command. @@ -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); diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java index b4ab57fa4dc8..63c721a5da7b 100644 --- a/services/core/java/com/android/server/pm/PackageManagerService.java +++ b/services/core/java/com/android/server/pm/PackageManagerService.java @@ -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 { - Slog.i(TAG, - "Result set changed, dropping preferred activity for " - + intent + " type " + resolvedType); - if (DEBUG_PREFERRED) { - Slog.v(TAG, "Removing preferred activity since set changed " - + pa.mPref.mComponent); + if (allowSetMutation) { + Slog.i(TAG, + "Result set changed, dropping preferred activity " + + "for " + intent + " type " + + resolvedType); + if (DEBUG_PREFERRED) { + 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); + pir.addFilter(lastChosen); + changed = true; } - 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); - pir.addFilter(lastChosen); - changed = true; return null; } } diff --git a/services/core/java/com/android/server/storage/StorageUserConnection.java b/services/core/java/com/android/server/storage/StorageUserConnection.java index ed5706752cb2..361a5067b9bf 100644 --- a/services/core/java/com/android/server/storage/StorageUserConnection.java +++ b/services/core/java/com/android/server/storage/StorageUserConnection.java @@ -34,6 +34,7 @@ import android.os.ParcelFileDescriptor; import android.os.ParcelableException; import android.os.RemoteCallback; import android.os.UserHandle; +import android.os.UserManagerInternal; import android.os.storage.StorageManagerInternal; import android.os.storage.StorageVolume; import android.service.storage.ExternalStorageService; @@ -62,19 +63,25 @@ import java.util.concurrent.TimeoutException; public final class StorageUserConnection { private static final String TAG = "StorageUserConnection"; - public static final int REMOTE_TIMEOUT_SECONDS = 20; + private static final int DEFAULT_REMOTE_TIMEOUT_SECONDS = 20; + // TODO(b/161702661): Workaround for demo user to have shorter timeout. + // This allows the DevicePolicyManagerService#enableSystemApp call to succeed without ANR. + private static final int DEMO_USER_REMOTE_TIMEOUT_SECONDS = 5; private final Object mLock = new Object(); private final Context mContext; private final int mUserId; private final StorageSessionController mSessionController; private final ActiveConnection mActiveConnection = new ActiveConnection(); + private final boolean mIsDemoUser; @GuardedBy("mLock") private final Map<String, Session> mSessions = new HashMap<>(); public StorageUserConnection(Context context, int userId, StorageSessionController controller) { mContext = Objects.requireNonNull(context); mUserId = Preconditions.checkArgumentNonnegative(userId); mSessionController = controller; + mIsDemoUser = LocalServices.getService(UserManagerInternal.class) + .getUserInfo(userId).isDemo(); } /** @@ -200,7 +207,8 @@ public final class StorageUserConnection { private void waitForLatch(CountDownLatch latch, String reason) throws TimeoutException { try { - if (!latch.await(REMOTE_TIMEOUT_SECONDS, TimeUnit.SECONDS)) { + if (!latch.await(mIsDemoUser ? DEMO_USER_REMOTE_TIMEOUT_SECONDS + : DEFAULT_REMOTE_TIMEOUT_SECONDS, TimeUnit.SECONDS)) { // TODO(b/140025078): Call ActivityManager ANR API? Slog.wtf(TAG, "Failed to bind to the ExternalStorageService for user " + mUserId); throw new TimeoutException("Latch wait for " + reason + " elapsed"); diff --git a/telephony/common/android/telephony/LocationAccessPolicy.java b/telephony/common/android/telephony/LocationAccessPolicy.java index 3048ad7c1fb0..1c7a700a96ef 100644 --- a/telephony/common/android/telephony/LocationAccessPolicy.java +++ b/telephony/common/android/telephony/LocationAccessPolicy.java @@ -260,11 +260,12 @@ public final class LocationAccessPolicy { /** Check if location permissions have been granted */ public static LocationPermissionResult checkLocationPermission( Context context, LocationPermissionQuery query) { - // Always allow the phone process and system server to access location. This avoid - // breaking legacy code that rely on public-facing APIs to access cell location, and - // it doesn't create an info leak risk because the cell location is stored in the phone + // Always allow the phone process, system server, and network stack to access location. + // This avoid breaking legacy code that rely on public-facing APIs to access cell location, + // and it doesn't create an info leak risk because the cell location is stored in the phone // process anyway, and the system server already has location access. if (query.callingUid == Process.PHONE_UID || query.callingUid == Process.SYSTEM_UID + || query.callingUid == Process.NETWORK_STACK_UID || query.callingUid == Process.ROOT_UID) { return LocationPermissionResult.ALLOWED; } |