diff --git a/apex/jobscheduler/service/java/com/android/server/job/JobServiceContext.java b/apex/jobscheduler/service/java/com/android/server/job/JobServiceContext.java index e2b742575ddd8..e81feb39adbf6 100644 --- a/apex/jobscheduler/service/java/com/android/server/job/JobServiceContext.java +++ b/apex/jobscheduler/service/java/com/android/server/job/JobServiceContext.java @@ -1485,9 +1485,11 @@ void handleOpTimeoutLocked() { } else { Slog.i(TAG, "JS was waiting to stop this job." + " Sending onStop: " + getRunningJobNameLocked()); - mParams.setStopReason(mPendingStopReason, mPendingInternalStopReason, - mPendingDebugStopReason); - sendStopMessageLocked(mPendingDebugStopReason); + if (mParams != null) { + mParams.setStopReason(mPendingStopReason, mPendingInternalStopReason, + mPendingDebugStopReason); + sendStopMessageLocked(mPendingDebugStopReason); + } mAnrTimer.discard(); break; } diff --git a/core/java/android/content/res/AssetManager.java b/core/java/android/content/res/AssetManager.java index 61c16a3d4c5f2..eafdb63897188 100644 --- a/core/java/android/content/res/AssetManager.java +++ b/core/java/android/content/res/AssetManager.java @@ -971,8 +971,14 @@ public boolean containsAllocatedTable() { @Nullable CharSequence getPooledStringForCookie(int cookie, int id) { - // Cookies map to ApkAssets starting at 1. - return getApkAssets()[cookie - 1].getStringFromPool(id); + ApkAssets[] apkAssets = getApkAssets(); + + if (cookie > 0 && cookie <= apkAssets.length) { + // map cookies starting at 1. + return apkAssets[cookie - 1].getStringFromPool(id); + } + + return null; } /** diff --git a/core/java/android/os/Process.java b/core/java/android/os/Process.java index 793b05560d6c7..cca05a2526c3f 100644 --- a/core/java/android/os/Process.java +++ b/core/java/android/os/Process.java @@ -1519,6 +1519,31 @@ public static final void killProcessQuiet(int pid) { sendSignalQuiet(pid, SIGNAL_KILL); } + /** + * @hide + * PID-reuse-safe variant of {@link #killProcessQuiet(int)} backed by + * pidfd_open + pidfd_send_signal. Pass {@code expectedUid < 0} to skip + * the uid check. Falls back to the legacy path on kernels without pidfd. + */ + public static final void killProcessByPidfdQuiet(int pid, int expectedUid) { + if (pid <= 0) { + return; + } + if (supportsPidFd()) { + int rc = nativeKillProcessByPidfdQuiet(pid, SIGNAL_KILL, expectedUid); + if (rc >= 0) { + return; + } + } + // Fallback: re-check uid via /proc to avoid killing a recycled pid. + if (expectedUid >= 0 && getUidForPid(pid) != expectedUid) { + return; + } + sendSignalQuiet(pid, SIGNAL_KILL); + } + + private static native int nativeKillProcessByPidfdQuiet(int pid, int signal, int expectedUid); + /** * @hide * Private impl for avoiding a log message... DO NOT USE without doing diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index 98f07b1c1049b..77ad5e4cdd921 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -7032,6 +7032,13 @@ public static void setShowGTalkServiceStatusForUser(ContentResolver cr, boolean */ public static final String DOZE_TRIGGER_DOUBLETAP = "doze_trigger_doubletap"; + /** + * Whether to control brightness from status bar on lockscreen + * 0 = 0ff, 1 = on + * @hide + */ + public static final String STATUS_BAR_BRIGHTNESS_CONTROL_LOCKSCREEN = "status_bar_brightness_control_lockscreen"; + /** * Whether to enable smart 5G mode * @hide @@ -7374,6 +7381,13 @@ public static void setShowGTalkServiceStatusForUser(ContentResolver cr, boolean */ public static final String FORCE_FULLSCREEN_CUTOUT_APPS = "force_full_screen_cutout_apps"; + /** + * Whether to control brightness from status bar + * 0 = 0ff, 1 = on + * @hide + */ + public static final String STATUS_BAR_BRIGHTNESS_CONTROL = "status_bar_brightness_control"; + /** * Keys we no longer back up under the current schema, but want to continue to * process when restoring historical backup datasets. diff --git a/core/java/android/util/EventLog.java b/core/java/android/util/EventLog.java index 0dec1fabda0a6..a48c336f7b643 100644 --- a/core/java/android/util/EventLog.java +++ b/core/java/android/util/EventLog.java @@ -334,8 +334,6 @@ public int hashCode() { } } - // We assume that the native methods deal with any concurrency issues. - /** * Record an event log message. * @param tag The event type tag code @@ -343,7 +341,13 @@ public int hashCode() { * @return The number of bytes written */ @RavenwoodRedirect - public static native int writeEvent(int tag, int value); + public static int writeEvent(int tag, int value) { + if (!Build.IS_ENG) { + return 0; + } + + return nativeWriteEvent(tag, value); + } /** * Record an event log message. @@ -352,7 +356,13 @@ public int hashCode() { * @return The number of bytes written */ @RavenwoodRedirect - public static native int writeEvent(int tag, long value); + public static int writeEvent(int tag, long value) { + if (!Build.IS_ENG) { + return 0; + } + + return nativeWriteEvent(tag, value); + } /** * Record an event log message. @@ -361,7 +371,13 @@ public int hashCode() { * @return The number of bytes written */ @RavenwoodRedirect - public static native int writeEvent(int tag, float value); + public static int writeEvent(int tag, float value) { + if (!Build.IS_ENG) { + return 0; + } + + return nativeWriteEvent(tag, value); + } /** * Record an event log message. @@ -370,7 +386,13 @@ public int hashCode() { * @return The number of bytes written */ @RavenwoodRedirect - public static native int writeEvent(int tag, String str); + public static int writeEvent(int tag, String str) { + if (!Build.IS_ENG) { + return 0; + } + + return nativeWriteEvent(tag, str); + } /** * Record an event log message. @@ -379,7 +401,13 @@ public int hashCode() { * @return The number of bytes written */ @RavenwoodRedirect - public static native int writeEvent(int tag, Object... list); + public static int writeEvent(int tag, Object... list) { + if (!Build.IS_ENG) { + return 0; + } + + return nativeWriteEvent(tag, list); + } /** * Read events from the log, filtered by type. @@ -388,8 +416,14 @@ public int hashCode() { * @throws IOException if something goes wrong reading events */ @RavenwoodThrow - public static native void readEvents(int[] tags, Collection output) - throws IOException; + public static void readEvents(int[] tags, Collection output) + throws IOException { + if (!Build.IS_ENG) { + return; + } + + nativeReadEvents(tags, output); + } /** * Read events from the log, filtered by type, blocking until logs are about to be overwritten. @@ -401,7 +435,27 @@ public static native void readEvents(int[] tags, Collection output) */ @SystemApi @RavenwoodThrow - public static native void readEventsOnWrapping(int[] tags, long timestamp, + public static void readEventsOnWrapping(int[] tags, long timestamp, + Collection output) + throws IOException { + if (!Build.IS_ENG) { + return; + } + + nativeReadEventsOnWrapping(tags, timestamp, output); + } + + // We assume that the native methods deal with any concurrency issues. + + private static native int nativeWriteEvent(int tag, int value); + private static native int nativeWriteEvent(int tag, long value); + private static native int nativeWriteEvent(int tag, float value); + private static native int nativeWriteEvent(int tag, String str); + private static native int nativeWriteEvent(int tag, Object... list); + + private static native void nativeReadEvents(int[] tags, Collection output) + throws IOException; + private static native void nativeReadEventsOnWrapping(int[] tags, long timestamp, Collection output) throws IOException; diff --git a/core/java/android/view/Choreographer.java b/core/java/android/view/Choreographer.java index 0352f4417b63a..8c3abd709d75e 100644 --- a/core/java/android/view/Choreographer.java +++ b/core/java/android/view/Choreographer.java @@ -1198,8 +1198,10 @@ void doFrame(long frameTimeNanos, int frame, void doCallbacks(int callbackType, long frameIntervalNanos) { CallbackRecord callbacks; - long frameTimeNanos = mFrameData.mFrameTimeNanos; synchronized (mLock) { + if (mCallbackQueues[callbackType].mHead == null) { + return; + } // We use "now" to determine when callbacks become due because it's possible // for earlier processing phases in a frame to post callbacks that should run // in a following phase, such as an input event that causes an animation to start. @@ -1219,6 +1221,7 @@ void doCallbacks(int callbackType, long frameIntervalNanos) { // or equal to the previous frame's commit frame time. Keep in mind that the // next frame has most likely already been scheduled by now so we play it // safe by ensuring the commit time is always at least one frame behind. + long frameTimeNanos = mFrameData.mFrameTimeNanos; if (callbackType == Choreographer.CALLBACK_COMMIT) { final long jitterNanos = now - frameTimeNanos; Trace.traceCounter(Trace.TRACE_TAG_VIEW, "jitterNanos", (int) jitterNanos); diff --git a/core/java/com/android/internal/util/FileRotator.java b/core/java/com/android/internal/util/FileRotator.java index bcad6fc85ca92..22014a411e49c 100644 --- a/core/java/com/android/internal/util/FileRotator.java +++ b/core/java/com/android/internal/util/FileRotator.java @@ -334,7 +334,15 @@ private String getActiveName(long currentTimeMillis) { long oldestActiveStart = Long.MAX_VALUE; final FileInfo info = new FileInfo(mPrefix); - for (String name : mBasePath.list()) { + String[] baseFiles = mBasePath.list(); + if (baseFiles == null) { + // no file in the path and create one starting now + info.startMillis = currentTimeMillis; + info.endMillis = Long.MAX_VALUE; + return info.build(); + } + + for (String name : baseFiles) { if (!info.parse(name)) continue; // pick the oldest active file which covers current time diff --git a/core/jni/android_util_EventLog.cpp b/core/jni/android_util_EventLog.cpp index 0a5e786175682..2e9aa3405dac2 100644 --- a/core/jni/android_util_EventLog.cpp +++ b/core/jni/android_util_EventLog.cpp @@ -68,16 +68,16 @@ static void android_util_EventLog_readEventsOnWrapping(JNIEnv* env, jobject claz */ static const JNINativeMethod gRegisterMethods[] = { /* name, signature, funcPtr */ - { "writeEvent", "(II)I", (void*) ELog::writeEventInteger }, - { "writeEvent", "(IJ)I", (void*) ELog::writeEventLong }, - { "writeEvent", "(IF)I", (void*) ELog::writeEventFloat }, - { "writeEvent", "(ILjava/lang/String;)I", (void*) ELog::writeEventString }, - { "writeEvent", "(I[Ljava/lang/Object;)I", (void*) ELog::writeEventArray }, - { "readEvents", + { "nativeWriteEvent", "(II)I", (void*) ELog::writeEventInteger }, + { "nativeWriteEvent", "(IJ)I", (void*) ELog::writeEventLong }, + { "nativeWriteEvent", "(IF)I", (void*) ELog::writeEventFloat }, + { "nativeWriteEvent", "(ILjava/lang/String;)I", (void*) ELog::writeEventString }, + { "nativeWriteEvent", "(I[Ljava/lang/Object;)I", (void*) ELog::writeEventArray }, + { "nativeReadEvents", "([ILjava/util/Collection;)V", (void*) android_util_EventLog_readEvents }, - { "readEventsOnWrapping", + { "nativeReadEventsOnWrapping", "([IJLjava/util/Collection;)V", (void*) android_util_EventLog_readEventsOnWrapping }, diff --git a/core/jni/android_util_Process.cpp b/core/jni/android_util_Process.cpp index 74c35777afe48..6b4149164040a 100644 --- a/core/jni/android_util_Process.cpp +++ b/core/jni/android_util_Process.cpp @@ -1332,6 +1332,47 @@ static jint android_os_Process_nativePidFdOpen(JNIEnv* env, jobject, jint pid, j return fd; } +// Kill via pidfd to defeat PID-reuse races. +// Returns: 0=delivered, 1=target gone, 2=uid mismatch (suppressed), -1=error. +static jint android_os_Process_killProcessByPidfdQuiet(JNIEnv* /*env*/, jobject /*clazz*/, + jint pid, jint signal, jint expectedUid) { + if (pid <= 0) { + return -1; + } + + int pfd = pidfd_open(pid, 0); + if (pfd < 0) { + if (errno == ESRCH) return 1; + if (errno == ENOSYS) { + ALOGW("pidfd_open(%d) ENOSYS, kernel too old for pidfd guard", pid); + return -1; + } + ALOGW("pidfd_open(%d) failed: %s", pid, strerror(errno)); + return -1; + } + + if (expectedUid >= 0) { + const int actualUid = uid_from_pid(pid); + if (actualUid != expectedUid) { + ALOGW("Skip kill: pid %d uid mismatch, expected=%d actual=%d (likely pid reuse)", + pid, expectedUid, actualUid); + close(pfd); + return 2; + } + } + + int rc = pidfd_send_signal(pfd, signal, nullptr, 0); + int saved_errno = errno; + close(pfd); + + if (rc == 0) return 0; + if (saved_errno == ESRCH) return 1; + ALOGW("pidfd_send_signal(pid=%d, sig=%d) failed: %s", + pid, signal, strerror(saved_errno)); + errno = saved_errno; + return -1; +} + void android_os_Process_freezeCgroupUID(JNIEnv* env, jobject clazz, jint uid, jboolean freeze) { if (uid < 0) { jniThrowExceptionFmt(env, "java/lang/IllegalArgumentException", "uid is negative: %d", uid); @@ -1398,6 +1439,8 @@ static const JNINativeMethod methods[] = { {"sendSignalToProcessGroup", "(III)Z", (void*)android_os_Process_sendSignalToProcessGroup}, {"removeAllProcessGroups", "()V", (void*)android_os_Process_removeAllProcessGroups}, {"nativePidFdOpen", "(II)I", (void*)android_os_Process_nativePidFdOpen}, + {"nativeKillProcessByPidfdQuiet", "(III)I", + (void*)android_os_Process_killProcessByPidfdQuiet}, {"freezeCgroupUid", "(IZ)V", (void*)android_os_Process_freezeCgroupUID}, }; diff --git a/core/res/res/layout/transient_notification.xml b/core/res/res/layout/transient_notification.xml index 8bedb897dc196..b5983f8721e04 100644 --- a/core/res/res/layout/transient_notification.xml +++ b/core/res/res/layout/transient_notification.xml @@ -1,22 +1,19 @@ + ~ Copyright (C) 2021 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. + --> + diff --git a/core/res/res/layout/transient_notification_with_icon.xml b/core/res/res/layout/transient_notification_with_icon.xml index 04518b2a75a2e..05da8676ada80 100644 --- a/core/res/res/layout/transient_notification_with_icon.xml +++ b/core/res/res/layout/transient_notification_with_icon.xml @@ -22,7 +22,7 @@ android:orientation="horizontal" android:gravity="center_vertical" android:maxWidth="@dimen/toast_width" - android:background="@android:drawable/toast_frame" + android:background="@drawable/toast_frame" android:elevation="@dimen/toast_elevation" android:layout_marginEnd="16dp" android:layout_marginStart="16dp" @@ -41,9 +41,15 @@ android:id="@android:id/message" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:ellipsize="end" - android:maxLines="2" android:paddingTop="12dp" android:paddingBottom="12dp" + android:textAlignment="center" + android:layout_gravity="center_vertical" + android:singleLine="true" + android:ellipsize="marquee" + android:marqueeRepeatLimit="marquee_forever" + android:focusable="true" + android:focusableInTouchMode="true" + android:scrollHorizontally="true" android:textAppearance="@style/TextAppearance.Toast"/> diff --git a/core/res/res/values/hertzify_config.xml b/core/res/res/values/hertzify_config.xml index 69bfa18135fc0..01b17d45b0f7f 100644 --- a/core/res/res/values/hertzify_config.xml +++ b/core/res/res/values/hertzify_config.xml @@ -184,4 +184,16 @@ -1 + + + + diff --git a/core/res/res/values/hertzify_symbols.xml b/core/res/res/values/hertzify_symbols.xml index 4f2bd43d1c2da..53c1173384114 100644 --- a/core/res/res/values/hertzify_symbols.xml +++ b/core/res/res/values/hertzify_symbols.xml @@ -175,4 +175,7 @@ + + + diff --git a/native/android/performance_hint.cpp b/native/android/performance_hint.cpp index 1e48c1f6d7bbb..97da7b8577501 100644 --- a/native/android/performance_hint.cpp +++ b/native/android/performance_hint.cpp @@ -443,7 +443,7 @@ int APerformanceHintManager::createSessionUsingConfig(ASessionCreationConfig* se sessionCreationConfig->layerTokens.clear(); if (!ret.isOk() || !returnValue.session) { - ALOGE("%s: PerformanceHint cannot create session. %s", __FUNCTION__, ret.getMessage()); + //ALOGE("%s: PerformanceHint cannot create session. %s", __FUNCTION__, ret.getMessage()); switch (ret.getExceptionCode()) { case binder::Status::EX_UNSUPPORTED_OPERATION: return ENOTSUP; diff --git a/packages/SettingsLib/CollapsingToolbarBaseActivity/res/drawable-v36/settingslib_expressive_icon_back.xml b/packages/SettingsLib/CollapsingToolbarBaseActivity/res/drawable-v36/settingslib_expressive_icon_back.xml index 9986a60250fec..1ef24ad12903c 100644 --- a/packages/SettingsLib/CollapsingToolbarBaseActivity/res/drawable-v36/settingslib_expressive_icon_back.xml +++ b/packages/SettingsLib/CollapsingToolbarBaseActivity/res/drawable-v36/settingslib_expressive_icon_back.xml @@ -22,7 +22,7 @@ + android:radius="14dp" /> @@ -44,4 +44,4 @@ android:pathData="M3.626,9L8.526,13.9C8.726,14.1 8.817,14.333 8.801,14.6C8.801,14.867 8.701,15.1 8.501,15.3C8.301,15.483 8.067,15.583 7.801,15.6C7.534,15.6 7.301,15.5 7.101,15.3L0.501,8.7C0.401,8.6 0.326,8.492 0.276,8.375C0.242,8.258 0.226,8.133 0.226,8C0.226,7.867 0.242,7.742 0.276,7.625C0.326,7.508 0.401,7.4 0.501,7.3L7.101,0.7C7.284,0.517 7.509,0.425 7.776,0.425C8.059,0.425 8.301,0.517 8.501,0.7C8.701,0.9 8.801,1.142 8.801,1.425C8.801,1.692 8.701,1.925 8.501,2.125L3.626,7H14.801C15.084,7 15.317,7.1 15.501,7.3C15.701,7.483 15.801,7.717 15.801,8C15.801,8.283 15.701,8.525 15.501,8.725C15.317,8.908 15.084,9 14.801,9H3.626Z"/> - \ No newline at end of file + diff --git a/packages/SettingsLib/CollapsingToolbarBaseActivity/res/values-v36/styles_expressive.xml b/packages/SettingsLib/CollapsingToolbarBaseActivity/res/values-v36/styles_expressive.xml index 344b336dc6751..7471a553931d9 100644 --- a/packages/SettingsLib/CollapsingToolbarBaseActivity/res/values-v36/styles_expressive.xml +++ b/packages/SettingsLib/CollapsingToolbarBaseActivity/res/values-v36/styles_expressive.xml @@ -38,10 +38,12 @@