diff options
35 files changed, 388 insertions, 246 deletions
diff --git a/cmds/statsd/src/atoms.proto b/cmds/statsd/src/atoms.proto index aed0bd5f3e4e..db1cb4b1a310 100644 --- a/cmds/statsd/src/atoms.proto +++ b/cmds/statsd/src/atoms.proto @@ -3960,7 +3960,7 @@ message ProcessMemoryState { optional int64 page_major_fault = 5; // RSS - // Value is read from /proc/PID/stat, field 24. Or from memory.stat, field + // Value is read from /proc/PID/status. Or from memory.stat, field // total_rss if per-app memory cgroups are enabled. optional int64 rss_in_bytes = 6; @@ -3980,6 +3980,9 @@ message ProcessMemoryState { // Elapsed real time when the process started. // Value is read from /proc/PID/stat, field 22. 0 if read from per-app memory cgroups. optional int64 start_time_nanos = 10; + + // Anonymous page size plus swap size. Values are read from /proc/PID/status. + optional int32 anon_rss_and_swap_in_kilobytes = 11; } /* @@ -4002,7 +4005,7 @@ message NativeProcessMemoryState { optional int64 page_major_fault = 4; // RSS - // Value read from /proc/PID/stat, field 24. + // Value read from /proc/PID/status. optional int64 rss_in_bytes = 5; // Deprecated: use ProcessMemoryHighWaterMark atom instead. Always 0. @@ -4015,6 +4018,9 @@ message NativeProcessMemoryState { // SWAP // Value read from /proc/PID/status, field VmSwap. optional int64 swap_in_bytes = 8; + + // Anonymous page size plus swap size. Values are read from /proc/PID/status. + optional int32 anon_rss_and_swap_in_kilobytes = 9; } /* diff --git a/core/java/android/app/ActivityManagerInternal.java b/core/java/android/app/ActivityManagerInternal.java index 0b25b2e2f254..8508c2c95666 100644 --- a/core/java/android/app/ActivityManagerInternal.java +++ b/core/java/android/app/ActivityManagerInternal.java @@ -168,20 +168,13 @@ public abstract class ActivityManagerInternal { public abstract boolean isUidActive(int uid); /** - * Returns a list that contains the memory stats for currently running processes. + * Returns a list of running processes along with corresponding uids, pids and their oom score. * * Only processes managed by ActivityManagerService are included. */ public abstract List<ProcessMemoryState> getMemoryStateForProcesses(); /** - * Returns a list that contains the memory high-water mark for currently running processes. - * - * Only processes managed by ActivityManagerService are included. - */ - public abstract List<ProcessMemoryHighWaterMark> getMemoryHighWaterMarkForProcesses(); - - /** * Checks to see if the calling pid is allowed to handle the user. Returns adjusted user id as * needed. */ diff --git a/core/java/android/app/ProcessMemoryHighWaterMark.java b/core/java/android/app/ProcessMemoryHighWaterMark.java deleted file mode 100644 index d1cae94f02b4..000000000000 --- a/core/java/android/app/ProcessMemoryHighWaterMark.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (C) 2018 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.app; - -import android.os.Parcel; -import android.os.Parcelable; - -/** - * The memory high-water mark value for a process. - * {@hide} - */ -public final class ProcessMemoryHighWaterMark implements Parcelable { - public final int uid; - public final String processName; - public final long rssHighWaterMarkInBytes; - - public ProcessMemoryHighWaterMark(int uid, String processName, long rssHighWaterMarkInBytes) { - this.uid = uid; - this.processName = processName; - this.rssHighWaterMarkInBytes = rssHighWaterMarkInBytes; - } - - private ProcessMemoryHighWaterMark(Parcel in) { - uid = in.readInt(); - processName = in.readString(); - rssHighWaterMarkInBytes = in.readLong(); - } - - public static final @android.annotation.NonNull Creator<ProcessMemoryHighWaterMark> CREATOR = - new Creator<ProcessMemoryHighWaterMark>() { - @Override - public ProcessMemoryHighWaterMark createFromParcel(Parcel in) { - return new ProcessMemoryHighWaterMark(in); - } - - @Override - public ProcessMemoryHighWaterMark[] newArray(int size) { - return new ProcessMemoryHighWaterMark[size]; - } - }; - - @Override - public int describeContents() { - return 0; - } - - @Override - public void writeToParcel(Parcel parcel, int flags) { - parcel.writeInt(uid); - parcel.writeString(processName); - parcel.writeLong(rssHighWaterMarkInBytes); - } -} diff --git a/core/java/android/app/ProcessMemoryState.java b/core/java/android/app/ProcessMemoryState.java index e28d79c2565b..24914a6af557 100644 --- a/core/java/android/app/ProcessMemoryState.java +++ b/core/java/android/app/ProcessMemoryState.java @@ -20,44 +20,27 @@ import android.os.Parcel; import android.os.Parcelable; /** - * The memory stats for a process. + * State (oom score) for processes known to activity manager. * {@hide} */ public final class ProcessMemoryState implements Parcelable { public final int uid; + public final int pid; public final String processName; public final int oomScore; - public final long pgfault; - public final long pgmajfault; - public final long rssInBytes; - public final long cacheInBytes; - public final long swapInBytes; - public final long startTimeNanos; - public ProcessMemoryState(int uid, String processName, int oomScore, long pgfault, - long pgmajfault, long rssInBytes, long cacheInBytes, - long swapInBytes, long startTimeNanos) { + public ProcessMemoryState(int uid, int pid, String processName, int oomScore) { this.uid = uid; + this.pid = pid; this.processName = processName; this.oomScore = oomScore; - this.pgfault = pgfault; - this.pgmajfault = pgmajfault; - this.rssInBytes = rssInBytes; - this.cacheInBytes = cacheInBytes; - this.swapInBytes = swapInBytes; - this.startTimeNanos = startTimeNanos; } private ProcessMemoryState(Parcel in) { uid = in.readInt(); + pid = in.readInt(); processName = in.readString(); oomScore = in.readInt(); - pgfault = in.readLong(); - pgmajfault = in.readLong(); - rssInBytes = in.readLong(); - cacheInBytes = in.readLong(); - swapInBytes = in.readLong(); - startTimeNanos = in.readLong(); } public static final @android.annotation.NonNull Creator<ProcessMemoryState> CREATOR = new Creator<ProcessMemoryState>() { @@ -80,13 +63,8 @@ public final class ProcessMemoryState implements Parcelable { @Override public void writeToParcel(Parcel parcel, int i) { parcel.writeInt(uid); + parcel.writeInt(pid); parcel.writeString(processName); parcel.writeInt(oomScore); - parcel.writeLong(pgfault); - parcel.writeLong(pgmajfault); - parcel.writeLong(rssInBytes); - parcel.writeLong(cacheInBytes); - parcel.writeLong(swapInBytes); - parcel.writeLong(startTimeNanos); } } diff --git a/core/java/android/view/contentcapture/MainContentCaptureSession.java b/core/java/android/view/contentcapture/MainContentCaptureSession.java index c5a5f7360321..cee79439d1b3 100644 --- a/core/java/android/view/contentcapture/MainContentCaptureSession.java +++ b/core/java/android/view/contentcapture/MainContentCaptureSession.java @@ -428,14 +428,16 @@ public final class MainContentCaptureSession extends ContentCaptureSession { } final int flushFrequencyMs; - if (reason == FLUSH_REASON_IDLE_TIMEOUT) { - flushFrequencyMs = mManager.mOptions.idleFlushingFrequencyMs; - } else if (reason == FLUSH_REASON_TEXT_CHANGE_TIMEOUT) { + if (reason == FLUSH_REASON_TEXT_CHANGE_TIMEOUT) { flushFrequencyMs = mManager.mOptions.textChangeFlushingFrequencyMs; } else { - Log.e(TAG, "handleScheduleFlush(" + getDebugState(reason) + "): not called with a " - + "timeout reason."); - return; + if (reason != FLUSH_REASON_IDLE_TIMEOUT) { + if (sDebug) { + Log.d(TAG, "handleScheduleFlush(" + getDebugState(reason) + "): not a timeout " + + "reason because mDirectServiceInterface is not ready yet"); + } + } + flushFrequencyMs = mManager.mOptions.idleFlushingFrequencyMs; } mNextFlush = System.currentTimeMillis() + flushFrequencyMs; diff --git a/core/res/res/values-es-rUS/strings.xml b/core/res/res/values-es-rUS/strings.xml index 157acd90fd23..daa205565229 100644 --- a/core/res/res/values-es-rUS/strings.xml +++ b/core/res/res/values-es-rUS/strings.xml @@ -1667,7 +1667,7 @@ <string name="accessibility_shortcut_spoken_feedback" msgid="8376923232350078434">"Mantén presionadas ambas teclas de volumen durante tres segundos para usar <xliff:g id="SERVICE_NAME">%1$s</xliff:g>"</string> <string name="accessibility_button_prompt_text" msgid="1176658502969738564">"Elige un servicio para usar cuando presiones el botón de accesibilidad:"</string> <string name="accessibility_gesture_prompt_text" msgid="8259145549733019401">"Elige un servicio para usar cuando realices el gesto de accesibilidad (deslizar dos dedos hacia arriba desde la parte inferior de la pantalla):"</string> - <string name="accessibility_gesture_3finger_prompt_text" msgid="1041435574275047665">"Elige un servicio para usar cuando realices el gesto de accesibilidad (deslizar tres dedos hacia arriba desde la parte inferior de la pantalla):"</string> + <string name="accessibility_gesture_3finger_prompt_text" msgid="1041435574275047665">"Elige el servicio que se usará cuando realices el gesto de accesibilidad (deslizar tres dedos hacia arriba desde la parte inferior de la pantalla):"</string> <string name="accessibility_button_instructional_text" msgid="7003212763213614833">"Para cambiar de servicio, mantén presionado el botón de accesibilidad."</string> <string name="accessibility_gesture_instructional_text" msgid="5261788874937410950">"Para cambiar de servicio, desliza dos dedos hacia arriba y mantén presionado."</string> <string name="accessibility_gesture_3finger_instructional_text" msgid="4969448938984394550">"Para cambiar de servicio, desliza tres dedos hacia arriba y mantén presionado."</string> diff --git a/core/res/res/values-gl/strings.xml b/core/res/res/values-gl/strings.xml index d4522f543df0..e4d9a9313f31 100644 --- a/core/res/res/values-gl/strings.xml +++ b/core/res/res/values-gl/strings.xml @@ -567,7 +567,7 @@ <string name="face_acquired_too_right" msgid="3667075962661863218">"Move o teléfono cara á esquerda."</string> <string name="face_acquired_too_left" msgid="3148242963894703424">"Move o teléfono cara á dereita."</string> <string name="face_acquired_poor_gaze" msgid="5606479370806754905">"Mira o dispositivo de forma máis directa."</string> - <string name="face_acquired_not_detected" msgid="4885504661626728809">"Non se pode ver a túa cara. Mira o teléfono."</string> + <string name="face_acquired_not_detected" msgid="4885504661626728809">"Non se ve a túa cara. Mira para o teléfono"</string> <string name="face_acquired_too_much_motion" msgid="3149332171102108851">"Demasiado movemento. Non movas o teléfono."</string> <string name="face_acquired_recalibrate" msgid="8077949502893707539">"Volve rexistrar a túa cara."</string> <string name="face_acquired_too_different" msgid="7663983770123789694">"Xa non se pode recoñecer a cara. Téntao de novo."</string> diff --git a/data/keyboards/Vendor_045e_Product_02e3.kl b/data/keyboards/Vendor_045e_Product_02e3.kl new file mode 100644 index 000000000000..0a6e7d75c2a7 --- /dev/null +++ b/data/keyboards/Vendor_045e_Product_02e3.kl @@ -0,0 +1,56 @@ +# Copyright (C) 2019 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. + +# +# Microsoft X-Box One Elite Pad - Model 1698 - USB +# + +# Mapping according to https://developer.android.com/training/game-controllers/controller-input.html + +key 0x130 BUTTON_A +key 0x131 BUTTON_B +key 0x133 BUTTON_X +key 0x134 BUTTON_Y + +key 0x136 BUTTON_L1 +key 0x137 BUTTON_R1 + +# Triggers. +axis 0x02 LTRIGGER +axis 0x05 RTRIGGER + +# Left stick +axis 0x00 X +axis 0x01 Y +# Right stick +axis 0x03 Z +axis 0x04 RZ + +key 0x13d BUTTON_THUMBL +key 0x13e BUTTON_THUMBR + +# Hat. +axis 0x10 HAT_X +axis 0x11 HAT_Y + + +# Mapping according to https://www.kernel.org/doc/Documentation/input/gamepad.txt + +# Two overlapping rectangles +key 0x13a BUTTON_SELECT +# Hamburger - 3 parallel lines +key 0x13b BUTTON_START + +# Xbox key +key 0x13c BUTTON_MODE diff --git a/media/apex/java/android/media/Media2Utils.java b/media/apex/java/android/media/Media2Utils.java index 5fd61915b4aa..a87e9676d017 100644 --- a/media/apex/java/android/media/Media2Utils.java +++ b/media/apex/java/android/media/Media2Utils.java @@ -75,5 +75,4 @@ public class Media2Utils { Log.v(TAG, "storeCookies: cookieHandler: " + cookieHandler + " Cookies: " + cookies); } - } diff --git a/media/apex/java/android/media/MediaController2.java b/media/apex/java/android/media/MediaController2.java index 9848f1a10a54..63a4510e7fe7 100644 --- a/media/apex/java/android/media/MediaController2.java +++ b/media/apex/java/android/media/MediaController2.java @@ -100,7 +100,7 @@ public class MediaController2 implements AutoCloseable { * @param callback controller callback to receive changes in. */ MediaController2(@NonNull Context context, @NonNull Session2Token token, - @Nullable Bundle connectionHints, @NonNull Executor executor, + @NonNull Bundle connectionHints, @NonNull Executor executor, @NonNull ControllerCallback callback) { if (context == null) { throw new IllegalArgumentException("context shouldn't be null"); @@ -259,7 +259,16 @@ public class MediaController2 implements AutoCloseable { Session2CommandGroup allowedCommands = connectionResult.getParcelable(KEY_ALLOWED_COMMANDS); boolean playbackActive = connectionResult.getBoolean(KEY_PLAYBACK_ACTIVE); + Bundle tokenExtras = connectionResult.getBundle(KEY_TOKEN_EXTRAS); + if (tokenExtras == null) { + Log.w(TAG, "extras shouldn't be null."); + tokenExtras = Bundle.EMPTY; + } else if (MediaSession2.hasCustomParcelable(tokenExtras)) { + Log.w(TAG, "extras contain custom parcelable. Ignoring."); + tokenExtras = Bundle.EMPTY; + } + if (DEBUG) { Log.d(TAG, "notifyConnected sessionBinder=" + sessionBinder + ", allowedCommands=" + allowedCommands); @@ -343,7 +352,7 @@ public class MediaController2 implements AutoCloseable { } } - private Bundle createConnectionRequest(@Nullable Bundle connectionHints) { + private Bundle createConnectionRequest(@NonNull Bundle connectionHints) { Bundle connectionRequest = new Bundle(); connectionRequest.putString(KEY_PACKAGE_NAME, mContext.getPackageName()); connectionRequest.putInt(KEY_PID, Process.myPid()); @@ -351,7 +360,7 @@ public class MediaController2 implements AutoCloseable { return connectionRequest; } - private boolean requestConnectToSession(@Nullable Bundle connectionHints) { + private boolean requestConnectToSession(@NonNull Bundle connectionHints) { Session2Link sessionBinder = mSessionToken.getSessionLink(); Bundle connectionRequest = createConnectionRequest(connectionHints); try { @@ -430,6 +439,9 @@ public class MediaController2 implements AutoCloseable { * <p> * {@code connectionHints} is a session-specific argument to send to the session when * connecting. The contents of this bundle may affect the connection result. + * <p> + * An {@link IllegalArgumentException} will be thrown if the bundle contains any + * non-framework Parcelable objects. * * @param connectionHints a bundle which contains the connection hints * @return The Builder to allow chaining @@ -439,6 +451,10 @@ public class MediaController2 implements AutoCloseable { if (connectionHints == null) { throw new IllegalArgumentException("connectionHints shouldn't be null"); } + if (MediaSession2.hasCustomParcelable(connectionHints)) { + throw new IllegalArgumentException("connectionHints shouldn't contain any custom " + + "parcelables"); + } mConnectionHints = new Bundle(connectionHints); return this; } @@ -477,6 +493,9 @@ public class MediaController2 implements AutoCloseable { if (mCallback == null) { mCallback = new ControllerCallback() {}; } + if (mConnectionHints == null) { + mConnectionHints = Bundle.EMPTY; + } return new MediaController2( mContext, mToken, mConnectionHints, mCallbackExecutor, mCallback); } diff --git a/media/apex/java/android/media/MediaSession2.java b/media/apex/java/android/media/MediaSession2.java index 081911896c04..b3edf3f50866 100644 --- a/media/apex/java/android/media/MediaSession2.java +++ b/media/apex/java/android/media/MediaSession2.java @@ -34,8 +34,10 @@ import android.content.Context; import android.content.Intent; import android.media.session.MediaSessionManager; import android.media.session.MediaSessionManager.RemoteUserInfo; +import android.os.BadParcelableException; import android.os.Bundle; import android.os.Handler; +import android.os.Parcel; import android.os.Process; import android.os.ResultReceiver; import android.util.ArrayMap; @@ -97,7 +99,7 @@ public class MediaSession2 implements AutoCloseable { MediaSession2(@NonNull Context context, @NonNull String id, PendingIntent sessionActivity, @NonNull Executor callbackExecutor, @NonNull SessionCallback callback, - Bundle tokenExtras) { + @NonNull Bundle tokenExtras) { synchronized (MediaSession2.class) { if (SESSION_ID_LIST.contains(id)) { throw new IllegalStateException("Session ID must be unique. ID=" + id); @@ -276,6 +278,35 @@ public class MediaSession2 implements AutoCloseable { return controllers; } + /** + * Returns whether the given bundle includes non-framework Parcelables. + */ + static boolean hasCustomParcelable(@Nullable Bundle bundle) { + if (bundle == null) { + return false; + } + + // Try writing the bundle to parcel, and read it with framework classloader. + Parcel parcel = null; + try { + parcel = Parcel.obtain(); + parcel.writeBundle(bundle); + parcel.setDataPosition(0); + Bundle out = parcel.readBundle(null); + + // Calling Bundle#size() will trigger Bundle#unparcel(). + out.size(); + } catch (BadParcelableException e) { + Log.d(TAG, "Custom parcelable in bundle.", e); + return true; + } finally { + if (parcel != null) { + parcel.recycle(); + } + } + return false; + } + boolean isClosed() { synchronized (mLock) { return mClosed; @@ -309,11 +340,21 @@ public class MediaSession2 implements AutoCloseable { String callingPkg = connectionRequest.getString(KEY_PACKAGE_NAME); RemoteUserInfo remoteUserInfo = new RemoteUserInfo(callingPkg, callingPid, callingUid); + + Bundle connectionHints = connectionRequest.getBundle(KEY_CONNECTION_HINTS); + if (connectionHints == null) { + Log.w(TAG, "connectionHints shouldn't be null."); + connectionHints = Bundle.EMPTY; + } else if (hasCustomParcelable(connectionHints)) { + Log.w(TAG, "connectionHints contain custom parcelable. Ignoring."); + connectionHints = Bundle.EMPTY; + } + final ControllerInfo controllerInfo = new ControllerInfo( remoteUserInfo, mSessionManager.isTrustedForMediaControl(remoteUserInfo), controller, - connectionRequest.getBundle(KEY_CONNECTION_HINTS)); + connectionHints); mCallbackExecutor.execute(() -> { boolean connected = false; try { @@ -516,7 +557,8 @@ public class MediaSession2 implements AutoCloseable { /** * Set extras for the session token. If null or not set, {@link Session2Token#getExtras()} - * will return {@link Bundle#EMPTY}. + * will return an empty {@link Bundle}. An {@link IllegalArgumentException} will be thrown + * if the bundle contains any non-framework Parcelable objects. * * @return The Builder to allow chaining * @see Session2Token#getExtras() @@ -526,7 +568,11 @@ public class MediaSession2 implements AutoCloseable { if (extras == null) { throw new NullPointerException("extras shouldn't be null"); } - mExtras = extras; + if (hasCustomParcelable(extras)) { + throw new IllegalArgumentException( + "extras shouldn't contain any custom parcelables"); + } + mExtras = new Bundle(extras); return this; } @@ -548,6 +594,9 @@ public class MediaSession2 implements AutoCloseable { if (mId == null) { mId = ""; } + if (mExtras == null) { + mExtras = Bundle.EMPTY; + } MediaSession2 session2 = new MediaSession2(mContext, mId, mSessionActivity, mCallbackExecutor, mCallback, mExtras); @@ -596,7 +645,7 @@ public class MediaSession2 implements AutoCloseable { * connection result. */ ControllerInfo(@NonNull RemoteUserInfo remoteUserInfo, boolean trusted, - @Nullable Controller2Link controllerBinder, @Nullable Bundle connectionHints) { + @Nullable Controller2Link controllerBinder, @NonNull Bundle connectionHints) { mRemoteUserInfo = remoteUserInfo; mIsTrusted = trusted; mControllerBinder = controllerBinder; @@ -629,11 +678,11 @@ public class MediaSession2 implements AutoCloseable { } /** - * @return connection hints sent from controller, or {@link Bundle#EMPTY} if none. + * @return connection hints sent from controller. */ @NonNull public Bundle getConnectionHints() { - return mConnectionHints == null ? Bundle.EMPTY : new Bundle(mConnectionHints); + return new Bundle(mConnectionHints); } /** diff --git a/media/apex/java/android/media/MediaSession2Service.java b/media/apex/java/android/media/MediaSession2Service.java index b8bf3842aae8..ee584e5eac30 100644 --- a/media/apex/java/android/media/MediaSession2Service.java +++ b/media/apex/java/android/media/MediaSession2Service.java @@ -378,12 +378,22 @@ public abstract class MediaSession2Service extends Service { callingPkg, pid == 0 ? connectionRequest.getInt(KEY_PID) : pid, uid); + + Bundle connectionHints = connectionRequest.getBundle(KEY_CONNECTION_HINTS); + if (connectionHints == null) { + Log.w(TAG, "connectionHints shouldn't be null."); + connectionHints = Bundle.EMPTY; + } else if (MediaSession2.hasCustomParcelable(connectionHints)) { + Log.w(TAG, "connectionHints contain custom parcelable. Ignoring."); + connectionHints = Bundle.EMPTY; + } + final ControllerInfo controllerInfo = new ControllerInfo( remoteUserInfo, service.getMediaSessionManager() .isTrustedForMediaControl(remoteUserInfo), caller, - connectionRequest.getBundle(KEY_CONNECTION_HINTS)); + connectionHints); if (DEBUG) { Log.d(TAG, "Handling incoming connection request from the" diff --git a/media/apex/java/android/media/Session2Token.java b/media/apex/java/android/media/Session2Token.java index d7cb9787cf08..6d499fa88815 100644 --- a/media/apex/java/android/media/Session2Token.java +++ b/media/apex/java/android/media/Session2Token.java @@ -118,11 +118,11 @@ public final class Session2Token implements Parcelable { mUid = uid; mType = TYPE_SESSION_SERVICE; mSessionLink = null; - mExtras = null; + mExtras = Bundle.EMPTY; } Session2Token(int uid, int type, String packageName, Session2Link sessionLink, - Bundle tokenExtras) { + @NonNull Bundle tokenExtras) { mUid = uid; mType = type; mPackageName = packageName; @@ -139,7 +139,16 @@ public final class Session2Token implements Parcelable { mServiceName = in.readString(); mSessionLink = in.readParcelable(null); mComponentName = ComponentName.unflattenFromString(in.readString()); - mExtras = in.readBundle(); + + Bundle extras = in.readBundle(); + if (extras == null) { + Log.w(TAG, "extras shouldn't be null."); + extras = Bundle.EMPTY; + } else if (MediaSession2.hasCustomParcelable(extras)) { + Log.w(TAG, "extras contain custom parcelable. Ignoring."); + extras = Bundle.EMPTY; + } + mExtras = extras; } @Override @@ -220,7 +229,7 @@ public final class Session2Token implements Parcelable { */ @NonNull public Bundle getExtras() { - return mExtras == null ? Bundle.EMPTY : mExtras; + return new Bundle(mExtras); } Session2Link getSessionLink() { diff --git a/media/java/android/media/session/MediaController.java b/media/java/android/media/session/MediaController.java index c1c7fcac0a8d..1fc4f7d59ca5 100644 --- a/media/java/android/media/session/MediaController.java +++ b/media/java/android/media/session/MediaController.java @@ -414,7 +414,7 @@ public final class MediaController { /** * Gets the additional session information which was set when the session was created. * - * @return The additional session information, or {@link Bundle#EMPTY} if not set. + * @return The additional session information, or an empty {@link Bundle} if not set. */ @NonNull public Bundle getSessionInfo() { @@ -430,6 +430,10 @@ public final class MediaController { } if (mSessionInfo == null) { + Log.w(TAG, "sessionInfo shouldn't be null."); + mSessionInfo = Bundle.EMPTY; + } else if (MediaSession.hasCustomParcelable(mSessionInfo)) { + Log.w(TAG, "sessionInfo contains custom parcelable. Ignoring."); mSessionInfo = Bundle.EMPTY; } return new Bundle(mSessionInfo); diff --git a/media/java/android/media/session/MediaSession.java b/media/java/android/media/session/MediaSession.java index c4085f876136..e11715ff7299 100644 --- a/media/java/android/media/session/MediaSession.java +++ b/media/java/android/media/session/MediaSession.java @@ -32,6 +32,7 @@ import android.media.Rating; import android.media.VolumeProvider; import android.media.session.MediaSessionManager.RemoteUserInfo; import android.net.Uri; +import android.os.BadParcelableException; import android.os.Bundle; import android.os.Handler; import android.os.Looper; @@ -168,6 +169,8 @@ public final class MediaSession { * @param sessionInfo A bundle for additional information about this session. * Controllers can get this information by calling * {@link MediaController#getSessionInfo()}. + * An {@link IllegalArgumentException} will be thrown if this contains + * any non-framework Parcelable objects. */ public MediaSession(@NonNull Context context, @NonNull String tag, @Nullable Bundle sessionInfo) { @@ -177,6 +180,11 @@ public final class MediaSession { if (TextUtils.isEmpty(tag)) { throw new IllegalArgumentException("tag cannot be null or empty"); } + if (hasCustomParcelable(sessionInfo)) { + throw new IllegalArgumentException("sessionInfo shouldn't contain any custom " + + "parcelables"); + } + mMaxBitmapSize = context.getResources().getDimensionPixelSize( com.android.internal.R.dimen.config_mediaMetadataBitmapMaxSize); mCbStub = new CallbackStub(this); @@ -600,6 +608,35 @@ public final class MediaSession { return false; } + /** + * Returns whether the given bundle includes non-framework Parcelables. + */ + static boolean hasCustomParcelable(@Nullable Bundle bundle) { + if (bundle == null) { + return false; + } + + // Try writing the bundle to parcel, and read it with framework classloader. + Parcel parcel = null; + try { + parcel = Parcel.obtain(); + parcel.writeBundle(bundle); + parcel.setDataPosition(0); + Bundle out = parcel.readBundle(null); + + // Calling Bundle#size() will trigger Bundle#unparcel(). + out.size(); + } catch (BadParcelableException e) { + Log.d(TAG, "Custom parcelable in bundle.", e); + return true; + } finally { + if (parcel != null) { + parcel.recycle(); + } + } + return false; + } + void dispatchPrepare(RemoteUserInfo caller) { postToCallback(caller, CallbackMessageHandler.MSG_PREPARE, null, null); } diff --git a/media/jni/Android.bp b/media/jni/Android.bp index db6a8588e2e6..10f76b07c749 100644 --- a/media/jni/Android.bp +++ b/media/jni/Android.bp @@ -58,9 +58,6 @@ cc_library_shared { "android.hardware.cas.native@1.0", "android.hidl.memory@1.0", "android.hidl.token@1.0-utils", - - // to speed up later users of this library - "libsfplugin_ccodec", ], header_libs: ["libhardware_headers"], diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml index 712ce6eef761..f60613ae4a83 100644 --- a/packages/SystemUI/res/values/strings.xml +++ b/packages/SystemUI/res/values/strings.xml @@ -887,10 +887,10 @@ <string name="quick_settings_night_secondary_label_on_at">On at <xliff:g id="time" example="10 pm">%s</xliff:g></string> <!-- QuickSettings: Secondary text for when the Night Light or some other tile will be on until some user-selected time. [CHAR LIMIT=20] --> <string name="quick_settings_secondary_label_until">Until <xliff:g id="time" example="7 am">%s</xliff:g></string> - <!-- QuickSettings: Label for the toggle to activate Dark theme (A.K.A Dark Mode). [CHAR LIMIT=20] --> - <string name="quick_settings_ui_mode_night_label">Dark Theme</string> - <!-- QuickSettings: Label for the Dark theme tile when enabled by battery saver. [CHAR LIMIT=40] --> - <string name="quick_settings_ui_mode_night_label_battery_saver">Dark Theme\nBattery saver</string> + <!-- QuickSettings: Label for the toggle to activate dark theme (A.K.A Dark Mode). [CHAR LIMIT=20] --> + <string name="quick_settings_ui_mode_night_label">Dark theme</string> + <!-- QuickSettings: Label for the dark theme tile when enabled by battery saver. [CHAR LIMIT=40] --> + <string name="quick_settings_ui_mode_night_label_battery_saver">Dark theme\nBattery saver</string> <!-- QuickSettings: NFC tile [CHAR LIMIT=NONE] --> <string name="quick_settings_nfc_label">NFC</string> diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java index d3fe2c36c6b0..15ed0d259f5d 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java @@ -2329,6 +2329,13 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener { mUserFaceAuthenticated.clear(); mTrustManager.clearAllBiometricRecognized(BiometricSourceType.FINGERPRINT); mTrustManager.clearAllBiometricRecognized(BiometricSourceType.FACE); + + for (int i = 0; i < mCallbacks.size(); i++) { + KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get(); + if (cb != null) { + cb.onBiometricsCleared(); + } + } } public boolean isSimPinVoiceSecure() { diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java index 8696bb769bbd..0fef755b5aba 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java @@ -314,4 +314,9 @@ public class KeyguardUpdateMonitorCallback { */ public void onLogoutEnabledChanged() { } + /** + * Called when authenticated biometrics are cleared. + */ + public void onBiometricsCleared() { } + } diff --git a/packages/SystemUI/src/com/android/systemui/assist/ui/InvocationLightsView.java b/packages/SystemUI/src/com/android/systemui/assist/ui/InvocationLightsView.java index 5ad6b80bfaea..43e7045511c5 100644 --- a/packages/SystemUI/src/com/android/systemui/assist/ui/InvocationLightsView.java +++ b/packages/SystemUI/src/com/android/systemui/assist/ui/InvocationLightsView.java @@ -92,15 +92,14 @@ public class InvocationLightsView extends View mPaint.setStrokeJoin(Paint.Join.MITER); mPaint.setAntiAlias(true); - int cornerRadiusBottom = DisplayUtils.getCornerRadiusBottom(context); - int cornerRadiusTop = DisplayUtils.getCornerRadiusTop(context); + int displayWidth = DisplayUtils.getWidth(context); int displayHeight = DisplayUtils.getHeight(context); - CircularCornerPathRenderer cornerPathRenderer = new CircularCornerPathRenderer( - cornerRadiusBottom, cornerRadiusTop, displayWidth, displayHeight); - mGuide = new PerimeterPathGuide(context, cornerPathRenderer, + mGuide = new PerimeterPathGuide(context, createCornerPathRenderer(context), mStrokeWidth / 2, displayWidth, displayHeight); + int cornerRadiusBottom = DisplayUtils.getCornerRadiusBottom(context); + int cornerRadiusTop = DisplayUtils.getCornerRadiusTop(context); mViewHeight = Math.max(cornerRadiusBottom, cornerRadiusTop); final int dualToneDarkTheme = Utils.getThemeAttr(mContext, R.attr.darkIconTheme); @@ -243,6 +242,19 @@ public class InvocationLightsView extends View } /** + * Returns CornerPathRenderer to be used for rendering invocation lights. + * + * To render corners that aren't circular, override this method in a subclass. + */ + protected CornerPathRenderer createCornerPathRenderer(Context context) { + int displayWidth = DisplayUtils.getWidth(context); + int displayHeight = DisplayUtils.getHeight(context); + int cornerRadiusBottom = DisplayUtils.getCornerRadiusBottom(context); + int cornerRadiusTop = DisplayUtils.getCornerRadiusTop(context); + return new CircularCornerPathRenderer( + cornerRadiusBottom, cornerRadiusTop, displayWidth, displayHeight); + } + /** * Receives an intensity from 0 (lightest) to 1 (darkest) and sets the handle color * appropriately. Intention is to match the home handle color. */ diff --git a/packages/SystemUI/src/com/android/systemui/doze/DozeAuthRemover.java b/packages/SystemUI/src/com/android/systemui/doze/DozeAuthRemover.java new file mode 100644 index 000000000000..e6a9e47be71c --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/doze/DozeAuthRemover.java @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2019 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 com.android.systemui.doze; + +import android.content.Context; + +import com.android.keyguard.KeyguardUpdateMonitor; + +/** + * Controls removing Keyguard authorization when the phone goes to sleep. + */ +public class DozeAuthRemover implements DozeMachine.Part { + + KeyguardUpdateMonitor mKeyguardUpdateMonitor; + + public DozeAuthRemover(Context context) { + mKeyguardUpdateMonitor = KeyguardUpdateMonitor.getInstance(context); + } + + @Override + public void transitionTo(DozeMachine.State oldState, DozeMachine.State newState) { + if (newState == DozeMachine.State.DOZE || newState == DozeMachine.State.DOZE_AOD) { + int currentUser = KeyguardUpdateMonitor.getCurrentUser(); + if (mKeyguardUpdateMonitor.getUserUnlockedWithBiometric(currentUser)) { + mKeyguardUpdateMonitor.clearBiometricRecognized(); + } + } + } +} diff --git a/packages/SystemUI/src/com/android/systemui/doze/DozeFactory.java b/packages/SystemUI/src/com/android/systemui/doze/DozeFactory.java index 8694d2ad607c..fc3d1a52342f 100644 --- a/packages/SystemUI/src/com/android/systemui/doze/DozeFactory.java +++ b/packages/SystemUI/src/com/android/systemui/doze/DozeFactory.java @@ -71,7 +71,8 @@ public class DozeFactory { createDozeScreenBrightness(context, wrappedService, sensorManager, host, params, handler), new DozeWallpaperState(context), - new DozeDockHandler(context, machine, host, config, handler, dockManager) + new DozeDockHandler(context, machine, host, config, handler, dockManager), + new DozeAuthRemover(dozeService) }); return machine; diff --git a/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java b/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java index e5caf68c416e..99f9e99cf359 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java +++ b/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java @@ -746,6 +746,8 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis try { if (mOverviewProxy != null) { mOverviewProxy.onAssistantVisibilityChanged(visibility); + } else { + Log.e(TAG_OPS, "Failed to get overview proxy for assistant visibility."); } } catch (RemoteException e) { Log.e(TAG_OPS, "Failed to call onAssistantVisibilityChanged()", e); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java b/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java index 6d6f07481607..4be93df0e81a 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java @@ -81,6 +81,7 @@ public class KeyguardIndicationController implements StateListener, private static final int MSG_CLEAR_BIOMETRIC_MSG = 2; private static final int MSG_SWIPE_UP_TO_UNLOCK = 3; private static final long TRANSIENT_BIOMETRIC_ERROR_TIMEOUT = 1300; + private static final float BOUNCE_ANIMATION_FINAL_Y = 0f; private final Context mContext; private final ShadeController mShadeController; @@ -422,7 +423,6 @@ public class KeyguardIndicationController implements StateListener, int animateDownDuration = mContext.getResources().getInteger( R.integer.wired_charging_keyguard_text_animation_duration_down); textView.animate().cancel(); - float translation = textView.getTranslationY(); ViewClippingUtil.setClippingDeactivated(textView, true, mClippingParams); textView.animate() .translationYBy(yTranslation) @@ -438,7 +438,7 @@ public class KeyguardIndicationController implements StateListener, @Override public void onAnimationCancel(Animator animation) { - textView.setTranslationY(translation); + textView.setTranslationY(BOUNCE_ANIMATION_FINAL_Y); mCancelled = true; } @@ -452,15 +452,11 @@ public class KeyguardIndicationController implements StateListener, textView.animate() .setDuration(animateDownDuration) .setInterpolator(Interpolators.BOUNCE) - .translationY(translation) + .translationY(BOUNCE_ANIMATION_FINAL_Y) .setListener(new AnimatorListenerAdapter() { @Override - public void onAnimationCancel(Animator animation) { - textView.setTranslationY(translation); - } - - @Override public void onAnimationEnd(Animator animation) { + textView.setTranslationY(BOUNCE_ANIMATION_FINAL_Y); ViewClippingUtil.setClippingDeactivated(textView, false, mClippingParams); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSwipeHelper.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSwipeHelper.java index 8dd324b33287..4dfc343df283 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSwipeHelper.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSwipeHelper.java @@ -23,7 +23,6 @@ import android.content.Context; import android.graphics.Rect; import android.os.Handler; import android.service.notification.StatusBarNotification; -import android.util.Log; import android.view.MotionEvent; import android.view.View; @@ -313,8 +312,6 @@ class NotificationSwipeHelper extends SwipeHelper public void setTranslation(View v, float translate) { if (v instanceof ExpandableNotificationRow) { ((ExpandableNotificationRow) v).setTranslation(translate); - } else { - Log.wtf(TAG, "setTranslation should only be called on an ExpandableNotificationRow."); } } @@ -324,7 +321,6 @@ class NotificationSwipeHelper extends SwipeHelper return ((ExpandableNotificationRow) v).getTranslation(); } else { - Log.wtf(TAG, "getTranslation should only be called on an ExpandableNotificationRow."); return 0f; } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackStateAnimator.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackStateAnimator.java index 9f2f1ce93c3c..4f169eb50f88 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackStateAnimator.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackStateAnimator.java @@ -61,6 +61,7 @@ public class StackStateAnimator { public static final int DELAY_EFFECT_MAX_INDEX_DIFFERENCE = 2; public static final int ANIMATION_DELAY_HEADS_UP = 120; public static final int ANIMATION_DELAY_HEADS_UP_CLICKED= 120; + private static final int MAX_STAGGER_COUNT = 5; private final int mGoToFullShadeAppearingTranslation; private final int mPulsingAppearingTranslation; @@ -78,8 +79,6 @@ public class StackStateAnimator { private long mCurrentLength; private long mCurrentAdditionalDelay; - /** The current index for the last child which was not added in this event set. */ - private int mCurrentLastNotAddedIndex; private ValueAnimator mTopOverScrollAnimator; private ValueAnimator mBottomOverScrollAnimator; private int mHeadsUpAppearHeightBottom; @@ -137,7 +136,8 @@ public class StackStateAnimator { mAnimationFilter.applyCombination(mNewEvents); mCurrentAdditionalDelay = additionalDelay; mCurrentLength = NotificationStackScrollLayout.AnimationEvent.combineLength(mNewEvents); - mCurrentLastNotAddedIndex = findLastNotAddedIndex(); + // Used to stagger concurrent animations' delays and durations for visual effect + int animationStaggerCount = 0; for (int i = 0; i < childCount; i++) { final ExpandableView child = (ExpandableView) mHostLayout.getChildAt(i); @@ -147,7 +147,10 @@ public class StackStateAnimator { continue; } - initAnimationProperties(child, viewState); + if (mAnimationProperties.wasAdded(child) && animationStaggerCount < MAX_STAGGER_COUNT) { + animationStaggerCount++; + } + initAnimationProperties(child, viewState, animationStaggerCount); viewState.animateTo(child, mAnimationProperties); } if (!isRunning()) { @@ -161,10 +164,10 @@ public class StackStateAnimator { } private void initAnimationProperties(ExpandableView child, - ExpandableViewState viewState) { + ExpandableViewState viewState, int animationStaggerCount) { boolean wasAdded = mAnimationProperties.wasAdded(child); mAnimationProperties.duration = mCurrentLength; - adaptDurationWhenGoingToFullShade(child, viewState, wasAdded); + adaptDurationWhenGoingToFullShade(child, viewState, wasAdded, animationStaggerCount); mAnimationProperties.delay = 0; if (wasAdded || mAnimationFilter.hasDelays && (viewState.yTranslation != child.getTranslationY() @@ -173,16 +176,15 @@ public class StackStateAnimator { || viewState.height != child.getActualHeight() || viewState.clipTopAmount != child.getClipTopAmount())) { mAnimationProperties.delay = mCurrentAdditionalDelay - + calculateChildAnimationDelay(viewState); + + calculateChildAnimationDelay(viewState, animationStaggerCount); } } private void adaptDurationWhenGoingToFullShade(ExpandableView child, - ExpandableViewState viewState, boolean wasAdded) { + ExpandableViewState viewState, boolean wasAdded, int animationStaggerCount) { if (wasAdded && mAnimationFilter.hasGoToFullShadeEvent) { child.setTranslationY(child.getTranslationY() + mGoToFullShadeAppearingTranslation); - float longerDurationFactor = viewState.notGoneIndex - mCurrentLastNotAddedIndex; - longerDurationFactor = (float) Math.pow(longerDurationFactor, 0.7f); + float longerDurationFactor = (float) Math.pow(animationStaggerCount, 0.7f); mAnimationProperties.duration = ANIMATION_DURATION_APPEAR_DISAPPEAR + 50 + (long) (100 * longerDurationFactor); } @@ -213,25 +215,10 @@ public class StackStateAnimator { return true; } - private int findLastNotAddedIndex() { - int childCount = mHostLayout.getChildCount(); - for (int i = childCount - 1; i >= 0; i--) { - final ExpandableView child = (ExpandableView) mHostLayout.getChildAt(i); - - ExpandableViewState viewState = child.getViewState(); - if (viewState == null || child.getVisibility() == View.GONE) { - continue; - } - if (!mNewAddChildren.contains(child)) { - return viewState.notGoneIndex; - } - } - return -1; - } - - private long calculateChildAnimationDelay(ExpandableViewState viewState) { + private long calculateChildAnimationDelay(ExpandableViewState viewState, + int animationStaggerCount) { if (mAnimationFilter.hasGoToFullShadeEvent) { - return calculateDelayGoToFullShade(viewState); + return calculateDelayGoToFullShade(viewState, animationStaggerCount); } if (mAnimationFilter.customDelay != AnimationFilter.NO_DELAY) { return mAnimationFilter.customDelay; @@ -285,13 +272,13 @@ public class StackStateAnimator { return minDelay; } - private long calculateDelayGoToFullShade(ExpandableViewState viewState) { + private long calculateDelayGoToFullShade(ExpandableViewState viewState, + int animationStaggerCount) { int shelfIndex = mShelf.getNotGoneIndex(); float index = viewState.notGoneIndex; long result = 0; if (index > shelfIndex) { - float diff = index - shelfIndex; - diff = (float) Math.pow(diff, 0.7f); + float diff = (float) Math.pow(animationStaggerCount, 0.7f); result += (long) (diff * ANIMATION_DELAY_PER_ELEMENT_GO_TO_FULL_SHADE * 0.25); index = shelfIndex; } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBypassController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBypassController.kt index fbd6adc9b7aa..45ca0d18b4d8 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBypassController.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBypassController.kt @@ -49,6 +49,7 @@ class KeyguardBypassController { private set var bouncerShowing: Boolean = false + var launchingAffordance: Boolean = false var qSExpanded = false set(value) { val changed = field != value @@ -106,6 +107,9 @@ class KeyguardBypassController { // to unlock return false } + if (launchingAffordance) { + return false + } if (isPulseExpanding || qSExpanded) { pendingUnlockType = biometricSourceType return false diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/LockIcon.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/LockIcon.java index c0882ab17188..ca001c6f3110 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/LockIcon.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/LockIcon.java @@ -149,6 +149,11 @@ public class LockIcon extends KeyguardAffordanceView implements OnUserInfoChange public void onStrongAuthStateChanged(int userId) { update(); } + + @Override + public void onBiometricsCleared() { + update(); + } }; @Inject 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 029d6b3c4899..186fd3793cb2 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java @@ -56,6 +56,7 @@ import com.android.internal.logging.MetricsLogger; import com.android.internal.logging.nano.MetricsProto.MetricsEvent; import com.android.keyguard.KeyguardClockSwitch; import com.android.keyguard.KeyguardStatusView; +import com.android.keyguard.KeyguardUpdateMonitor; import com.android.systemui.DejankUtils; import com.android.systemui.Dependency; import com.android.systemui.Interpolators; @@ -154,6 +155,7 @@ public class NotificationPanelView extends PanelView implements private final NotificationWakeUpCoordinator mWakeUpCoordinator; private final PulseExpansionHandler mPulseExpansionHandler; private final KeyguardBypassController mKeyguardBypassController; + private final KeyguardUpdateMonitor mUpdateMonitor; @VisibleForTesting protected KeyguardAffordanceHelper mAffordanceHelper; @@ -382,6 +384,7 @@ public class NotificationPanelView extends PanelView implements }); mThemeResId = context.getThemeResId(); mKeyguardBypassController = bypassController; + mUpdateMonitor = KeyguardUpdateMonitor.getInstance(mContext); dynamicPrivacyController.addListener(this); mBottomAreaShadeAlphaAnimator = ValueAnimator.ofFloat(1f, 0); @@ -2427,6 +2430,7 @@ public class NotificationPanelView extends PanelView implements onUnlockHintFinished(); return; } + mUpdateMonitor.requestFaceAuth(); super.startUnlockHintAnimation(); } @@ -2909,7 +2913,6 @@ public class NotificationPanelView extends PanelView implements // nor setting these flags, since the occluded state doesn't change anymore, hence it's // never reset. if (!isFullyCollapsed()) { - mLaunchingAffordance = true; setLaunchingAffordance(true); } else { animate = false; @@ -2919,7 +2922,6 @@ public class NotificationPanelView extends PanelView implements } public void onAffordanceLaunchEnded() { - mLaunchingAffordance = false; setLaunchingAffordance(false); } @@ -2928,8 +2930,10 @@ public class NotificationPanelView extends PanelView implements * launched via a camera gesture. */ private void setLaunchingAffordance(boolean launchingAffordance) { + mLaunchingAffordance = launchingAffordance; getLeftIcon().setLaunchingAffordance(launchingAffordance); getRightIcon().setLaunchingAffordance(launchingAffordance); + mKeyguardBypassController.setLaunchingAffordance(launchingAffordance); if (mAffordanceLaunchListener != null) { mAffordanceLaunchListener.accept(launchingAffordance); } diff --git a/services/core/java/com/android/server/UiModeManagerService.java b/services/core/java/com/android/server/UiModeManagerService.java index 59589cd26859..bc7da3fe2edc 100644 --- a/services/core/java/com/android/server/UiModeManagerService.java +++ b/services/core/java/com/android/server/UiModeManagerService.java @@ -66,7 +66,6 @@ import com.android.server.twilight.TwilightState; import java.io.FileDescriptor; import java.io.PrintWriter; -import java.util.Objects; final class UiModeManagerService extends SystemService { private static final String TAG = UiModeManager.class.getSimpleName(); @@ -334,12 +333,6 @@ final class UiModeManagerService extends SystemService { mNightMode = defaultNightMode; } - if (UserManager.get(context).isPrimaryUser()) { - final String newTheme = Integer.toString(mNightMode); - if (!Objects.equals(SystemProperties.get(SYSTEM_PROPERTY_DEVICE_THEME), mNightMode)) { - SystemProperties.set(SYSTEM_PROPERTY_DEVICE_THEME, newTheme); - } - } return oldNightMode != mNightMode; } diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index 627ca911f9b9..b342d37dd37a 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -120,8 +120,6 @@ import static com.android.server.am.ActivityManagerDebugConfig.POSTFIX_UID_OBSER import static com.android.server.am.ActivityManagerDebugConfig.TAG_AM; import static com.android.server.am.ActivityManagerDebugConfig.TAG_WITH_CLASS_NAME; import static com.android.server.am.MemoryStatUtil.hasMemcg; -import static com.android.server.am.MemoryStatUtil.readMemoryStatFromFilesystem; -import static com.android.server.am.MemoryStatUtil.readRssHighWaterMarkFromProcfs; import static com.android.server.pm.PackageManagerService.PLATFORM_PACKAGE_NAME; import static com.android.server.wm.ActivityTaskManagerDebugConfig.DEBUG_CLEANUP; import static com.android.server.wm.ActivityTaskManagerDebugConfig.DEBUG_CONFIGURATION; @@ -178,7 +176,6 @@ import android.app.Instrumentation; import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; -import android.app.ProcessMemoryHighWaterMark; import android.app.ProcessMemoryState; import android.app.ProfilerInfo; import android.app.WaitResult; @@ -349,7 +346,6 @@ import com.android.server.SystemServiceManager; import com.android.server.ThreadPriorityBooster; import com.android.server.Watchdog; import com.android.server.am.ActivityManagerServiceDumpProcessesProto.UidObserverRegistrationProto; -import com.android.server.am.MemoryStatUtil.MemoryStat; import com.android.server.appop.AppOpsService; import com.android.server.contentcapture.ContentCaptureManagerInternal; import com.android.server.firewall.IntentFirewall; @@ -17861,43 +17857,14 @@ public class ActivityManagerService extends IActivityManager.Stub synchronized (mPidsSelfLocked) { for (int i = 0, size = mPidsSelfLocked.size(); i < size; i++) { final ProcessRecord r = mPidsSelfLocked.valueAt(i); - final int pid = r.pid; - final int uid = r.uid; - final MemoryStat memoryStat = readMemoryStatFromFilesystem(uid, pid); - if (memoryStat == null) { - continue; - } - ProcessMemoryState processMemoryState = - new ProcessMemoryState(uid, - r.processName, - r.curAdj, - memoryStat.pgfault, - memoryStat.pgmajfault, - memoryStat.rssInBytes, - memoryStat.cacheInBytes, - memoryStat.swapInBytes, - memoryStat.startTimeNanos); - processMemoryStates.add(processMemoryState); + processMemoryStates.add( + new ProcessMemoryState(r.uid, r.pid, r.processName, r.curAdj)); } } return processMemoryStates; } @Override - public List<ProcessMemoryHighWaterMark> getMemoryHighWaterMarkForProcesses() { - List<ProcessMemoryHighWaterMark> results = new ArrayList<>(); - synchronized (mPidsSelfLocked) { - for (int i = 0, size = mPidsSelfLocked.size(); i < size; i++) { - final ProcessRecord r = mPidsSelfLocked.valueAt(i); - final long rssHighWaterMarkInBytes = readRssHighWaterMarkFromProcfs(r.pid); - results.add(new ProcessMemoryHighWaterMark(r.uid, r.processName, - rssHighWaterMarkInBytes)); - } - } - return results; - } - - @Override public int handleIncomingUser(int callingPid, int callingUid, int userId, boolean allowAll, int allowMode, String name, String callerPackage) { return mUserController.handleIncomingUser(callingPid, callingUid, userId, allowAll, diff --git a/services/core/java/com/android/server/am/MemoryStatUtil.java b/services/core/java/com/android/server/am/MemoryStatUtil.java index 78d2634e9236..58d9965ed0c6 100644 --- a/services/core/java/com/android/server/am/MemoryStatUtil.java +++ b/services/core/java/com/android/server/am/MemoryStatUtil.java @@ -69,6 +69,8 @@ public final class MemoryStatUtil { Pattern.compile("VmHWM:\\s*(\\d+)\\s*kB"); private static final Pattern PROCFS_RSS_IN_KILOBYTES = Pattern.compile("VmRSS:\\s*(\\d+)\\s*kB"); + private static final Pattern PROCFS_ANON_RSS_IN_KILOBYTES = + Pattern.compile("RssAnon:\\s*(\\d+)\\s*kB"); private static final Pattern PROCFS_SWAP_IN_KILOBYTES = Pattern.compile("VmSwap:\\s*(\\d+)\\s*kB"); @@ -204,6 +206,8 @@ public final class MemoryStatUtil { memoryStat.pgmajfault = Long.parseLong(splits[PGMAJFAULT_INDEX]); memoryStat.rssInBytes = tryParseLong(PROCFS_RSS_IN_KILOBYTES, procStatusContents) * BYTES_IN_KILOBYTE; + memoryStat.anonRssInBytes = + tryParseLong(PROCFS_ANON_RSS_IN_KILOBYTES, procStatusContents) * BYTES_IN_KILOBYTE; memoryStat.swapInBytes = tryParseLong(PROCFS_SWAP_IN_KILOBYTES, procStatusContents) * BYTES_IN_KILOBYTE; memoryStat.startTimeNanos = Long.parseLong(splits[START_TIME_INDEX]) * JIFFY_NANOS; @@ -284,9 +288,11 @@ public final class MemoryStatUtil { public long pgfault; /** Number of major page faults */ public long pgmajfault; - /** Number of bytes of anonymous and swap cache memory */ + /** For memcg stats, the anon rss + swap cache size. Otherwise total RSS. */ public long rssInBytes; - /** Number of bytes of page cache memory */ + /** Number of bytes of the anonymous RSS. Only present for non-memcg stats. */ + public long anonRssInBytes; + /** Number of bytes of page cache memory. Only present for memcg stats. */ public long cacheInBytes; /** Number of bytes of swap usage */ public long swapInBytes; diff --git a/services/core/java/com/android/server/stats/StatsCompanionService.java b/services/core/java/com/android/server/stats/StatsCompanionService.java index 0e2d1dbf49c2..6b74c382afbe 100644 --- a/services/core/java/com/android/server/stats/StatsCompanionService.java +++ b/services/core/java/com/android/server/stats/StatsCompanionService.java @@ -25,6 +25,7 @@ import static android.os.storage.VolumeInfo.TYPE_PUBLIC; import static com.android.internal.util.Preconditions.checkNotNull; import static com.android.server.am.MemoryStatUtil.readCmdlineFromProcfs; +import static com.android.server.am.MemoryStatUtil.readMemoryStatFromFilesystem; import static com.android.server.am.MemoryStatUtil.readMemoryStatFromProcfs; import static com.android.server.am.MemoryStatUtil.readRssHighWaterMarkFromProcfs; import static com.android.server.am.MemoryStatUtil.readSystemIonHeapSizeFromDebugfs; @@ -39,7 +40,6 @@ import android.app.AppOpsManager.HistoricalOps; import android.app.AppOpsManager.HistoricalOpsRequest; import android.app.AppOpsManager.HistoricalPackageOps; import android.app.AppOpsManager.HistoricalUidOps; -import android.app.ProcessMemoryHighWaterMark; import android.app.ProcessMemoryState; import android.app.StatsManager; import android.bluetooth.BluetoothActivityEnergyInfo; @@ -1170,17 +1170,23 @@ public class StatsCompanionService extends IStatsCompanionService.Stub { LocalServices.getService( ActivityManagerInternal.class).getMemoryStateForProcesses(); for (ProcessMemoryState processMemoryState : processMemoryStates) { + final MemoryStat memoryStat = readMemoryStatFromFilesystem(processMemoryState.uid, + processMemoryState.pid); + if (memoryStat == null) { + continue; + } StatsLogEventWrapper e = new StatsLogEventWrapper(tagId, elapsedNanos, wallClockNanos); e.writeInt(processMemoryState.uid); e.writeString(processMemoryState.processName); e.writeInt(processMemoryState.oomScore); - e.writeLong(processMemoryState.pgfault); - e.writeLong(processMemoryState.pgmajfault); - e.writeLong(processMemoryState.rssInBytes); - e.writeLong(processMemoryState.cacheInBytes); - e.writeLong(processMemoryState.swapInBytes); + e.writeLong(memoryStat.pgfault); + e.writeLong(memoryStat.pgmajfault); + e.writeLong(memoryStat.rssInBytes); + e.writeLong(memoryStat.cacheInBytes); + e.writeLong(memoryStat.swapInBytes); e.writeLong(0); // unused - e.writeLong(processMemoryState.startTimeNanos); + e.writeLong(memoryStat.startTimeNanos); + e.writeInt(anonAndSwapInKilobytes(memoryStat)); pulledData.add(e); } } @@ -1213,20 +1219,31 @@ public class StatsCompanionService extends IStatsCompanionService.Stub { e.writeLong(0); // unused e.writeLong(memoryStat.startTimeNanos); e.writeLong(memoryStat.swapInBytes); + e.writeInt(anonAndSwapInKilobytes(memoryStat)); pulledData.add(e); } } + private static int anonAndSwapInKilobytes(MemoryStat memoryStat) { + return (int) ((memoryStat.anonRssInBytes + memoryStat.swapInBytes) / 1024); + } + private void pullProcessMemoryHighWaterMark( int tagId, long elapsedNanos, long wallClockNanos, List<StatsLogEventWrapper> pulledData) { - List<ProcessMemoryHighWaterMark> results = LocalServices.getService( - ActivityManagerInternal.class).getMemoryHighWaterMarkForProcesses(); - for (ProcessMemoryHighWaterMark processMemoryHighWaterMark : results) { + List<ProcessMemoryState> managedProcessList = + LocalServices.getService( + ActivityManagerInternal.class).getMemoryStateForProcesses(); + for (ProcessMemoryState managedProcess : managedProcessList) { + final long rssHighWaterMarkInBytes = + readRssHighWaterMarkFromProcfs(managedProcess.pid); + if (rssHighWaterMarkInBytes == 0) { + continue; + } StatsLogEventWrapper e = new StatsLogEventWrapper(tagId, elapsedNanos, wallClockNanos); - e.writeInt(processMemoryHighWaterMark.uid); - e.writeString(processMemoryHighWaterMark.processName); - e.writeLong(processMemoryHighWaterMark.rssHighWaterMarkInBytes); + e.writeInt(managedProcess.uid); + e.writeString(managedProcess.processName); + e.writeLong(rssHighWaterMarkInBytes); pulledData.add(e); } int[] pids = getPidsForCommands(MEMORY_INTERESTING_NATIVE_PROCESSES); diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java index 8b61208c0b66..e5518d05e9c5 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java @@ -11018,7 +11018,11 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { return false; } mLockPatternUtils.setLockScreenDisabled(disabled, userId); - mInjector.getIWindowManager().dismissKeyguard(null /* callback */, null /* message */); + if (disabled) { + mInjector + .getIWindowManager() + .dismissKeyguard(null /* callback */, null /* message */); + } DevicePolicyEventLogger .createEvent(DevicePolicyEnums.SET_KEYGUARD_DISABLED) .setAdmin(who) diff --git a/services/tests/servicestests/src/com/android/server/am/MemoryStatUtilTest.java b/services/tests/servicestests/src/com/android/server/am/MemoryStatUtilTest.java index 174571de1e4c..213c939494c2 100644 --- a/services/tests/servicestests/src/com/android/server/am/MemoryStatUtilTest.java +++ b/services/tests/servicestests/src/com/android/server/am/MemoryStatUtilTest.java @@ -233,6 +233,7 @@ public class MemoryStatUtilTest { assertEquals(0, stat.cacheInBytes); assertEquals(22 * BYTES_IN_KILOBYTE, stat.swapInBytes); assertEquals(2222 * JIFFY_NANOS, stat.startTimeNanos); + assertEquals(37860 * BYTES_IN_KILOBYTE, stat.anonRssInBytes); } @Test |