diff options
author | android-build-prod (mdb) <android-build-team-robot@google.com> | 2017-10-06 20:06:19 +0000 |
---|---|---|
committer | android-build-prod (mdb) <android-build-team-robot@google.com> | 2017-10-06 20:06:19 +0000 |
commit | 7ec76225bd406ea4974d119606d5159306e166b0 (patch) | |
tree | 53c06d8a97271e8b65d2aa69a4c349f002aa22cc | |
parent | 699510a4be42e885cd9839a9e91a8a82355adec9 (diff) | |
parent | 2efbc7239f419c931784acf98960ed6abc38c3f2 (diff) | |
download | base-7ec76225bd406ea4974d119606d5159306e166b0.tar.gz |
Snap for 4379964 from 2efbc7239f419c931784acf98960ed6abc38c3f2 to oreo-cts-release
Change-Id: I5e3a735a4054222e6baa244132058d3380e67b16
11 files changed, 193 insertions, 78 deletions
diff --git a/core/java/android/bluetooth/le/BluetoothLeScanner.java b/core/java/android/bluetooth/le/BluetoothLeScanner.java index 1eac395bd06c..e3bc78e5a2bb 100644 --- a/core/java/android/bluetooth/le/BluetoothLeScanner.java +++ b/core/java/android/bluetooth/le/BluetoothLeScanner.java @@ -205,7 +205,8 @@ public final class BluetoothLeScanner { } synchronized (mLeScanClients) { if (callback != null && mLeScanClients.containsKey(callback)) { - postCallbackError(callback, ScanCallback.SCAN_FAILED_ALREADY_STARTED); + return postCallbackErrorOrReturn(callback, + ScanCallback.SCAN_FAILED_ALREADY_STARTED); } IBluetoothGatt gatt; try { diff --git a/core/java/android/service/gatekeeper/GateKeeperResponse.java b/core/java/android/service/gatekeeper/GateKeeperResponse.java index 287dc76a9b01..9b529345851b 100644 --- a/core/java/android/service/gatekeeper/GateKeeperResponse.java +++ b/core/java/android/service/gatekeeper/GateKeeperResponse.java @@ -106,6 +106,8 @@ public final class GateKeeperResponse implements Parcelable { if (mPayload != null) { dest.writeInt(mPayload.length); dest.writeByteArray(mPayload); + } else { + dest.writeInt(0); } } } diff --git a/media/java/android/media/MediaDescription.java b/media/java/android/media/MediaDescription.java index 14485d3c43a3..e6aea99ef50b 100644 --- a/media/java/android/media/MediaDescription.java +++ b/media/java/android/media/MediaDescription.java @@ -220,6 +220,33 @@ public class MediaDescription implements Parcelable { } @Override + public boolean equals(Object o) { + if (o == null) { + return false; + } + + if (!(o instanceof MediaDescription)){ + return false; + } + + final MediaDescription d = (MediaDescription) o; + + if (!String.valueOf(mTitle).equals(String.valueOf(d.mTitle))) { + return false; + } + + if (!String.valueOf(mSubtitle).equals(String.valueOf(d.mSubtitle))) { + return false; + } + + if (!String.valueOf(mDescription).equals(String.valueOf(d.mDescription))) { + return false; + } + + return true; + } + + @Override public String toString() { return mTitle + ", " + mSubtitle + ", " + mDescription; } diff --git a/media/java/android/media/session/MediaSession.java b/media/java/android/media/session/MediaSession.java index dfd2bb35d6ea..9536d3d35206 100644 --- a/media/java/android/media/session/MediaSession.java +++ b/media/java/android/media/session/MediaSession.java @@ -48,6 +48,7 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.ref.WeakReference; import java.util.List; +import java.util.Objects; /** * Allows interaction with media controllers, volume keys, media buttons, and @@ -1256,6 +1257,28 @@ public final class MediaSession { "Description=" + mDescription + ", Id=" + mId + " }"; } + + @Override + public boolean equals(Object o) { + if (o == null) { + return false; + } + + if (!(o instanceof QueueItem)) { + return false; + } + + final QueueItem item = (QueueItem) o; + if (mId != item.mId) { + return false; + } + + if (!Objects.equals(mDescription, item.mDescription)) { + return false; + } + + return true; + } } private static final class Command { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java index 6fe8827c4c87..e9f6e95b2f48 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java @@ -397,24 +397,6 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL && pm.resolveActivity(PHONE_INTENT, 0) != null; } - private boolean isCameraDisabledByDpm() { - final DevicePolicyManager dpm = - (DevicePolicyManager) getContext().getSystemService(Context.DEVICE_POLICY_SERVICE); - if (dpm != null && mStatusBar != null) { - try { - final int userId = ActivityManager.getService().getCurrentUser().id; - final int disabledFlags = dpm.getKeyguardDisabledFeatures(null, userId); - final boolean disabledBecauseKeyguardSecure = - (disabledFlags & DevicePolicyManager.KEYGUARD_DISABLE_SECURE_CAMERA) != 0 - && mStatusBar.isKeyguardSecure(); - return dpm.getCameraDisabled(null) || disabledBecauseKeyguardSecure; - } catch (RemoteException e) { - Log.e(TAG, "Can't get userId", e); - } - } - return false; - } - private void watchForCameraPolicyChanges() { final IntentFilter filter = new IntentFilter(); filter.addAction(DevicePolicyManager.ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED); @@ -865,7 +847,8 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL @Override public IconState getIcon() { ResolveInfo resolved = resolveCameraIntent(); - mIconState.isVisible = !isCameraDisabledByDpm() && resolved != null + boolean isCameraDisabled = (mStatusBar != null) && !mStatusBar.isCameraAllowedByAdmin(); + mIconState.isVisible = !isCameraDisabled && resolved != null && getResources().getBoolean(R.bool.config_keyguardShowCameraAffordance) && mUserSetupComplete; mIconState.drawable = mContext.getDrawable(R.drawable.ic_camera_alt_24dp); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java index 6aab8e10543e..54c12a187dc2 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java @@ -31,6 +31,7 @@ import android.graphics.Color; import android.graphics.Paint; import android.graphics.Rect; import android.util.AttributeSet; +import android.util.EventLog; import android.util.FloatProperty; import android.util.MathUtils; import android.view.MotionEvent; @@ -2440,6 +2441,11 @@ public class NotificationPanelView extends PanelView implements * @param keyguardIsShowing whether keyguard is being shown */ public boolean canCameraGestureBeLaunched(boolean keyguardIsShowing) { + if (!mStatusBar.isCameraAllowedByAdmin()) { + EventLog.writeEvent(0x534e4554, "63787722", -1, ""); + return false; + } + ResolveInfo resolveInfo = mKeyguardBottomArea.resolveCameraIntent(); String packageToLaunch = (resolveInfo == null || resolveInfo.activityInfo == null) ? null : resolveInfo.activityInfo.packageName; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java index f58fe8290a43..d2994bd4fca1 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java @@ -1,5 +1,3 @@ - - /* * Copyright (C) 2010 The Android Open Source Project * @@ -5040,6 +5038,18 @@ public class StatusBar extends SystemUI implements DemoMode, } } + boolean isCameraAllowedByAdmin() { + if (mDevicePolicyManager.getCameraDisabled(null, mCurrentUserId)) { + return false; + } else if (isKeyguardShowing() && isKeyguardSecure()) { + // Check if the admin has disabled the camera specifically for the keyguard + return (mDevicePolicyManager.getKeyguardDisabledFeatures(null, mCurrentUserId) + & DevicePolicyManager.KEYGUARD_DISABLE_SECURE_CAMERA) == 0; + } + + return true; + } + public void notifyFpAuthModeChanged() { updateDozing(); } @@ -5062,6 +5072,10 @@ public class StatusBar extends SystemUI implements DemoMode, } public boolean isKeyguardShowing() { + if (mStatusBarKeyguardViewManager == null) { + Slog.i(TAG, "isKeyguardShowing() called before startKeyguard(), returning true"); + return true; + } return mStatusBarKeyguardViewManager.isShowing(); } diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java index bdea24704ef5..c3f9dc96c67b 100644 --- a/services/core/java/com/android/server/notification/NotificationManagerService.java +++ b/services/core/java/com/android/server/notification/NotificationManagerService.java @@ -519,7 +519,8 @@ public class NotificationManagerService extends SystemService { } } - private final NotificationDelegate mNotificationDelegate = new NotificationDelegate() { + @VisibleForTesting + final NotificationDelegate mNotificationDelegate = new NotificationDelegate() { @Override public void onSetDisabled(int status) { @@ -1011,6 +1012,25 @@ public class NotificationManagerService extends SystemService { } @VisibleForTesting + int getNotificationRecordCount() { + synchronized (mNotificationLock) { + int count = mNotificationList.size() + mNotificationsByKey.size() + + mSummaryByGroupKey.size() + mEnqueuedNotifications.size(); + // subtract duplicates + for (NotificationRecord posted : mNotificationList) { + if (mNotificationsByKey.containsKey(posted.getKey())) { + count--; + } + if (posted.sbn.isGroup() && posted.getNotification().isGroupSummary()) { + count --; + } + } + + return count; + } + } + + @VisibleForTesting void addNotification(NotificationRecord r) { mNotificationList.add(r); mNotificationsByKey.put(r.sbn.getKey(), r); @@ -4506,6 +4526,7 @@ public class NotificationManagerService extends SystemService { canceledNotifications = new ArrayList<>(); } notificationList.remove(i); + mNotificationsByKey.remove(r.getKey()); canceledNotifications.add(r); cancelNotificationLocked(r, sendDelete, reason, wasPosted); } @@ -4615,6 +4636,7 @@ public class NotificationManagerService extends SystemService { EventLogTags.writeNotificationCancel(callingUid, callingPid, pkg, childSbn.getId(), childSbn.getTag(), userId, 0, 0, reason, listenerName); notificationList.remove(i); + mNotificationsByKey.remove(childR.getKey()); cancelNotificationLocked(childR, sendDelete, reason, wasPosted); } } diff --git a/services/core/java/com/android/server/wm/AppWindowContainerController.java b/services/core/java/com/android/server/wm/AppWindowContainerController.java index 4e4398ee9d91..741161b79187 100644 --- a/services/core/java/com/android/server/wm/AppWindowContainerController.java +++ b/services/core/java/com/android/server/wm/AppWindowContainerController.java @@ -115,41 +115,6 @@ public class AppWindowContainerController mListener.onWindowsGone(); }; - private final Runnable mRemoveStartingWindow = () -> { - StartingSurface surface = null; - synchronized (mWindowMap) { - if (mContainer == null) { - if (DEBUG_STARTING_WINDOW) Slog.v(TAG_WM, "mContainer was null while trying to" - + " remove starting window"); - return; - } - if (DEBUG_STARTING_WINDOW) Slog.v(TAG_WM, "Remove starting " + mContainer - + ": startingWindow=" + mContainer.startingWindow - + " startingView=" + mContainer.startingSurface); - if (mContainer.startingData != null) { - surface = mContainer.startingSurface; - mContainer.startingData = null; - mContainer.startingSurface = null; - mContainer.startingWindow = null; - mContainer.startingDisplayed = false; - if (surface == null && DEBUG_STARTING_WINDOW) { - Slog.v(TAG_WM, "startingWindow was set but startingSurface==null, couldn't " - + "remove"); - } - } else if (DEBUG_STARTING_WINDOW) { - Slog.v(TAG_WM, "Tried to remove starting window but startingWindow was null:" - + mContainer); - } - } - if (surface != null) { - try { - surface.remove(); - } catch (Exception e) { - Slog.w(TAG_WM, "Exception when removing starting window", e); - } - } - }; - private final Runnable mAddStartingWindow = () -> { final StartingData startingData; final AppWindowToken container; @@ -649,13 +614,6 @@ public class AppWindowContainerController public void removeStartingWindow() { synchronized (mWindowMap) { - if (mHandler.hasCallbacks(mRemoveStartingWindow)) { - // Already scheduled. - if (DEBUG_STARTING_WINDOW) Slog.v(TAG_WM, "Trying to remove starting window but " - + "already scheduled"); - return; - } - if (mContainer.startingWindow == null) { if (mContainer.startingData != null) { // Starting window has not been added yet, but it is scheduled to be added. @@ -667,9 +625,36 @@ public class AppWindowContainerController return; } + final StartingSurface surface; + if (mContainer.startingData != null) { + surface = mContainer.startingSurface; + mContainer.startingData = null; + mContainer.startingSurface = null; + mContainer.startingWindow = null; + mContainer.startingDisplayed = false; + if (surface == null && DEBUG_STARTING_WINDOW) { + Slog.v(TAG_WM, "startingWindow was set but startingSurface==null, couldn't " + + "remove"); + } + } else { + if (DEBUG_STARTING_WINDOW) { + Slog.v(TAG_WM, "Tried to remove starting window but startingWindow was null:" + + mContainer); + } + return; + } + if (DEBUG_STARTING_WINDOW) Slog.v(TAG_WM, "Schedule remove starting " + mContainer - + " startingWindow=" + mContainer.startingWindow); - mHandler.post(mRemoveStartingWindow); + + " startingWindow=" + mContainer.startingWindow + + " startingView=" + mContainer.startingSurface); + mHandler.post(() -> { + if (DEBUG_STARTING_WINDOW) Slog.v(TAG_WM, "Removing startingView=" + surface); + try { + surface.remove(); + } catch (Exception e) { + Slog.w(TAG_WM, "Exception when removing starting window", e); + } + }); } } diff --git a/services/core/jni/com_android_server_power_PowerManagerService.cpp b/services/core/jni/com_android_server_power_PowerManagerService.cpp index c722629a28f4..c71614d69b0b 100644 --- a/services/core/jni/com_android_server_power_PowerManagerService.cpp +++ b/services/core/jni/com_android_server_power_PowerManagerService.cpp @@ -62,7 +62,7 @@ std::mutex gPowerHalMutex; static nsecs_t gLastEventTime[USER_ACTIVITY_EVENT_LAST + 1]; // Throttling interval for user activity calls. -static const nsecs_t MIN_TIME_BETWEEN_USERACTIVITIES = 500 * 1000000L; // 500ms +static const nsecs_t MIN_TIME_BETWEEN_USERACTIVITIES = 100 * 1000000L; // 100ms // ---------------------------------------------------------------------------- @@ -101,14 +101,6 @@ static void processReturn(const Return<void> &ret, const char* functionName) { } void android_server_PowerManagerService_userActivity(nsecs_t eventTime, int32_t eventType) { - // Tell the power HAL when user activity occurs. - gPowerHalMutex.lock(); - if (getPowerHal()) { - Return<void> ret = gPowerHal->powerHint(PowerHint::INTERACTION, 0); - processReturn(ret, "powerHint"); - } - gPowerHalMutex.unlock(); - if (gPowerManagerServiceObj) { // Throttle calls into user activity by event type. // We're a little conservative about argument checking here in case the caller @@ -123,6 +115,17 @@ void android_server_PowerManagerService_userActivity(nsecs_t eventTime, int32_t return; } gLastEventTime[eventType] = eventTime; + + + // Tell the power HAL when user activity occurs. + gPowerHalMutex.lock(); + if (getPowerHal()) { + Return<void> ret; + ret = gPowerHal->powerHint(PowerHint::INTERACTION, 0); + processReturn(ret, "powerHint"); + } + gPowerHalMutex.unlock(); + } JNIEnv* env = AndroidRuntime::getJNIEnv(); diff --git a/services/tests/notification/src/com/android/server/notification/NotificationManagerServiceTest.java b/services/tests/notification/src/com/android/server/notification/NotificationManagerServiceTest.java index 46c536c76d46..d7815a282d17 100644 --- a/services/tests/notification/src/com/android/server/notification/NotificationManagerServiceTest.java +++ b/services/tests/notification/src/com/android/server/notification/NotificationManagerServiceTest.java @@ -302,9 +302,9 @@ public class NotificationManagerServiceTest extends NotificationTestCase { mBinderService.enqueueNotificationWithTag(PKG, "opPkg", "tag", 0, generateNotificationRecord(null).getNotification(), 0); waitForIdle(); - StatusBarNotification[] notifs = - mBinderService.getActiveNotifications(PKG); + StatusBarNotification[] notifs = mBinderService.getActiveNotifications(PKG); assertEquals(1, notifs.length); + assertEquals(1, mNotificationManagerService.getNotificationRecordCount()); } @Test @@ -316,6 +316,7 @@ public class NotificationManagerServiceTest extends NotificationTestCase { StatusBarNotification[] notifs = mBinderService.getActiveNotifications(PKG); assertEquals(0, notifs.length); + assertEquals(0, mNotificationManagerService.getNotificationRecordCount()); } @Test @@ -330,6 +331,7 @@ public class NotificationManagerServiceTest extends NotificationTestCase { StatusBarNotification[] notifs = mBinderService.getActiveNotifications(PKG); assertEquals(0, notifs.length); + assertEquals(0, mNotificationManagerService.getNotificationRecordCount()); } @Test @@ -342,6 +344,7 @@ public class NotificationManagerServiceTest extends NotificationTestCase { StatusBarNotification[] notifs = mBinderService.getActiveNotifications(sbn.getPackageName()); assertEquals(0, notifs.length); + assertEquals(0, mNotificationManagerService.getNotificationRecordCount()); } @Test @@ -354,6 +357,43 @@ public class NotificationManagerServiceTest extends NotificationTestCase { StatusBarNotification[] notifs = mBinderService.getActiveNotifications(sbn.getPackageName()); assertEquals(0, notifs.length); + assertEquals(0, mNotificationManagerService.getNotificationRecordCount()); + } + + @Test + public void testUserInitiatedClearAll_noLeak() throws Exception { + final NotificationRecord n = generateNotificationRecord( + mTestNotificationChannel, 1, "group", true); + + mBinderService.enqueueNotificationWithTag(PKG, "opPkg", "tag", + n.sbn.getId(), n.sbn.getNotification(), n.sbn.getUserId()); + waitForIdle(); + + mNotificationManagerService.mNotificationDelegate.onClearAll(uid, Binder.getCallingPid(), + n.getUserId()); + waitForIdle(); + StatusBarNotification[] notifs = + mBinderService.getActiveNotifications(n.sbn.getPackageName()); + assertEquals(0, notifs.length); + assertEquals(0, mNotificationManagerService.getNotificationRecordCount()); + } + + @Test + public void testCancelAllNotificationsCancelsChildren() throws Exception { + final NotificationRecord parent = generateNotificationRecord( + mTestNotificationChannel, 1, "group1", true); + final NotificationRecord child = generateNotificationRecord( + mTestNotificationChannel, 2, "group1", false); + + mBinderService.enqueueNotificationWithTag(PKG, "opPkg", "tag", + parent.sbn.getId(), parent.sbn.getNotification(), parent.sbn.getUserId()); + mBinderService.enqueueNotificationWithTag(PKG, "opPkg", "tag", + child.sbn.getId(), child.sbn.getNotification(), child.sbn.getUserId()); + waitForIdle(); + + mBinderService.cancelAllNotifications(PKG, parent.sbn.getUserId()); + waitForIdle(); + assertEquals(0, mNotificationManagerService.getNotificationRecordCount()); } @Test @@ -365,6 +405,8 @@ public class NotificationManagerServiceTest extends NotificationTestCase { } mBinderService.cancelAllNotifications(PKG, sbn.getUserId()); waitForIdle(); + + assertEquals(0, mNotificationManagerService.getNotificationRecordCount()); } @Test @@ -391,6 +433,8 @@ public class NotificationManagerServiceTest extends NotificationTestCase { parentAsChild.sbn.getId(), parentAsChild.sbn.getNotification(), parentAsChild.sbn.getUserId()); waitForIdle(); + + assertEquals(0, mNotificationManagerService.getNotificationRecordCount()); } @Test @@ -404,6 +448,7 @@ public class NotificationManagerServiceTest extends NotificationTestCase { StatusBarNotification[] notifs = mBinderService.getActiveNotifications(sbn.getPackageName()); assertEquals(1, notifs.length); + assertEquals(1, mNotificationManagerService.getNotificationRecordCount()); } @Test @@ -417,6 +462,7 @@ public class NotificationManagerServiceTest extends NotificationTestCase { StatusBarNotification[] notifs = mBinderService.getActiveNotifications(sbn.getPackageName()); assertEquals(1, notifs.length); + assertEquals(1, mNotificationManagerService.getNotificationRecordCount()); } @Test @@ -429,6 +475,7 @@ public class NotificationManagerServiceTest extends NotificationTestCase { StatusBarNotification[] notifs = mBinderService.getActiveNotifications(sbn.getPackageName()); assertEquals(0, notifs.length); + assertEquals(0, mNotificationManagerService.getNotificationRecordCount()); } @Test @@ -442,6 +489,7 @@ public class NotificationManagerServiceTest extends NotificationTestCase { StatusBarNotification[] notifs = mBinderService.getActiveNotifications(sbn.getPackageName()); assertEquals(1, notifs.length); + assertEquals(1, mNotificationManagerService.getNotificationRecordCount()); } @Test @@ -471,6 +519,7 @@ public class NotificationManagerServiceTest extends NotificationTestCase { mBinderService.cancelNotificationWithTag(PKG, "tag", sbn.getId(), sbn.getUserId()); waitForIdle(); assertEquals(0, mBinderService.getActiveNotifications(sbn.getPackageName()).length); + assertEquals(0, mNotificationManagerService.getNotificationRecordCount()); } @Test |