diff options
107 files changed, 927 insertions, 248 deletions
diff --git a/api/OWNERS b/api/OWNERS index 965093c9ab38..f2bcf13d2d2e 100644 --- a/api/OWNERS +++ b/api/OWNERS @@ -9,4 +9,4 @@ per-file *.go,go.mod,go.work,go.work.sum = file:platform/build/soong:/OWNERS per-file Android.bp = file:platform/build/soong:/OWNERS #{LAST_RESORT_SUGGESTION} # For metalava team to disable lint checks in platform -per-file Android.bp = aurimas@google.com,emberrose@google.com +per-file Android.bp = aurimas@google.com diff --git a/core/java/android/accessibilityservice/OWNERS b/core/java/android/accessibilityservice/OWNERS index 1265dfa2c441..dac64f47ba7e 100644 --- a/core/java/android/accessibilityservice/OWNERS +++ b/core/java/android/accessibilityservice/OWNERS @@ -1,4 +1,7 @@ -# Bug component: 44215 +# Bug component: 1530954 +# +# The above component is for automated test bugs. If you are a human looking to report +# a bug in this codebase then please use component 44215. # Android Accessibility Framework owners include /services/accessibility/OWNERS
\ No newline at end of file diff --git a/core/java/android/os/Binder.java b/core/java/android/os/Binder.java index 86dc20c497e6..ed75491b8e21 100644 --- a/core/java/android/os/Binder.java +++ b/core/java/android/os/Binder.java @@ -149,11 +149,6 @@ public class Binder implements IBinder { private static volatile boolean sStackTrackingEnabled = false; /** - * The extension binder object - */ - private IBinder mExtension = null; - - /** * Enable Binder IPC stack tracking. If enabled, every binder transaction will be logged to * {@link TransactionTracker}. * @@ -1239,9 +1234,7 @@ public class Binder implements IBinder { /** @hide */ @Override - public final @Nullable IBinder getExtension() { - return mExtension; - } + public final native @Nullable IBinder getExtension(); /** * Set the binder extension. @@ -1249,12 +1242,7 @@ public class Binder implements IBinder { * * @hide */ - public final void setExtension(@Nullable IBinder extension) { - mExtension = extension; - setExtensionNative(extension); - } - - private final native void setExtensionNative(@Nullable IBinder extension); + public final native void setExtension(@Nullable IBinder extension); /** * Default implementation rewinds the parcels and calls onTransact. On diff --git a/core/java/android/os/SharedMemory.java b/core/java/android/os/SharedMemory.java index 46ae9d8682ee..320641ded0f9 100644 --- a/core/java/android/os/SharedMemory.java +++ b/core/java/android/os/SharedMemory.java @@ -25,8 +25,6 @@ import android.system.OsConstants; import dalvik.system.VMRuntime; -import libcore.io.IoUtils; - import java.io.Closeable; import java.io.FileDescriptor; import java.io.IOException; @@ -65,7 +63,7 @@ public final class SharedMemory implements Parcelable, Closeable { mMemoryRegistration = new MemoryRegistration(mSize); mCleaner = Cleaner.create(mFileDescriptor, - new Closer(mFileDescriptor, mMemoryRegistration)); + new Closer(mFileDescriptor.getInt$(), mMemoryRegistration)); } /** @@ -278,6 +276,7 @@ public final class SharedMemory implements Parcelable, Closeable { */ @Override public void close() { + mFileDescriptor.setInt$(-1); if (mCleaner != null) { mCleaner.clean(); mCleaner = null; @@ -327,20 +326,21 @@ public final class SharedMemory implements Parcelable, Closeable { * Cleaner that closes the FD */ private static final class Closer implements Runnable { - private FileDescriptor mFd; + private int mFd; private MemoryRegistration mMemoryReference; - private Closer(FileDescriptor fd, MemoryRegistration memoryReference) { + private Closer(int fd, MemoryRegistration memoryReference) { mFd = fd; - IoUtils.setFdOwner(mFd, this); mMemoryReference = memoryReference; } @Override public void run() { - IoUtils.closeQuietly(mFd); - mFd = null; - + try { + FileDescriptor fd = new FileDescriptor(); + fd.setInt$(mFd); + Os.close(fd); + } catch (ErrnoException e) { /* swallow error */ } mMemoryReference.release(); mMemoryReference = null; } diff --git a/core/java/android/view/accessibility/OWNERS b/core/java/android/view/accessibility/OWNERS index f62b33f1f753..799ef0091f71 100644 --- a/core/java/android/view/accessibility/OWNERS +++ b/core/java/android/view/accessibility/OWNERS @@ -1,4 +1,7 @@ -# Bug component: 44215 +# Bug component: 1530954 +# +# The above component is for automated test bugs. If you are a human looking to report +# a bug in this codebase then please use component 44215. # Android Accessibility Framework owners include /services/accessibility/OWNERS diff --git a/core/java/com/android/internal/accessibility/OWNERS b/core/java/com/android/internal/accessibility/OWNERS index 1265dfa2c441..dac64f47ba7e 100644 --- a/core/java/com/android/internal/accessibility/OWNERS +++ b/core/java/com/android/internal/accessibility/OWNERS @@ -1,4 +1,7 @@ -# Bug component: 44215 +# Bug component: 1530954 +# +# The above component is for automated test bugs. If you are a human looking to report +# a bug in this codebase then please use component 44215. # Android Accessibility Framework owners include /services/accessibility/OWNERS
\ No newline at end of file diff --git a/core/java/com/android/internal/graphics/palette/OWNERS b/core/java/com/android/internal/graphics/palette/OWNERS index 731dca9b128f..df867252c01c 100644 --- a/core/java/com/android/internal/graphics/palette/OWNERS +++ b/core/java/com/android/internal/graphics/palette/OWNERS @@ -1,3 +1,2 @@ -# Bug component: 484670
-dupin@google.com
-jamesoleary@google.com
\ No newline at end of file +# Bug component: 484670 +dupin@google.com diff --git a/core/java/com/android/internal/os/BaseCommand.java b/core/java/com/android/internal/os/BaseCommand.java index c85b5d7aa7a6..af763e4c5fa9 100644 --- a/core/java/com/android/internal/os/BaseCommand.java +++ b/core/java/com/android/internal/os/BaseCommand.java @@ -58,15 +58,23 @@ public abstract class BaseCommand { mRawArgs = args; mArgs.init(null, null, null, null, args, 0); + int status = 1; try { onRun(); + status = 0; } catch (IllegalArgumentException e) { onShowUsage(System.err); System.err.println(); System.err.println("Error: " + e.getMessage()); + status = 0; } catch (Exception e) { e.printStackTrace(System.err); - System.exit(1); + } finally { + System.out.flush(); + System.err.flush(); + } + if (status != 0) { + System.exit(status); } } diff --git a/core/jni/Android.bp b/core/jni/Android.bp index 411315ee2800..c76e8e9ef3ce 100644 --- a/core/jni/Android.bp +++ b/core/jni/Android.bp @@ -42,6 +42,8 @@ cc_library_shared_for_libandroid_runtime { "-DU_USING_ICU_NAMESPACE=0", + "-DANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION", + "-Wall", "-Werror", "-Wextra", @@ -288,6 +290,7 @@ cc_library_shared_for_libandroid_runtime { ], static_libs: [ + "android.os.flags-aconfig-cc", "libasync_safe", "libbinderthreadstateutils", "libdmabufinfo", diff --git a/core/jni/AndroidRuntime.cpp b/core/jni/AndroidRuntime.cpp index 3bfc1028dd6a..0e4da86b7cc3 100644 --- a/core/jni/AndroidRuntime.cpp +++ b/core/jni/AndroidRuntime.cpp @@ -22,6 +22,7 @@ #include <android-base/parsebool.h> #include <android-base/properties.h> #include <android/graphics/jni_runtime.h> +#include <android_os.h> #include <android_runtime/AndroidRuntime.h> #include <assert.h> #include <binder/IBinder.h> @@ -887,9 +888,13 @@ int AndroidRuntime::startVm(JavaVM** pJavaVM, JNIEnv** pEnv, bool zygote, bool p madviseWillNeedFileSizeOdex, "-XMadviseWillNeedOdexFileSize:"); - parseRuntimeOption("dalvik.vm.madvise.artfile.size", - madviseWillNeedFileSizeArt, - "-XMadviseWillNeedArtFileSize:"); + // Historically, dalvik.vm.madvise.artfile.size was set to UINT_MAX by default. With the + // disable_madvise_art_default flag rollout, we use this default only when the flag is disabled. + // TODO(b/382110550): Remove this property/flag entirely after validating and ramping. + const char* madvise_artfile_size_default = + android::os::disable_madvise_artfile_default() ? "" : "4294967295"; + parseRuntimeOption("dalvik.vm.madvise.artfile.size", madviseWillNeedFileSizeArt, + "-XMadviseWillNeedArtFileSize:", madvise_artfile_size_default); /* * Profile related options. diff --git a/core/jni/android_content_res_ObbScanner.cpp b/core/jni/android_content_res_ObbScanner.cpp index 760037f63195..5b412ab19e16 100644 --- a/core/jni/android_content_res_ObbScanner.cpp +++ b/core/jni/android_content_res_ObbScanner.cpp @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#undef ANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION // TODO:remove this and fix code #define LOG_TAG "ObbScanner" diff --git a/core/jni/android_graphics_BLASTBufferQueue.cpp b/core/jni/android_graphics_BLASTBufferQueue.cpp index b9c3bf73f11c..ed547ef7bb1c 100644 --- a/core/jni/android_graphics_BLASTBufferQueue.cpp +++ b/core/jni/android_graphics_BLASTBufferQueue.cpp @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#undef ANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION // TODO:remove this and fix code #define LOG_TAG "BLASTBufferQueue" diff --git a/core/jni/android_graphics_GraphicBuffer.cpp b/core/jni/android_graphics_GraphicBuffer.cpp index d5765f1907d5..61dbb32c3b9f 100644 --- a/core/jni/android_graphics_GraphicBuffer.cpp +++ b/core/jni/android_graphics_GraphicBuffer.cpp @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#undef ANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION // TODO:remove this and fix code #define LOG_TAG "GraphicBuffer" diff --git a/core/jni/android_graphics_SurfaceTexture.cpp b/core/jni/android_graphics_SurfaceTexture.cpp index 8dd63cc07b8a..93d1e2eef9e7 100644 --- a/core/jni/android_graphics_SurfaceTexture.cpp +++ b/core/jni/android_graphics_SurfaceTexture.cpp @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#undef ANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION // TODO:remove this and fix code #undef LOG_TAG #define LOG_TAG "SurfaceTexture" diff --git a/core/jni/android_hardware_Camera.cpp b/core/jni/android_hardware_Camera.cpp index 3f74fac35bb7..13c4fb7517d3 100644 --- a/core/jni/android_hardware_Camera.cpp +++ b/core/jni/android_hardware_Camera.cpp @@ -14,6 +14,7 @@ ** See the License for the specific language governing permissions and ** limitations under the License. */ +#undef ANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION // TODO:remove this and fix code //#define LOG_NDEBUG 0 #define LOG_TAG "Camera-JNI" diff --git a/core/jni/android_hardware_HardwareBuffer.cpp b/core/jni/android_hardware_HardwareBuffer.cpp index 2ea2158d1884..c8059f39a34a 100644 --- a/core/jni/android_hardware_HardwareBuffer.cpp +++ b/core/jni/android_hardware_HardwareBuffer.cpp @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#undef ANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION // TODO:remove this and fix code #define LOG_TAG "HardwareBuffer" diff --git a/core/jni/android_hardware_SensorManager.cpp b/core/jni/android_hardware_SensorManager.cpp index 56ea52d2ad8b..2864a5718f33 100644 --- a/core/jni/android_hardware_SensorManager.cpp +++ b/core/jni/android_hardware_SensorManager.cpp @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#undef ANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION // TODO:remove this and fix code #define LOG_TAG "SensorManager" #include <nativehelper/JNIHelp.h> diff --git a/core/jni/android_hardware_camera2_CameraMetadata.cpp b/core/jni/android_hardware_camera2_CameraMetadata.cpp index 041fed74c573..e343438f1260 100644 --- a/core/jni/android_hardware_camera2_CameraMetadata.cpp +++ b/core/jni/android_hardware_camera2_CameraMetadata.cpp @@ -14,6 +14,7 @@ ** See the License for the specific language governing permissions and ** limitations under the License. */ +#undef ANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION // TODO:remove this and fix code // #define LOG_NDEBUG 0 #include <memory> diff --git a/core/jni/android_hardware_camera2_DngCreator.cpp b/core/jni/android_hardware_camera2_DngCreator.cpp index 82570be8e329..828f2eb76c60 100644 --- a/core/jni/android_hardware_camera2_DngCreator.cpp +++ b/core/jni/android_hardware_camera2_DngCreator.cpp @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#undef ANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION // TODO:remove this and fix code //#define LOG_NDEBUG 0 #define LOG_TAG "DngCreator_JNI" diff --git a/core/jni/android_hardware_input_InputWindowHandle.cpp b/core/jni/android_hardware_input_InputWindowHandle.cpp index 69f633420a0d..bfc5419d5d50 100644 --- a/core/jni/android_hardware_input_InputWindowHandle.cpp +++ b/core/jni/android_hardware_input_InputWindowHandle.cpp @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#undef ANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION // TODO:remove this and fix code #define LOG_TAG "InputWindowHandle" diff --git a/core/jni/android_media_AudioRecord.cpp b/core/jni/android_media_AudioRecord.cpp index f9d00edce3fa..c76395921914 100644 --- a/core/jni/android_media_AudioRecord.cpp +++ b/core/jni/android_media_AudioRecord.cpp @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#undef ANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION // TODO:remove this and fix code //#define LOG_NDEBUG 0 diff --git a/core/jni/android_media_AudioSystem.cpp b/core/jni/android_media_AudioSystem.cpp index 9bccf5af7096..a50fb898691c 100644 --- a/core/jni/android_media_AudioSystem.cpp +++ b/core/jni/android_media_AudioSystem.cpp @@ -14,6 +14,7 @@ ** See the License for the specific language governing permissions and ** limitations under the License. */ +#undef ANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION // TODO:remove this and fix code //#define LOG_NDEBUG 0 diff --git a/core/jni/android_media_AudioTrack.cpp b/core/jni/android_media_AudioTrack.cpp index 1557f9ed47a5..a660f0bb5d18 100644 --- a/core/jni/android_media_AudioTrack.cpp +++ b/core/jni/android_media_AudioTrack.cpp @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#undef ANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION // TODO:remove this and fix code //#define LOG_NDEBUG 0 #define LOG_TAG "AudioTrack-JNI" diff --git a/core/jni/android_media_AudioVolumeGroupCallback.cpp b/core/jni/android_media_AudioVolumeGroupCallback.cpp index cb4ddbd119d5..d130a4bc68fa 100644 --- a/core/jni/android_media_AudioVolumeGroupCallback.cpp +++ b/core/jni/android_media_AudioVolumeGroupCallback.cpp @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#undef ANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION // TODO:remove this and fix code //#define LOG_NDEBUG 0 diff --git a/core/jni/android_media_RemoteDisplay.cpp b/core/jni/android_media_RemoteDisplay.cpp index 3b517f1eafe0..cf96f027bd5e 100644 --- a/core/jni/android_media_RemoteDisplay.cpp +++ b/core/jni/android_media_RemoteDisplay.cpp @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#undef ANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION // TODO:remove this and fix code #define LOG_TAG "RemoteDisplay" diff --git a/core/jni/android_media_ToneGenerator.cpp b/core/jni/android_media_ToneGenerator.cpp index cc4657ded596..3c590c37adac 100644 --- a/core/jni/android_media_ToneGenerator.cpp +++ b/core/jni/android_media_ToneGenerator.cpp @@ -14,6 +14,7 @@ ** See the License for the specific language governing permissions and ** limitations under the License. */ +#undef ANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION // TODO:remove this and fix code #define LOG_TAG "ToneGenerator" #include <stdio.h> diff --git a/core/jni/android_opengl_EGL14.cpp b/core/jni/android_opengl_EGL14.cpp index 917d28348d04..7e9beefdc38c 100644 --- a/core/jni/android_opengl_EGL14.cpp +++ b/core/jni/android_opengl_EGL14.cpp @@ -632,7 +632,7 @@ not_valid_surface: if (producer == NULL) goto not_valid_surface; - window = new android::Surface(producer, true); + window = android::sp<android::Surface>::make(producer, true); if (window == NULL) goto not_valid_surface; diff --git a/core/jni/android_os_HwBinder.cpp b/core/jni/android_os_HwBinder.cpp index 734b5f497e2e..8060e6232482 100644 --- a/core/jni/android_os_HwBinder.cpp +++ b/core/jni/android_os_HwBinder.cpp @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#undef ANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION // TODO:remove this and fix code //#define LOG_NDEBUG 0 #define LOG_TAG "android_os_HwBinder" diff --git a/core/jni/android_os_HwBlob.cpp b/core/jni/android_os_HwBlob.cpp index e554b44233b5..df579af0acb4 100644 --- a/core/jni/android_os_HwBlob.cpp +++ b/core/jni/android_os_HwBlob.cpp @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#undef ANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION // TODO:remove this and fix code //#define LOG_NDEBUG 0 #define LOG_TAG "android_os_HwBlob" diff --git a/core/jni/android_os_HwParcel.cpp b/core/jni/android_os_HwParcel.cpp index c7866524668f..727455c21e02 100644 --- a/core/jni/android_os_HwParcel.cpp +++ b/core/jni/android_os_HwParcel.cpp @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#undef ANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION // TODO:remove this and fix code //#define LOG_NDEBUG 0 #define LOG_TAG "android_os_HwParcel" diff --git a/core/jni/android_os_HwRemoteBinder.cpp b/core/jni/android_os_HwRemoteBinder.cpp index d2d7213e5761..3b567092f6a6 100644 --- a/core/jni/android_os_HwRemoteBinder.cpp +++ b/core/jni/android_os_HwRemoteBinder.cpp @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#undef ANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION // TODO:remove this and fix code //#define LOG_NDEBUG 0 #define LOG_TAG "JHwRemoteBinder" diff --git a/core/jni/android_os_MessageQueue.cpp b/core/jni/android_os_MessageQueue.cpp index 30d9ea19be39..d5d5521eb8c8 100644 --- a/core/jni/android_os_MessageQueue.cpp +++ b/core/jni/android_os_MessageQueue.cpp @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#undef ANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION // TODO:remove this and fix code #define LOG_TAG "MessageQueue-JNI" diff --git a/core/jni/android_tracing_PerfettoDataSource.cpp b/core/jni/android_tracing_PerfettoDataSource.cpp index fec28987e7e6..ea896e1678a7 100644 --- a/core/jni/android_tracing_PerfettoDataSource.cpp +++ b/core/jni/android_tracing_PerfettoDataSource.cpp @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#undef ANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION // TODO:remove this and fix code #define LOG_TAG "NativeJavaPerfettoDs" @@ -489,4 +490,4 @@ int register_android_tracing_PerfettoDataSource(JNIEnv* env) { return 0; } -} // namespace android
\ No newline at end of file +} // namespace android diff --git a/core/jni/android_util_Binder.cpp b/core/jni/android_util_Binder.cpp index e85b33e2f7b7..7f545164dbc3 100644 --- a/core/jni/android_util_Binder.cpp +++ b/core/jni/android_util_Binder.cpp @@ -13,9 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #define LOG_TAG "JavaBinder" -//#define LOG_NDEBUG 0 +// #define LOG_NDEBUG 0 #include "android_util_Binder.h" @@ -74,7 +73,6 @@ static struct bindernative_offsets_t jmethodID mExecTransact; jmethodID mGetInterfaceDescriptor; jmethodID mTransactionCallback; - jmethodID mGetExtension; // Object state. jfieldID mObject; @@ -479,7 +477,7 @@ public: if (b) return b; // b/360067751: constructor may trigger GC, so call outside lock - b = new JavaBBinder(env, obj); + b = sp<JavaBBinder>::make(env, obj); { AutoMutex _l(mLock); @@ -490,12 +488,8 @@ public: if (mVintf) { ::android::internal::Stability::markVintf(b.get()); } - if (mSetExtensionCalled) { - jobject javaIBinderObject = env->CallObjectMethod(obj, gBinderOffsets.mGetExtension); - sp<IBinder> extensionFromJava = ibinderForJavaObject(env, javaIBinderObject); - if (extensionFromJava != nullptr) { - b.get()->setExtension(extensionFromJava); - } + if (mExtension != nullptr) { + b.get()->setExtension(mExtension); } mBinder = b; ALOGV("Creating JavaBinder %p (refs %p) for Object %p, weakCount=%" PRId32 "\n", @@ -521,12 +515,21 @@ public: mVintf = false; } + sp<IBinder> getExtension() { + AutoMutex _l(mLock); + sp<JavaBBinder> b = mBinder.promote(); + if (b != nullptr) { + return b.get()->getExtension(); + } + return mExtension; + } + void setExtension(const sp<IBinder>& extension) { AutoMutex _l(mLock); - mSetExtensionCalled = true; + mExtension = extension; sp<JavaBBinder> b = mBinder.promote(); if (b != nullptr) { - b.get()->setExtension(extension); + b.get()->setExtension(mExtension); } } @@ -538,7 +541,8 @@ private: // is too much binder state here, we can think about making JavaBBinder an // sp here (avoid recreating it) bool mVintf = false; - bool mSetExtensionCalled = false; + + sp<IBinder> mExtension; }; // ---------------------------------------------------------------------------- @@ -640,11 +644,17 @@ public: } else { mObject = env->NewGlobalRef(object); } + } + + void onFirstRef() override { + T::onFirstRef(); + + sp<RecipientList<T>> list = mList.promote(); // These objects manage their own lifetimes so are responsible for final bookkeeping. // The list holds a strong reference to this object. LOG_DEATH_FREEZE("%s Adding JavaRecipient %p to RecipientList %p", logPrefix<T>(), this, list.get()); - list->add(this); + list->add(sp<JavaRecipient>::fromExisting(this)); } void clearReference() { @@ -652,7 +662,7 @@ public: if (list != NULL) { LOG_DEATH_FREEZE("%s Removing JavaRecipient %p from RecipientList %p", logPrefix<T>(), this, list.get()); - list->remove(this); + list->remove(sp<JavaRecipient>::fromExisting(this)); } else { LOG_DEATH_FREEZE("%s clearReference() on JavaRecipient %p but RecipientList wp purged", logPrefix<T>(), this); @@ -934,7 +944,7 @@ struct BinderProxyNativeData { // Frozen state change callbacks for mObject. Reference counted only because // JavaFrozenStateChangeCallback hold a weak reference that can be // temporarily promoted. - sp<FrozenStateChangeCallbackList> mFrozenStateChangCallbackList; + sp<FrozenStateChangeCallbackList> mFrozenStateChangeCallbackList; }; BinderProxyNativeData* getBPNativeData(JNIEnv* env, jobject obj) { @@ -959,8 +969,8 @@ jobject javaObjectForIBinder(JNIEnv* env, const sp<IBinder>& val) } BinderProxyNativeData* nativeData = new BinderProxyNativeData(); - nativeData->mOrgue = new DeathRecipientList; - nativeData->mFrozenStateChangCallbackList = new FrozenStateChangeCallbackList; + nativeData->mOrgue = sp<DeathRecipientList>::make(); + nativeData->mFrozenStateChangeCallbackList = sp<FrozenStateChangeCallbackList>::make(); nativeData->mObject = val; jobject object = env->CallStaticObjectMethod(gBinderProxyOffsets.mClass, @@ -1244,6 +1254,10 @@ static void android_os_Binder_blockUntilThreadAvailable(JNIEnv* env, jobject cla return IPCThreadState::self()->blockUntilThreadAvailable(); } +static jobject android_os_Binder_getExtension(JNIEnv* env, jobject obj) { + JavaBBinderHolder* jbh = (JavaBBinderHolder*) env->GetLongField(obj, gBinderOffsets.mObject); + return javaObjectForIBinder(env, jbh->getExtension()); +} static void android_os_Binder_setExtension(JNIEnv* env, jobject obj, jobject extensionObject) { JavaBBinderHolder* jbh = (JavaBBinderHolder*) env->GetLongField(obj, gBinderOffsets.mObject); @@ -1286,7 +1300,8 @@ static const JNINativeMethod gBinderMethods[] = { { "getNativeBBinderHolder", "()J", (void*)android_os_Binder_getNativeBBinderHolder }, { "getNativeFinalizer", "()J", (void*)android_os_Binder_getNativeFinalizer }, { "blockUntilThreadAvailable", "()V", (void*)android_os_Binder_blockUntilThreadAvailable }, - { "setExtensionNative", "(Landroid/os/IBinder;)V", (void*)android_os_Binder_setExtension }, + { "getExtension", "()Landroid/os/IBinder;", (void*)android_os_Binder_getExtension }, + { "setExtension", "(Landroid/os/IBinder;)V", (void*)android_os_Binder_setExtension }, }; // clang-format on @@ -1303,8 +1318,6 @@ static int int_register_android_os_Binder(JNIEnv* env) gBinderOffsets.mTransactionCallback = GetStaticMethodIDOrDie(env, clazz, "transactionCallback", "(IIII)V"); gBinderOffsets.mObject = GetFieldIDOrDie(env, clazz, "mObject", "J"); - gBinderOffsets.mGetExtension = GetMethodIDOrDie(env, clazz, "getExtension", - "()Landroid/os/IBinder;"); return RegisterMethodsOrDie( env, kBinderPathName, @@ -1563,8 +1576,8 @@ static void android_os_BinderProxy_linkToDeath(JNIEnv* env, jobject obj, LOG_DEATH_FREEZE("linkToDeath: binder=%p recipient=%p\n", target, recipient); if (!target->localBinder()) { - DeathRecipientList* list = nd->mOrgue.get(); - sp<JavaDeathRecipient> jdr = new JavaDeathRecipient(env, recipient, list); + sp<DeathRecipientList> list = nd->mOrgue; + sp<JavaDeathRecipient> jdr = sp<JavaDeathRecipient>::make(env, recipient, list); status_t err = target->linkToDeath(jdr, NULL, flags); if (err != NO_ERROR) { // Failure adding the death recipient, so clear its reference @@ -1640,7 +1653,7 @@ static void android_os_BinderProxy_addFrozenStateChangeCallback( LOG_DEATH_FREEZE("addFrozenStateChangeCallback: binder=%p callback=%p\n", target, callback); if (!target->localBinder()) { - FrozenStateChangeCallbackList* list = nd->mFrozenStateChangCallbackList.get(); + sp<FrozenStateChangeCallbackList> list = nd->mFrozenStateChangeCallbackList; auto jfscc = sp<JavaFrozenStateChangeCallback>::make(env, callback, list); status_t err = target->addFrozenStateChangeCallback(jfscc); if (err != NO_ERROR) { @@ -1674,7 +1687,7 @@ static jboolean android_os_BinderProxy_removeFrozenStateChangeCallback(JNIEnv* e status_t err = NAME_NOT_FOUND; // If we find the matching callback, proceed to unlink using that - FrozenStateChangeCallbackList* list = nd->mFrozenStateChangCallbackList.get(); + FrozenStateChangeCallbackList* list = nd->mFrozenStateChangeCallbackList.get(); sp<JavaRecipient<IBinder::FrozenStateChangeCallback> > origJFSCC = list->find(callback); LOG_DEATH_FREEZE(" removeFrozenStateChangeCallback found list %p and JFSCC %p", list, origJFSCC.get()); @@ -1703,7 +1716,7 @@ static void BinderProxy_destroy(void* rawNativeData) BinderProxyNativeData * nativeData = (BinderProxyNativeData *) rawNativeData; LOG_DEATH_FREEZE("Destroying BinderProxy: binder=%p drl=%p fsccl=%p\n", nativeData->mObject.get(), nativeData->mOrgue.get(), - nativeData->mFrozenStateChangCallbackList.get()); + nativeData->mFrozenStateChangeCallbackList.get()); delete nativeData; IPCThreadState::self()->flushCommands(); } diff --git a/core/jni/android_view_CompositionSamplingListener.cpp b/core/jni/android_view_CompositionSamplingListener.cpp index 59c01dc37593..28616a063730 100644 --- a/core/jni/android_view_CompositionSamplingListener.cpp +++ b/core/jni/android_view_CompositionSamplingListener.cpp @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#undef ANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION // TODO:remove this and fix code #define LOG_TAG "CompositionSamplingListener" diff --git a/core/jni/android_view_DisplayEventReceiver.cpp b/core/jni/android_view_DisplayEventReceiver.cpp index f007cc5a23bd..8587cb27523d 100644 --- a/core/jni/android_view_DisplayEventReceiver.cpp +++ b/core/jni/android_view_DisplayEventReceiver.cpp @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#undef ANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION // TODO:remove this and fix code #define LOG_TAG "DisplayEventReceiver" diff --git a/core/jni/android_view_InputEventReceiver.cpp b/core/jni/android_view_InputEventReceiver.cpp index 3a1e8835c8db..0b350c5721d8 100644 --- a/core/jni/android_view_InputEventReceiver.cpp +++ b/core/jni/android_view_InputEventReceiver.cpp @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#undef ANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION // TODO:remove this and fix code #define LOG_TAG "InputEventReceiver" #define ATRACE_TAG ATRACE_TAG_INPUT diff --git a/core/jni/android_view_InputEventSender.cpp b/core/jni/android_view_InputEventSender.cpp index 88b02baab924..01309b795567 100644 --- a/core/jni/android_view_InputEventSender.cpp +++ b/core/jni/android_view_InputEventSender.cpp @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#undef ANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION // TODO:remove this and fix code #define LOG_TAG "InputEventSender" diff --git a/core/jni/android_view_InputQueue.cpp b/core/jni/android_view_InputQueue.cpp index 50d2cbe2ce74..17165d8a03fe 100644 --- a/core/jni/android_view_InputQueue.cpp +++ b/core/jni/android_view_InputQueue.cpp @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#undef ANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION // TODO:remove this and fix code #define LOG_TAG "InputQueue" diff --git a/core/jni/android_view_Surface.cpp b/core/jni/android_view_Surface.cpp index ac6298d3d0b4..312c2067d396 100644 --- a/core/jni/android_view_Surface.cpp +++ b/core/jni/android_view_Surface.cpp @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#undef ANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION // TODO:remove this and fix code #define LOG_TAG "Surface" diff --git a/core/jni/android_view_SurfaceControl.cpp b/core/jni/android_view_SurfaceControl.cpp index 17c89f88b441..3f6698b8df14 100644 --- a/core/jni/android_view_SurfaceControl.cpp +++ b/core/jni/android_view_SurfaceControl.cpp @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#undef ANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION // TODO:remove this and fix code #define LOG_TAG "SurfaceControl" #define LOG_NDEBUG 0 diff --git a/core/jni/android_view_SurfaceControlHdrLayerInfoListener.cpp b/core/jni/android_view_SurfaceControlHdrLayerInfoListener.cpp index 443f99a78f02..09cb8116d04b 100644 --- a/core/jni/android_view_SurfaceControlHdrLayerInfoListener.cpp +++ b/core/jni/android_view_SurfaceControlHdrLayerInfoListener.cpp @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#undef ANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION // TODO:remove this and fix code #define LOG_TAG "SurfaceControlHdrLayerInfoListener" diff --git a/core/jni/android_view_SurfaceSession.cpp b/core/jni/android_view_SurfaceSession.cpp index 0aac07d17cdc..6ad109e80752 100644 --- a/core/jni/android_view_SurfaceSession.cpp +++ b/core/jni/android_view_SurfaceSession.cpp @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#undef ANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION // TODO:remove this and fix code #define LOG_TAG "SurfaceSession" diff --git a/core/jni/android_view_TextureView.cpp b/core/jni/android_view_TextureView.cpp index 391f515af115..21fe1f020b29 100644 --- a/core/jni/android_view_TextureView.cpp +++ b/core/jni/android_view_TextureView.cpp @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#undef ANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION // TODO:remove this and fix code #include "jni.h" #include <nativehelper/JNIHelp.h> diff --git a/core/jni/android_view_TunnelModeEnabledListener.cpp b/core/jni/android_view_TunnelModeEnabledListener.cpp index d9ab9571cfbe..fd78a94fc2d9 100644 --- a/core/jni/android_view_TunnelModeEnabledListener.cpp +++ b/core/jni/android_view_TunnelModeEnabledListener.cpp @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#undef ANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION // TODO:remove this and fix code #define LOG_TAG "TunnelModeEnabledListener" diff --git a/core/jni/android_window_InputTransferToken.cpp b/core/jni/android_window_InputTransferToken.cpp index 5bcea9b7c401..f92d128c7077 100644 --- a/core/jni/android_window_InputTransferToken.cpp +++ b/core/jni/android_window_InputTransferToken.cpp @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#undef ANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION // TODO:remove this and fix code #define LOG_TAG "InputTransferToken" @@ -137,4 +138,4 @@ int register_android_window_InputTransferToken(JNIEnv* env) { return err; } -} // namespace android
\ No newline at end of file +} // namespace android diff --git a/core/jni/android_window_ScreenCapture.cpp b/core/jni/android_window_ScreenCapture.cpp index 1a52fb74a1e9..59ff746a60a1 100644 --- a/core/jni/android_window_ScreenCapture.cpp +++ b/core/jni/android_window_ScreenCapture.cpp @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#undef ANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION // TODO:remove this and fix code #define LOG_TAG "ScreenCapture" // #define LOG_NDEBUG 0 diff --git a/core/jni/android_window_WindowInfosListener.cpp b/core/jni/android_window_WindowInfosListener.cpp index c39d5e20aa1c..30846ef99d60 100644 --- a/core/jni/android_window_WindowInfosListener.cpp +++ b/core/jni/android_window_WindowInfosListener.cpp @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#undef ANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION // TODO:remove this and fix code #define LOG_TAG "WindowInfosListener" diff --git a/core/jni/com_google_android_gles_jni_EGLImpl.cpp b/core/jni/com_google_android_gles_jni_EGLImpl.cpp index 5aea8485d0c1..75330be2624d 100644 --- a/core/jni/com_google_android_gles_jni_EGLImpl.cpp +++ b/core/jni/com_google_android_gles_jni_EGLImpl.cpp @@ -14,6 +14,7 @@ ** See the License for the specific language governing permissions and ** limitations under the License. */ +#undef ANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION // TODO:remove this and fix code #include <nativehelper/JNIHelp.h> #include <android_runtime/AndroidRuntime.h> diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml index 45c4ea08c09b..c084bdda5c01 100644 --- a/core/res/AndroidManifest.xml +++ b/core/res/AndroidManifest.xml @@ -8910,7 +8910,7 @@ android:permission="android.permission.BIND_JOB_SERVICE" > </service> - <service android:name="com.android.server.ZramMaintenance" + <service android:name="com.android.server.memory.ZramMaintenance" android:exported="false" android:permission="android.permission.BIND_JOB_SERVICE" > </service> diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index c01a8a95e021..c735b2712aed 100644 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -3183,6 +3183,14 @@ as private. {@see android.view.Display#FLAG_PRIVATE} --> <integer-array translatable="false" name="config_localPrivateDisplayPorts"></integer-array> + <!-- Controls if local secondary displays should be able to steal focus and become top display. + Value specified in the array represents physical port address of each display and displays + in this list due to flag dependencies will be marked with the following flags: + {@see android.view.Display#FLAG_STEAL_TOP_FOCUS_DISABLED} + {@see android.view.Display#FLAG_OWN_FOCUS} --> + <integer-array translatable="false" name="config_localNotStealTopFocusDisplayPorts"> + </integer-array> + <!-- The default mode for the default display. One of the following values (See Display.java): 0 - COLOR_MODE_DEFAULT 7 - COLOR_MODE_SRGB diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index a3d5be79cad2..cbdf5a1ecb1b 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -425,6 +425,7 @@ <java-symbol type="bool" name="config_enableProximityService" /> <java-symbol type="bool" name="config_enableVirtualDeviceManager" /> <java-symbol type="array" name="config_localPrivateDisplayPorts" /> + <java-symbol type="array" name="config_localNotStealTopFocusDisplayPorts" /> <java-symbol type="integer" name="config_defaultDisplayDefaultColorMode" /> <java-symbol type="bool" name="config_enableAppWidgetService" /> <java-symbol type="dimen" name="config_pictureInPictureMinAspectRatio" /> diff --git a/data/etc/OWNERS b/data/etc/OWNERS index 85dae631cac3..712042f6ff6b 100644 --- a/data/etc/OWNERS +++ b/data/etc/OWNERS @@ -5,7 +5,6 @@ hackbod@android.com hackbod@google.com jeffv@google.com jsharkey@android.com -jsharkey@google.com lorenzo@google.com yamasani@google.com diff --git a/libs/WindowManager/Shell/OWNERS b/libs/WindowManager/Shell/OWNERS index 394093c6ab30..ab2f3ef94eb6 100644 --- a/libs/WindowManager/Shell/OWNERS +++ b/libs/WindowManager/Shell/OWNERS @@ -1,7 +1,7 @@ -xutan@google.com +jorgegil@google.com pbdr@google.com pragyabajoria@google.com # Give submodule owners in shell resource approval -per-file res*/*/*.xml = atsjenk@google.com, hwwang@google.com, jorgegil@google.com, lbill@google.com, madym@google.com, vaniadesmonda@google.com, pbdr@google.com, tkachenkoi@google.com, mpodolian@google.com, liranb@google.com, pragyabajoria@google.com, uysalorhan@google.com, gsennton@google.com, mattsziklay@google.com, mdehaini@google.com +per-file res*/*/*.xml = atsjenk@google.com, hwwang@google.com, lbill@google.com, madym@google.com, vaniadesmonda@google.com, pbdr@google.com, mpodolian@google.com, liranb@google.com, pragyabajoria@google.com, uysalorhan@google.com, gsennton@google.com, mattsziklay@google.com, mdehaini@google.com per-file res*/*/tv_*.xml = bronger@google.com diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/OWNERS b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/OWNERS index afdda8ff865e..47b3ae8fc11b 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/OWNERS +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/OWNERS @@ -3,7 +3,6 @@ atsjenk@google.com jorgegil@google.com madym@google.com pbdr@google.com -tkachenkoi@google.com vaniadesmonda@google.com pragyabajoria@google.com uysalorhan@google.com diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/freeform/OWNERS b/libs/WindowManager/Shell/src/com/android/wm/shell/freeform/OWNERS index 83b5bf658459..44d46eea9c55 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/freeform/OWNERS +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/freeform/OWNERS @@ -4,7 +4,6 @@ jorgegil@google.com madym@google.com nmusgrave@google.com pbdr@google.com -tkachenkoi@google.com vaniadesmonda@google.com pragyabajoria@google.com uysalorhan@google.com diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/OWNERS b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/OWNERS index 3f828f547920..992402528f4f 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/OWNERS +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/OWNERS @@ -1,3 +1,2 @@ -jorgegil@google.com mattsziklay@google.com mdehaini@google.com diff --git a/libs/WindowManager/Shell/tests/OWNERS b/libs/WindowManager/Shell/tests/OWNERS index 65e50f86e8fe..5ba90ac66e78 100644 --- a/libs/WindowManager/Shell/tests/OWNERS +++ b/libs/WindowManager/Shell/tests/OWNERS @@ -11,7 +11,6 @@ atsjenk@google.com jorgegil@google.com vaniadesmonda@google.com pbdr@google.com -tkachenkoi@google.com mpodolian@google.com jeremysim@google.com peanutbutter@google.com diff --git a/libs/androidfw/Android.bp b/libs/androidfw/Android.bp index a13dd78a23a1..104ba018fb62 100644 --- a/libs/androidfw/Android.bp +++ b/libs/androidfw/Android.bp @@ -287,6 +287,7 @@ cc_benchmark { "tests/AttributeResolution_bench.cpp", "tests/CursorWindow_bench.cpp", "tests/Generic_bench.cpp", + "tests/LocaleDataLookup_bench.cpp", "tests/SparseEntry_bench.cpp", "tests/Theme_bench.cpp", ], diff --git a/libs/androidfw/LocaleDataLookup.cpp b/libs/androidfw/LocaleDataLookup.cpp index 6e751a77f355..ea9e9a2d4280 100644 --- a/libs/androidfw/LocaleDataLookup.cpp +++ b/libs/androidfw/LocaleDataLookup.cpp @@ -7518,6 +7518,13 @@ const char* lookupLikelyScript(uint32_t packed_lang_region) { } } +/* + * TODO: Consider turning the below switch statement into binary search + * to save the disk space when the table is larger in the future. + * Disassembled code shows that the jump table emitted by clang can be + * 4x larger than the data in disk size, but it depends on the optimization option. + * However, a switch statement will benefit from the future of compiler improvement. + */ bool isLocaleRepresentative(uint32_t language_and_region, const char* script) { const uint64_t packed_locale = ((static_cast<uint64_t>(language_and_region)) << 32u) | diff --git a/libs/androidfw/tests/LocaleDataLookup_bench.cpp b/libs/androidfw/tests/LocaleDataLookup_bench.cpp new file mode 100644 index 000000000000..60ce3b944551 --- /dev/null +++ b/libs/androidfw/tests/LocaleDataLookup_bench.cpp @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2025 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. + */ + +#include "benchmark/benchmark.h" + +#include "androidfw/LocaleDataLookup.h" + +namespace android { + +static void BM_LocaleDataLookupIsLocaleRepresentative(benchmark::State& state) { + for (auto&& _ : state) { + isLocaleRepresentative(packLocale("en", "US"), "Latn"); + isLocaleRepresentative(packLocale("es", "ES"), "Latn"); + isLocaleRepresentative(packLocale("zh", "CN"), "Hans"); + isLocaleRepresentative(packLocale("pt", "BR"), "Latn"); + isLocaleRepresentative(packLocale("ar", "EG"), "Arab"); + isLocaleRepresentative(packLocale("hi", "IN"), "Deva"); + isLocaleRepresentative(packLocale("jp", "JP"), "Jpan"); + } +} +BENCHMARK(BM_LocaleDataLookupIsLocaleRepresentative); + +static void BM_LocaleDataLookupLikelyScript(benchmark::State& state) { + for (auto&& _ : state) { + lookupLikelyScript(packLocale("en", "")); + lookupLikelyScript(packLocale("es", "")); + lookupLikelyScript(packLocale("zh", "")); + lookupLikelyScript(packLocale("pt", "")); + lookupLikelyScript(packLocale("ar", "")); + lookupLikelyScript(packLocale("hi", "")); + lookupLikelyScript(packLocale("jp", "")); + lookupLikelyScript(packLocale("en", "US")); + lookupLikelyScript(packLocale("es", "ES")); + lookupLikelyScript(packLocale("zh", "CN")); + lookupLikelyScript(packLocale("pt", "BR")); + lookupLikelyScript(packLocale("ar", "EG")); + lookupLikelyScript(packLocale("hi", "IN")); + lookupLikelyScript(packLocale("jp", "JP")); + } +} +BENCHMARK(BM_LocaleDataLookupLikelyScript); + + +} // namespace android diff --git a/libs/hwui/OWNERS b/libs/hwui/OWNERS index bc174599a4d3..70d13ab8b3e5 100644 --- a/libs/hwui/OWNERS +++ b/libs/hwui/OWNERS @@ -4,7 +4,6 @@ alecmouri@google.com djsollen@google.com jreck@google.com njawad@google.com -scroggo@google.com sumir@google.com # For text, e.g. Typeface, Font, Minikin, etc. diff --git a/media/java/android/media/MediaCodec.java b/media/java/android/media/MediaCodec.java index c9625c405faa..871fadfc5308 100644 --- a/media/java/android/media/MediaCodec.java +++ b/media/java/android/media/MediaCodec.java @@ -44,6 +44,7 @@ import android.os.IHwBinder; import android.os.Looper; import android.os.Message; import android.os.PersistableBundle; +import android.os.Trace; import android.view.Surface; import java.io.IOException; @@ -3103,6 +3104,7 @@ final public class MediaCodec { int index, int offset, int size, long presentationTimeUs, int flags) throws CryptoException { + Trace.traceBegin(Trace.TRACE_TAG_VIDEO, "MediaCodec::queueInputBuffer#java"); if ((flags & BUFFER_FLAG_DECODE_ONLY) != 0 && (flags & BUFFER_FLAG_END_OF_STREAM) != 0) { throw new InvalidBufferFlagsException(EOS_AND_DECODE_ONLY_ERROR_MESSAGE); @@ -3122,6 +3124,8 @@ final public class MediaCodec { } catch (CryptoException | IllegalStateException e) { revalidateByteBuffer(mCachedInputBuffers, index, true /* input */); throw e; + } finally { + Trace.traceEnd(Trace.TRACE_TAG_VIDEO); } } @@ -3163,6 +3167,7 @@ final public class MediaCodec { public final void queueInputBuffers( int index, @NonNull ArrayDeque<BufferInfo> bufferInfos) { + Trace.traceBegin(Trace.TRACE_TAG_VIDEO, "MediaCodec::queueInputBuffers#java"); synchronized(mBufferLock) { if (mBufferMode == BUFFER_MODE_BLOCK) { throw new IncompatibleWithBlockModelException("queueInputBuffers() " @@ -3178,6 +3183,8 @@ final public class MediaCodec { } catch (CryptoException | IllegalStateException | IllegalArgumentException e) { revalidateByteBuffer(mCachedInputBuffers, index, true /* input */); throw e; + } finally { + Trace.traceEnd(Trace.TRACE_TAG_VIDEO); } } @@ -3438,6 +3445,7 @@ final public class MediaCodec { @NonNull CryptoInfo info, long presentationTimeUs, int flags) throws CryptoException { + Trace.traceBegin(Trace.TRACE_TAG_VIDEO, "MediaCodec::queueSecureInputBuffer#java"); if ((flags & BUFFER_FLAG_DECODE_ONLY) != 0 && (flags & BUFFER_FLAG_END_OF_STREAM) != 0) { throw new InvalidBufferFlagsException(EOS_AND_DECODE_ONLY_ERROR_MESSAGE); @@ -3457,6 +3465,8 @@ final public class MediaCodec { } catch (CryptoException | IllegalStateException e) { revalidateByteBuffer(mCachedInputBuffers, index, true /* input */); throw e; + } finally { + Trace.traceEnd(Trace.TRACE_TAG_VIDEO); } } @@ -3487,6 +3497,7 @@ final public class MediaCodec { int index, @NonNull ArrayDeque<BufferInfo> bufferInfos, @NonNull ArrayDeque<CryptoInfo> cryptoInfos) { + Trace.traceBegin(Trace.TRACE_TAG_VIDEO, "MediaCodec::queueSecureInputBuffers#java"); synchronized(mBufferLock) { if (mBufferMode == BUFFER_MODE_BLOCK) { throw new IncompatibleWithBlockModelException("queueSecureInputBuffers() " @@ -3502,6 +3513,8 @@ final public class MediaCodec { } catch (CryptoException | IllegalStateException | IllegalArgumentException e) { revalidateByteBuffer(mCachedInputBuffers, index, true /* input */); throw e; + } finally { + Trace.traceEnd(Trace.TRACE_TAG_VIDEO); } } @@ -3529,6 +3542,7 @@ final public class MediaCodec { * @throws MediaCodec.CodecException upon codec error. */ public final int dequeueInputBuffer(long timeoutUs) { + Trace.traceBegin(Trace.TRACE_TAG_VIDEO, "MediaCodec::dequeueInputBuffer#java"); synchronized (mBufferLock) { if (mBufferMode == BUFFER_MODE_BLOCK) { throw new IncompatibleWithBlockModelException("dequeueInputBuffer() " @@ -3542,6 +3556,7 @@ final public class MediaCodec { validateInputByteBufferLocked(mCachedInputBuffers, res); } } + Trace.traceEnd(Trace.TRACE_TAG_VIDEO); return res; } diff --git a/media/java/android/media/session/MediaSessionManager.java b/media/java/android/media/session/MediaSessionManager.java index 371b47fe3421..22f4182ee37b 100644 --- a/media/java/android/media/session/MediaSessionManager.java +++ b/media/java/android/media/session/MediaSessionManager.java @@ -155,11 +155,6 @@ public final class MediaSessionManager { } /** - * This API is not generally intended for third party application developers. - * Use the <a href="{@docRoot}jetpack/androidx.html">AndroidX</a> - * <a href="{@docRoot}reference/androidx/media2/session/package-summary.html">Media2 session - * Library</a> for consistent behavior across all devices. - * <p> * Notifies that a new {@link MediaSession2} with type {@link Session2Token#TYPE_SESSION} is * created. * <p> @@ -283,16 +278,16 @@ public final class MediaSessionManager { } /** - * This API is not generally intended for third party application developers. - * Use the <a href="{@docRoot}jetpack/androidx.html">AndroidX</a> - * <a href="{@docRoot}reference/androidx/media2/session/package-summary.html">Media2 session - * Library</a> for consistent behavior across all devices. - * <p> * Gets a list of {@link Session2Token} with type {@link Session2Token#TYPE_SESSION} for the * current user. * <p> * Although this API can be used without any restriction, each session owners can accept or * reject your uses of {@link MediaSession2}. + * <p> + * This API is not generally intended for third party application developers. Apps wanting media + * session functionality should use the + * <a href="{@docRoot}reference/androidx/media3/session/package-summary.html">AndroidX Media3 + * Session Library</a>. * * @return A list of {@link Session2Token}. */ @@ -417,12 +412,12 @@ public final class MediaSessionManager { } /** - * This API is not generally intended for third party application developers. - * Use the <a href="{@docRoot}jetpack/androidx.html">AndroidX</a> - * <a href="{@docRoot}reference/androidx/media2/session/package-summary.html">Media2 session - * Library</a> for consistent behavior across all devices. - * <p> * Adds a listener to be notified when the {@link #getSession2Tokens()} changes. + * <p> + * This API is not generally intended for third party application developers. Apps wanting media + * session functionality should use the + * <a href="{@docRoot}reference/androidx/media3/session/package-summary.html">AndroidX Media3 + * Session Library</a>. * * @param listener The listener to add */ @@ -433,12 +428,12 @@ public final class MediaSessionManager { } /** - * This API is not generally intended for third party application developers. - * Use the <a href="{@docRoot}jetpack/androidx.html">AndroidX</a> - * <a href="{@docRoot}reference/androidx/media2/session/package-summary.html">Media2 session - * Library</a> for consistent behavior across all devices. - * <p> * Adds a listener to be notified when the {@link #getSession2Tokens()} changes. + * <p> + * This API is not generally intended for third party application developers. Apps wanting media + * session functionality should use the + * <a href="{@docRoot}reference/androidx/media3/session/package-summary.html">AndroidX Media3 + * Session Library</a>. * * @param listener The listener to add * @param handler The handler to call listener on. @@ -451,16 +446,16 @@ public final class MediaSessionManager { } /** - * This API is not generally intended for third party application developers. - * Use the <a href="{@docRoot}jetpack/androidx.html">AndroidX</a> - * <a href="{@docRoot}reference/androidx/media2/session/package-summary.html">Media2 session - * Library</a> for consistent behavior across all devices. - * <p> * Adds a listener to be notified when the {@link #getSession2Tokens()} changes. * <p> * The calling application needs to hold the * {@link android.Manifest.permission#INTERACT_ACROSS_USERS_FULL} permission in order to * add listeners for user ids that do not belong to current process. + * <p> + * This API is not generally intended for third party application developers. Apps wanting media + * session functionality should use the + * <a href="{@docRoot}reference/androidx/media3/session/package-summary.html">AndroidX Media3 + * Session Library</a>. * * @param userHandle The userHandle to listen for changes on * @param listener The listener to add @@ -496,12 +491,12 @@ public final class MediaSessionManager { } /** - * This API is not generally intended for third party application developers. - * Use the <a href="{@docRoot}jetpack/androidx.html">AndroidX</a> - * <a href="{@docRoot}reference/androidx/media2/session/package-summary.html">Media2 session - * Library</a> for consistent behavior across all devices. - * <p> * Removes the {@link OnSession2TokensChangedListener} to stop receiving session token updates. + * <p> + * This API is not generally intended for third party application developers. Apps wanting media + * session functionality should use the + * <a href="{@docRoot}reference/androidx/media3/session/package-summary.html">AndroidX Media3 + * Session Library</a>. * * @param listener The listener to remove. */ @@ -1061,13 +1056,13 @@ public final class MediaSessionManager { } /** - * This API is not generally intended for third party application developers. - * Use the <a href="{@docRoot}jetpack/androidx.html">AndroidX</a> - * <a href="{@docRoot}reference/androidx/media2/session/package-summary.html">Media2 session - * Library</a> for consistent behavior across all devices. - * <p> * Listens for changes to the {@link #getSession2Tokens()}. This can be added * using {@link #addOnSession2TokensChangedListener(OnSession2TokensChangedListener, Handler)}. + * <p> + * This API is not generally intended for third party application developers. Apps wanting media + * session functionality should use the + * <a href="{@docRoot}reference/androidx/media3/session/package-summary.html">AndroidX Media3 + * Session Library</a>. */ public interface OnSession2TokensChangedListener { /** diff --git a/media/jni/android_media_MediaCodec.cpp b/media/jni/android_media_MediaCodec.cpp index 8419ce761a4a..61c287b9633c 100644 --- a/media/jni/android_media_MediaCodec.cpp +++ b/media/jni/android_media_MediaCodec.cpp @@ -16,7 +16,9 @@ //#define LOG_NDEBUG 0 #define LOG_TAG "MediaCodec-JNI" +#define ATRACE_TAG ATRACE_TAG_VIDEO #include <utils/Log.h> +#include <utils/Trace.h> #include <type_traits> @@ -1230,63 +1232,73 @@ static void AMessageToCryptoInfo(JNIEnv * env, const jobject & obj, sp<ABuffer> ivBuffer; CryptoPlugin::Mode mode; CryptoPlugin::Pattern pattern; - CHECK(msg->findInt32("mode", (int*)&mode)); - CHECK(msg->findSize("numSubSamples", &numSubSamples)); - CHECK(msg->findBuffer("subSamples", &subSamplesBuffer)); - CHECK(msg->findInt32("encryptBlocks", (int32_t *)&pattern.mEncryptBlocks)); - CHECK(msg->findInt32("skipBlocks", (int32_t *)&pattern.mSkipBlocks)); - CHECK(msg->findBuffer("iv", &ivBuffer)); - CHECK(msg->findBuffer("key", &keyBuffer)); - - // subsamples + CryptoPlugin::SubSample *samplesArray = nullptr; + ScopedLocalRef<jbyteArray> keyArray(env, env->NewByteArray(16)); + ScopedLocalRef<jbyteArray> ivArray(env, env->NewByteArray(16)); + jboolean isCopy; + sp<RefBase> cryptoInfosObj; + if (msg->findObject("cryptoInfos", &cryptoInfosObj)) { + sp<CryptoInfosWrapper> cryptoInfos((CryptoInfosWrapper*)cryptoInfosObj.get()); + CHECK(!cryptoInfos->value.empty() && (cryptoInfos->value[0] != nullptr)); + std::unique_ptr<CodecCryptoInfo> &info = cryptoInfos->value[0]; + mode = info->mMode; + numSubSamples = info->mNumSubSamples; + samplesArray = info->mSubSamples; + pattern = info->mPattern; + if (info->mKey != nullptr) { + jbyte * dstKey = env->GetByteArrayElements(keyArray.get(), &isCopy); + memcpy(dstKey, info->mKey, 16); + env->ReleaseByteArrayElements(keyArray.get(), dstKey, 0); + } + if (info->mIv != nullptr) { + jbyte * dstIv = env->GetByteArrayElements(ivArray.get(), &isCopy); + memcpy(dstIv, info->mIv, 16); + env->ReleaseByteArrayElements(ivArray.get(), dstIv, 0); + } + } else { + CHECK(msg->findInt32("mode", (int*)&mode)); + CHECK(msg->findSize("numSubSamples", &numSubSamples)); + CHECK(msg->findBuffer("subSamples", &subSamplesBuffer)); + CHECK(msg->findInt32("encryptBlocks", (int32_t *)&pattern.mEncryptBlocks)); + CHECK(msg->findInt32("skipBlocks", (int32_t *)&pattern.mSkipBlocks)); + CHECK(msg->findBuffer("iv", &ivBuffer)); + CHECK(msg->findBuffer("key", &keyBuffer)); + samplesArray = + (CryptoPlugin::SubSample*)(subSamplesBuffer.get()->data()); + if (keyBuffer.get() != nullptr && keyBuffer->size() > 0) { + jbyte * dstKey = env->GetByteArrayElements(keyArray.get(), &isCopy); + memcpy(dstKey, keyBuffer->data(), keyBuffer->size()); + env->ReleaseByteArrayElements(keyArray.get(), dstKey, 0); + } + if (ivBuffer.get() != nullptr && ivBuffer->size() > 0) { + jbyte * dstIv = env->GetByteArrayElements(ivArray.get(), &isCopy); + memcpy(dstIv, ivBuffer->data(), ivBuffer->size()); + env->ReleaseByteArrayElements(ivArray.get(), dstIv, 0); + } + } ScopedLocalRef<jintArray> samplesOfEncryptedDataArr(env, env->NewIntArray(numSubSamples)); ScopedLocalRef<jintArray> samplesOfClearDataArr(env, env->NewIntArray(numSubSamples)); - jboolean isCopy; - jint *dstEncryptedSamples = - env->GetIntArrayElements(samplesOfEncryptedDataArr.get(), &isCopy); - jint * dstClearSamples = - env->GetIntArrayElements(samplesOfClearDataArr.get(), &isCopy); - - CryptoPlugin::SubSample * samplesArray = - (CryptoPlugin::SubSample*)(subSamplesBuffer.get()->data()); - - for(int i = 0 ; i < numSubSamples ; i++) { - dstEncryptedSamples[i] = samplesArray[i].mNumBytesOfEncryptedData; - dstClearSamples[i] = samplesArray[i].mNumBytesOfClearData; - } - env->ReleaseIntArrayElements(samplesOfEncryptedDataArr.get(), dstEncryptedSamples, 0); - env->ReleaseIntArrayElements(samplesOfClearDataArr.get(), dstClearSamples, 0); - // key and iv - jbyteArray keyArray = NULL; - jbyteArray ivArray = NULL; - if (keyBuffer.get() != nullptr && keyBuffer->size() > 0) { - keyArray = env->NewByteArray(keyBuffer->size()); - jbyte * dstKey = env->GetByteArrayElements(keyArray, &isCopy); - memcpy(dstKey, keyBuffer->data(), keyBuffer->size()); - env->ReleaseByteArrayElements(keyArray,dstKey,0); - } - if (ivBuffer.get() != nullptr && ivBuffer->size() > 0) { - ivArray = env->NewByteArray(ivBuffer->size()); - jbyte *dstIv = env->GetByteArrayElements(ivArray, &isCopy); - memcpy(dstIv, ivBuffer->data(), ivBuffer->size()); - env->ReleaseByteArrayElements(ivArray, dstIv,0); - } - // set samples, key and iv + if (numSubSamples > 0) { + jint *dstEncryptedSamples = + env->GetIntArrayElements(samplesOfEncryptedDataArr.get(), &isCopy); + jint * dstClearSamples = + env->GetIntArrayElements(samplesOfClearDataArr.get(), &isCopy); + for(int i = 0 ; i < numSubSamples ; i++) { + dstEncryptedSamples[i] = samplesArray[i].mNumBytesOfEncryptedData; + dstClearSamples[i] = samplesArray[i].mNumBytesOfClearData; + } + env->ReleaseIntArrayElements(samplesOfEncryptedDataArr.get(), dstEncryptedSamples, 0); + env->ReleaseIntArrayElements(samplesOfClearDataArr.get(), dstClearSamples, 0); + } env->CallVoidMethod( obj, gFields.cryptoInfoSetID, (jint)numSubSamples, samplesOfClearDataArr.get(), samplesOfEncryptedDataArr.get(), - keyArray, - ivArray, + keyArray.get(), + ivArray.get(), mode); - if (keyArray != NULL) { - env->DeleteLocalRef(keyArray); - } - if (ivArray != NULL) { - env->DeleteLocalRef(ivArray); - } // set pattern env->CallVoidMethod( obj, @@ -2106,7 +2118,7 @@ static void android_media_MediaCodec_queueInputBuffer( jlong timestampUs, jint flags) { ALOGV("android_media_MediaCodec_queueInputBuffer"); - + ScopedTrace trace(ATRACE_TAG, "MediaCodec::queueInputBuffer#jni"); sp<JMediaCodec> codec = getMediaCodec(env, thiz); if (codec == NULL || codec->initCheck() != OK) { @@ -2192,6 +2204,7 @@ static void android_media_MediaCodec_queueInputBuffers( jint index, jobjectArray objArray) { ALOGV("android_media_MediaCodec_queueInputBuffers"); + ScopedTrace trace(ATRACE_TAG, "MediaCodec::queueInputBuffers#jni"); sp<JMediaCodec> codec = getMediaCodec(env, thiz); if (codec == NULL || codec->initCheck() != OK || objArray == NULL) { throwExceptionAsNecessary(env, INVALID_OPERATION, codec); @@ -2431,6 +2444,7 @@ static void android_media_MediaCodec_queueSecureInputBuffer( jobject cryptoInfoObj, jlong timestampUs, jint flags) { + ScopedTrace trace(ATRACE_TAG, "MediaCodec::queueSecureInputBuffer#jni"); ALOGV("android_media_MediaCodec_queueSecureInputBuffer"); sp<JMediaCodec> codec = getMediaCodec(env, thiz); @@ -2641,6 +2655,7 @@ static void android_media_MediaCodec_queueSecureInputBuffers( jint index, jobjectArray bufferInfosObjs, jobjectArray cryptoInfoObjs) { + ScopedTrace trace(ATRACE_TAG, "MediaCodec::queueSecureInputBuffers#jni"); ALOGV("android_media_MediaCodec_queueSecureInputBuffers"); sp<JMediaCodec> codec = getMediaCodec(env, thiz); @@ -2685,6 +2700,7 @@ static void android_media_MediaCodec_queueSecureInputBuffers( } static jobject android_media_MediaCodec_mapHardwareBuffer(JNIEnv *env, jclass, jobject bufferObj) { + ScopedTrace trace(ATRACE_TAG, "MediaCodec::mapHardwareBuffer#jni"); ALOGV("android_media_MediaCodec_mapHardwareBuffer"); AHardwareBuffer *hardwareBuffer = android_hardware_HardwareBuffer_getNativeHardwareBuffer( env, bufferObj); @@ -3028,6 +3044,7 @@ static void extractBufferFromContext( static void android_media_MediaCodec_native_queueLinearBlock( JNIEnv *env, jobject thiz, jint index, jobject bufferObj, jobjectArray cryptoInfoArray, jobjectArray objArray, jobject keys, jobject values) { + ScopedTrace trace(ATRACE_TAG, "MediaCodec::queueLinearBlock#jni"); ALOGV("android_media_MediaCodec_native_queueLinearBlock"); sp<JMediaCodec> codec = getMediaCodec(env, thiz); @@ -3145,6 +3162,7 @@ static void android_media_MediaCodec_native_queueHardwareBuffer( JNIEnv *env, jobject thiz, jint index, jobject bufferObj, jlong presentationTimeUs, jint flags, jobject keys, jobject values) { ALOGV("android_media_MediaCodec_native_queueHardwareBuffer"); + ScopedTrace trace(ATRACE_TAG, "MediaCodec::queueHardwareBuffer#jni"); sp<JMediaCodec> codec = getMediaCodec(env, thiz); diff --git a/nfc-non-updatable/flags/flags.aconfig b/nfc-non-updatable/flags/flags.aconfig index 54ded0cddffa..eb30bbe1bfe7 100644 --- a/nfc-non-updatable/flags/flags.aconfig +++ b/nfc-non-updatable/flags/flags.aconfig @@ -198,10 +198,6 @@ flag { bug: "380892385" } -flag { - name: "nfc_hce_latency_events" - is_exported: true - namespace: "wallet_integration" - description: "Enables tracking latency for HCE" - bug: "379849603" -} +# Unless you are adding a flag for a file under nfc-non-updatable, you should +# not add a flag here for Android 16+ targeting features. Use the flags +# in com.android.nfc.module.flags (packages/modules/Nfc/flags) instead. diff --git a/nfc-non-updatable/java/android/nfc/cardemulation/ApduServiceInfo.java b/nfc-non-updatable/java/android/nfc/cardemulation/ApduServiceInfo.java index 93d6eb73dcae..e83b9f1afddb 100644 --- a/nfc-non-updatable/java/android/nfc/cardemulation/ApduServiceInfo.java +++ b/nfc-non-updatable/java/android/nfc/cardemulation/ApduServiceInfo.java @@ -572,8 +572,10 @@ public final class ApduServiceInfo implements Parcelable { if (mAutoTransact.getOrDefault(plf.toUpperCase(Locale.ROOT), false)) { return true; } - List<Pattern> patternMatches = mAutoTransactPatterns.keySet().stream() - .filter(p -> p.matcher(plf).matches()).toList(); + boolean isPattern = plf.contains("?") || plf.contains("*"); + List<Pattern> patternMatches = mAutoTransactPatterns.keySet().stream().filter( + p -> isPattern ? p.toString().equals(plf) : p.matcher(plf).matches()).toList(); + if (patternMatches == null || patternMatches.size() == 0) { return false; } diff --git a/packages/SettingsLib/src/com/android/settingslib/media/OWNERS b/packages/SettingsLib/src/com/android/settingslib/media/OWNERS index d58add4bb5eb..a34876dd1e0e 100644 --- a/packages/SettingsLib/src/com/android/settingslib/media/OWNERS +++ b/packages/SettingsLib/src/com/android/settingslib/media/OWNERS @@ -3,5 +3,8 @@ ethibodeau@google.com michaelmikhil@google.com apotapov@google.com +# Output Switcher OWNERS +file:/packages/SystemUI/src/com/android/systemui/media/dialog/OWNERS + #Android Media - For minor changes and renames only. aquilescanta@google.com #{LAST_RESORT_SUGGESTION} diff --git a/packages/SystemUI/OWNERS b/packages/SystemUI/OWNERS index 7fadcc4e6065..09c0cf7a2ac1 100644 --- a/packages/SystemUI/OWNERS +++ b/packages/SystemUI/OWNERS @@ -13,7 +13,6 @@ alexflo@google.com andonian@google.com amiko@google.com austindelgado@google.com -aroederer@google.com arteiro@google.com asc@google.com awickham@google.com @@ -103,7 +102,6 @@ stwu@google.com syeonlee@google.com sunnygoyal@google.com thiruram@google.com -tkachenkoi@google.com tracyzhou@google.com tsuji@google.com twickham@google.com diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/OWNERS b/packages/SystemUI/src/com/android/systemui/accessibility/OWNERS index 1ed8c068f974..5a59b7aaef56 100644 --- a/packages/SystemUI/src/com/android/systemui/accessibility/OWNERS +++ b/packages/SystemUI/src/com/android/systemui/accessibility/OWNERS @@ -1,4 +1,7 @@ -# Bug component: 44215 +# Bug component: 1530954 +# +# The above component is for automated test bugs. If you are a human looking to report +# a bug in this codebase then please use component 44215. include /core/java/android/view/accessibility/OWNERS jonesriley@google.com
\ No newline at end of file diff --git a/packages/SystemUI/src/com/android/systemui/ailabs/OWNERS b/packages/SystemUI/src/com/android/systemui/ailabs/OWNERS index b65d29c6a0bb..429b4b0fccab 100644 --- a/packages/SystemUI/src/com/android/systemui/ailabs/OWNERS +++ b/packages/SystemUI/src/com/android/systemui/ailabs/OWNERS @@ -5,5 +5,4 @@ linyuh@google.com pauldpong@google.com praveenj@google.com vicliang@google.com -mfolkerts@google.com yuklimko@google.com diff --git a/packages/SystemUI/src/com/android/systemui/notetask/OWNERS b/packages/SystemUI/src/com/android/systemui/notetask/OWNERS index 0ec996be72de..9b4902a9e7b2 100644 --- a/packages/SystemUI/src/com/android/systemui/notetask/OWNERS +++ b/packages/SystemUI/src/com/android/systemui/notetask/OWNERS @@ -6,5 +6,4 @@ madym@google.com mgalhardo@google.com petrcermak@google.com stevenckng@google.com -tkachenkoi@google.com -vanjan@google.com
\ No newline at end of file +vanjan@google.com diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/OWNERS b/packages/SystemUI/src/com/android/systemui/statusbar/notification/OWNERS index 5558ab1e2af2..d284cde2356f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/OWNERS +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/OWNERS @@ -3,7 +3,6 @@ set noparent # Bug component: 78010 aioana@google.com -aroederer@google.com iyz@google.com jeffdq@google.com juliacr@google.com diff --git a/packages/SystemUI/src/com/android/systemui/stylus/OWNERS b/packages/SystemUI/src/com/android/systemui/stylus/OWNERS index 0ec996be72de..9b4902a9e7b2 100644 --- a/packages/SystemUI/src/com/android/systemui/stylus/OWNERS +++ b/packages/SystemUI/src/com/android/systemui/stylus/OWNERS @@ -6,5 +6,4 @@ madym@google.com mgalhardo@google.com petrcermak@google.com stevenckng@google.com -tkachenkoi@google.com -vanjan@google.com
\ No newline at end of file +vanjan@google.com diff --git a/packages/SystemUI/tests/src/com/android/systemui/notetask/OWNERS b/packages/SystemUI/tests/src/com/android/systemui/notetask/OWNERS index 0ec996be72de..9b4902a9e7b2 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/notetask/OWNERS +++ b/packages/SystemUI/tests/src/com/android/systemui/notetask/OWNERS @@ -6,5 +6,4 @@ madym@google.com mgalhardo@google.com petrcermak@google.com stevenckng@google.com -tkachenkoi@google.com -vanjan@google.com
\ No newline at end of file +vanjan@google.com diff --git a/packages/SystemUI/tests/src/com/android/systemui/stylus/OWNERS b/packages/SystemUI/tests/src/com/android/systemui/stylus/OWNERS index 0ec996be72de..9b4902a9e7b2 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/stylus/OWNERS +++ b/packages/SystemUI/tests/src/com/android/systemui/stylus/OWNERS @@ -6,5 +6,4 @@ madym@google.com mgalhardo@google.com petrcermak@google.com stevenckng@google.com -tkachenkoi@google.com -vanjan@google.com
\ No newline at end of file +vanjan@google.com diff --git a/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodRuntimeEnvironmentController.java b/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodRuntimeEnvironmentController.java index 3cb6c5a6bd16..7af03ed2e6c8 100644 --- a/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodRuntimeEnvironmentController.java +++ b/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodRuntimeEnvironmentController.java @@ -44,6 +44,7 @@ import android.app.UiAutomation; import android.content.Context; import android.content.pm.ApplicationInfo; import android.content.res.Resources; +import android.icu.util.ULocale; import android.os.Binder; import android.os.Build; import android.os.Build.VERSION_CODES; @@ -81,6 +82,7 @@ import java.io.IOException; import java.io.PrintStream; import java.util.Collections; import java.util.HashMap; +import java.util.Locale; import java.util.Map; import java.util.Objects; import java.util.Random; @@ -228,6 +230,9 @@ public class RavenwoodRuntimeEnvironmentController { RuntimeInit.redirectLogStreams(); dumpCommandLineArgs(); + dumpEnvironment(); + dumpJavaProperties(); + dumpOtherInfo(); // We haven't initialized liblog yet, so directly write to System.out here. RavenwoodCommonUtils.log(TAG, "globalInitInner()"); @@ -564,4 +569,34 @@ public class RavenwoodRuntimeEnvironmentController { Log.v(TAG, " " + arg); } } + + private static void dumpJavaProperties() { + Log.v(TAG, "JVM properties:"); + dumpMap(System.getProperties()); + } + + private static void dumpEnvironment() { + Log.v(TAG, "Environment:"); + dumpMap(System.getenv()); + } + + private static void dumpMap(Map<?, ?> map) { + for (var key : map.keySet().stream().sorted().toList()) { + Log.v(TAG, " " + key + "=" + map.get(key)); + } + } + + private static void dumpOtherInfo() { + Log.v(TAG, "Other key information:"); + var jloc = Locale.getDefault(); + Log.v(TAG, " java.util.Locale=" + jloc + " / " + jloc.toLanguageTag()); + var uloc = ULocale.getDefault(); + Log.v(TAG, " android.icu.util.ULocale=" + uloc + " / " + uloc.toLanguageTag()); + + var jtz = java.util.TimeZone.getDefault(); + Log.v(TAG, " java.util.TimeZone=" + jtz.getDisplayName() + " / " + jtz); + + var itz = android.icu.util.TimeZone.getDefault(); + Log.v(TAG, " android.icu.util.TimeZone=" + itz.getDisplayName() + " / " + itz); + } } diff --git a/services/accessibility/OWNERS b/services/accessibility/OWNERS index 4e1175034b5b..ab1e9ffe3bfe 100644 --- a/services/accessibility/OWNERS +++ b/services/accessibility/OWNERS @@ -1,4 +1,7 @@ -# Bug component: 44215 +# Bug component: 1530954 +# +# The above component is for automated test bugs. If you are a human looking to report +# a bug in this codebase then please use component 44215. # Android Accessibility Framework owners danielnorman@google.com diff --git a/services/accessibility/java/com/android/server/accessibility/magnification/OWNERS b/services/accessibility/java/com/android/server/accessibility/magnification/OWNERS new file mode 100644 index 000000000000..ff812ad7e7e6 --- /dev/null +++ b/services/accessibility/java/com/android/server/accessibility/magnification/OWNERS @@ -0,0 +1,8 @@ +# Bug component: 1530954 +# +# The above component is for automated test bugs. If you are a human looking to report +# a bug in this codebase then please use component 770744. + +juchengchou@google.com +chenjean@google.com +chihtinglo@google.com diff --git a/services/core/Android.bp b/services/core/Android.bp index 717a2d46be0b..22763f1cf729 100644 --- a/services/core/Android.bp +++ b/services/core/Android.bp @@ -243,6 +243,7 @@ java_library_static { "aconfig_new_storage_flags_lib", "powerstats_flags_lib", "locksettings_flags_lib", + "MmdProperties", "mmd_flags_lib", ], javac_shard_size: 50, @@ -274,9 +275,18 @@ java_genrule { out: ["services.core.priorityboosted.jar"], } +java_genrule_combiner { + name: "services.core.combined", + static_libs: ["services.core.priorityboosted"], + headers: ["services.core.unboosted"], +} + java_library { name: "services.core", - static_libs: ["services.core.priorityboosted"], + static_libs: select(release_flag("RELEASE_SERVICES_JAVA_GENRULE_COMBINER"), { + true: ["services.core.combined"], + default: ["services.core.priorityboosted"], + }), } java_library_host { diff --git a/services/core/java/com/android/server/BootReceiver.java b/services/core/java/com/android/server/BootReceiver.java index 23cee9db2138..16209b1dc3d3 100644 --- a/services/core/java/com/android/server/BootReceiver.java +++ b/services/core/java/com/android/server/BootReceiver.java @@ -50,6 +50,7 @@ import com.android.modules.utils.TypedXmlPullParser; import com.android.modules.utils.TypedXmlSerializer; import com.android.server.am.DropboxRateLimiter; +import libcore.io.IoUtils; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; @@ -147,6 +148,10 @@ public class BootReceiver extends BroadcastReceiver { @Override public void onReceive(final Context context, Intent intent) { + if (!Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) { + return; + } + // Log boot events in the background to avoid blocking the main thread with I/O new Thread() { @Override @@ -212,6 +217,8 @@ public class BootReceiver extends BroadcastReceiver { } catch (Exception e) { Slog.wtf(TAG, "Error watching for trace events", e); return 0; // Unregister the handler. + } finally { + IoUtils.closeQuietly(fd); } return OnFileDescriptorEventListener.EVENT_INPUT; } diff --git a/services/core/java/com/android/server/OWNERS b/services/core/java/com/android/server/OWNERS index ef769cf6217c..6858e2941ff9 100644 --- a/services/core/java/com/android/server/OWNERS +++ b/services/core/java/com/android/server/OWNERS @@ -9,7 +9,6 @@ per-file DisplayThread.java = michaelwr@google.com, ogunwale@google.com # Zram writeback per-file ZramWriteback.java = minchan@google.com, rajekumar@google.com -per-file ZramMaintenance.java = kawasin@google.com # ServiceWatcher per-file ServiceWatcher.java = sooniln@google.com diff --git a/services/core/java/com/android/server/StorageManagerService.java b/services/core/java/com/android/server/StorageManagerService.java index 19676ebdbfcd..ebaf6bc95a5e 100644 --- a/services/core/java/com/android/server/StorageManagerService.java +++ b/services/core/java/com/android/server/StorageManagerService.java @@ -126,6 +126,7 @@ import android.provider.Downloads; import android.provider.MediaStore; import android.provider.Settings; import android.service.storage.ExternalStorageService; +import android.sysprop.MmdProperties; import android.text.TextUtils; import android.text.format.DateUtils; import android.util.ArrayMap; @@ -155,6 +156,7 @@ import com.android.internal.util.IndentingPrintWriter; import com.android.internal.util.Preconditions; import com.android.modules.utils.TypedXmlPullParser; import com.android.modules.utils.TypedXmlSerializer; +import com.android.server.memory.ZramMaintenance; import com.android.server.pm.Installer; import com.android.server.pm.UserManagerInternal; import com.android.server.storage.AppFuseBridge; @@ -933,22 +935,21 @@ class StorageManagerService extends IStorageManager.Stub // Start scheduling nominally-daily fstrim operations MountServiceIdler.scheduleIdlePass(mContext); - // Toggle zram-enable system property in response to settings - mContext.getContentResolver().registerContentObserver( - Settings.Global.getUriFor(Settings.Global.ZRAM_ENABLED), - false /*notifyForDescendants*/, - new ContentObserver(null /* current thread */) { - @Override - public void onChange(boolean selfChange) { - refreshZramSettings(); - } - }); - refreshZramSettings(); - - if (mmdEnabled()) { - // TODO: b/375432472 - Start zram maintenance only when zram is enabled. + if (mmdEnabled() && MmdProperties.mmd_zram_enabled().orElse(false)) { ZramMaintenance.startZramMaintenance(mContext); } else { + // Toggle zram-enable system property in response to settings + mContext.getContentResolver().registerContentObserver( + Settings.Global.getUriFor(Settings.Global.ZRAM_ENABLED), + false /*notifyForDescendants*/, + new ContentObserver(null /* current thread */) { + @Override + public void onChange(boolean selfChange) { + refreshZramSettings(); + } + }); + refreshZramSettings(); + // Schedule zram writeback unless zram is disabled by persist.sys.zram_enabled String zramPropValue = SystemProperties.get(ZRAM_ENABLED_PROPERTY); if (!zramPropValue.equals("0") @@ -982,7 +983,7 @@ class StorageManagerService extends IStorageManager.Stub // sole writer. SystemProperties.set(ZRAM_ENABLED_PROPERTY, desiredPropertyValue); // Schedule writeback only if zram is being enabled. - if (!mmdEnabled() && desiredPropertyValue.equals("1") + if (desiredPropertyValue.equals("1") && mContext.getResources().getBoolean( com.android.internal.R.bool.config_zramWriteback)) { ZramWriteback.scheduleZramWriteback(mContext); diff --git a/services/core/java/com/android/server/am/AppBatteryTracker.java b/services/core/java/com/android/server/am/AppBatteryTracker.java index 374abe0256c1..0bc816e78e7b 100644 --- a/services/core/java/com/android/server/am/AppBatteryTracker.java +++ b/services/core/java/com/android/server/am/AppBatteryTracker.java @@ -818,8 +818,10 @@ final class AppBatteryTracker extends BaseAppStateTracker<AppBatteryPolicy> void dump(PrintWriter pw, String prefix) { pw.print(prefix); pw.println("APP BATTERY STATE TRACKER:"); - // Force an update. - updateBatteryUsageStatsIfNecessary(mInjector.currentTimeMillis(), true); + if (mInjector.getActivityManagerInternal().isBooted()) { + // Force an update. + updateBatteryUsageStatsIfNecessary(mInjector.currentTimeMillis(), true); + } // Force a check. scheduleBgBatteryUsageStatsCheck(); // Wait for its completion (as it runs in handler thread for the sake of thread safe) @@ -878,8 +880,10 @@ final class AppBatteryTracker extends BaseAppStateTracker<AppBatteryPolicy> @Override void dumpAsProto(ProtoOutputStream proto, int uid) { - // Force an update. - updateBatteryUsageStatsIfNecessary(mInjector.currentTimeMillis(), true); + if (mInjector.getActivityManagerInternal().isBooted()) { + // Force an update. + updateBatteryUsageStatsIfNecessary(mInjector.currentTimeMillis(), true); + } synchronized (mLock) { final SparseArray<ImmutableBatteryUsage> uidConsumers = mUidBatteryUsageInWindow; if (uid != android.os.Process.INVALID_UID) { diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java index ca8dadde3bea..8d0118173030 100644 --- a/services/core/java/com/android/server/audio/AudioService.java +++ b/services/core/java/com/android/server/audio/AudioService.java @@ -14678,11 +14678,13 @@ public class AudioService extends IAudioService.Stub final String key = "additional_output_device_delay"; final String reply = AudioSystem.getParameters( key + "=" + device.getInternalType() + "," + device.getAddress()); - long delayMillis; - try { - delayMillis = Long.parseLong(reply.substring(key.length() + 1)); - } catch (NullPointerException e) { - delayMillis = 0; + long delayMillis = 0; + if (reply.contains(key)) { + try { + delayMillis = Long.parseLong(reply.substring(key.length() + 1)); + } catch (NullPointerException e) { + delayMillis = 0; + } } return delayMillis; } @@ -14708,11 +14710,13 @@ public class AudioService extends IAudioService.Stub final String key = "max_additional_output_device_delay"; final String reply = AudioSystem.getParameters( key + "=" + device.getInternalType() + "," + device.getAddress()); - long delayMillis; - try { - delayMillis = Long.parseLong(reply.substring(key.length() + 1)); - } catch (NullPointerException e) { - delayMillis = 0; + long delayMillis = 0; + if (reply.contains(key)) { + try { + delayMillis = Long.parseLong(reply.substring(key.length() + 1)); + } catch (NullPointerException e) { + delayMillis = 0; + } } return delayMillis; } diff --git a/services/core/java/com/android/server/display/LocalDisplayAdapter.java b/services/core/java/com/android/server/display/LocalDisplayAdapter.java index 0570b2ab510b..34d59d86bead 100644 --- a/services/core/java/com/android/server/display/LocalDisplayAdapter.java +++ b/services/core/java/com/android/server/display/LocalDisplayAdapter.java @@ -725,6 +725,11 @@ final class LocalDisplayAdapter extends DisplayAdapter { if (isDisplayPrivate(physicalAddress)) { mInfo.flags |= DisplayDeviceInfo.FLAG_PRIVATE; } + + if (isDisplayStealTopFocusDisabled(physicalAddress)) { + mInfo.flags |= DisplayDeviceInfo.FLAG_OWN_FOCUS; + mInfo.flags |= DisplayDeviceInfo.FLAG_STEAL_TOP_FOCUS_DISABLED; + } } if (DisplayCutout.getMaskBuiltInDisplayCutout(res, mInfo.uniqueId)) { @@ -1395,6 +1400,23 @@ final class LocalDisplayAdapter extends DisplayAdapter { } return false; } + + private boolean isDisplayStealTopFocusDisabled(DisplayAddress.Physical physicalAddress) { + if (physicalAddress == null) { + return false; + } + final Resources res = getOverlayContext().getResources(); + int[] ports = res.getIntArray(R.array.config_localNotStealTopFocusDisplayPorts); + if (ports != null) { + int port = physicalAddress.getPort(); + for (int p : ports) { + if (p == port) { + return true; + } + } + } + return false; + } } private boolean hdrTypesEqual(int[] modeHdrTypes, int[] recordHdrTypes) { diff --git a/services/core/java/com/android/server/logcat/OWNERS b/services/core/java/com/android/server/logcat/OWNERS index 33e1873d91fa..2913cc9bf19e 100644 --- a/services/core/java/com/android/server/logcat/OWNERS +++ b/services/core/java/com/android/server/logcat/OWNERS @@ -3,6 +3,5 @@ cbrubaker@google.com eunjeongshin@google.com georgechan@google.com -jsharkey@google.com wenhaowang@google.com xiaozhenl@google.com diff --git a/services/core/java/com/android/server/memory/OWNERS b/services/core/java/com/android/server/memory/OWNERS new file mode 100644 index 000000000000..dc0e89892e43 --- /dev/null +++ b/services/core/java/com/android/server/memory/OWNERS @@ -0,0 +1,3 @@ +include /MEMORY_OWNERS + +per-file ZramMaintenance.java = kawasin@google.com diff --git a/services/core/java/com/android/server/ZramMaintenance.java b/services/core/java/com/android/server/memory/ZramMaintenance.java index cdb48122e321..560d2d741dd9 100644 --- a/services/core/java/com/android/server/ZramMaintenance.java +++ b/services/core/java/com/android/server/memory/ZramMaintenance.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.server; +package com.android.server.memory; import android.app.job.JobInfo; import android.app.job.JobParameters; @@ -24,11 +24,15 @@ import android.content.ComponentName; import android.content.Context; import android.os.IBinder; import android.os.IMmd; +import android.os.PersistableBundle; import android.os.RemoteException; import android.os.ServiceManager; import android.os.SystemProperties; +import android.provider.DeviceConfig; import android.util.Slog; +import com.android.internal.annotations.VisibleForTesting; + import java.time.Duration; /** @@ -46,43 +50,45 @@ public class ZramMaintenance extends JobService { private static final String TAG = ZramMaintenance.class.getName(); // Job id must be unique across all clients of the same uid. ZramMaintenance uses the bug number // as the job id. - private static final int JOB_ID = 375432472; + @VisibleForTesting + public static final int JOB_ID = 375432472; private static final ComponentName sZramMaintenance = new ComponentName("android", ZramMaintenance.class.getName()); + @VisibleForTesting + public static final String KEY_CHECK_STATUS = "check_status"; + private static final String SYSTEM_PROPERTY_PREFIX = "mm."; private static final String FIRST_DELAY_SECONDS_PROP = - "mm.zram.maintenance.first_delay_seconds"; + "zram.maintenance.first_delay_seconds"; // The default is 1 hour. private static final long DEFAULT_FIRST_DELAY_SECONDS = 3600; private static final String PERIODIC_DELAY_SECONDS_PROP = - "mm.zram.maintenance.periodic_delay_seconds"; + "zram.maintenance.periodic_delay_seconds"; // The default is 1 hour. private static final long DEFAULT_PERIODIC_DELAY_SECONDS = 3600; private static final String REQUIRE_DEVICE_IDLE_PROP = - "mm.zram.maintenance.require_device_idle"; + "zram.maintenance.require_device_idle"; private static final boolean DEFAULT_REQUIRE_DEVICE_IDLE = true; private static final String REQUIRE_BATTERY_NOT_LOW_PROP = - "mm.zram.maintenance.require_battry_not_low"; + "zram.maintenance.require_battery_not_low"; private static final boolean DEFAULT_REQUIRE_BATTERY_NOT_LOW = true; @Override public boolean onStartJob(JobParameters params) { - IBinder binder = ServiceManager.getService("mmd"); - if (binder != null) { - IMmd mmd = IMmd.Stub.asInterface(binder); - try { - mmd.doZramMaintenance(); - } catch (RemoteException e) { - Slog.e(TAG, "Failed to doZramMaintenance", e); + new Thread("ZramMaintenance") { + @Override + public void run() { + try { + IBinder binder = ServiceManager.getService("mmd"); + IMmd mmd = IMmd.Stub.asInterface(binder); + startJob(ZramMaintenance.this, params, mmd); + } finally { + jobFinished(params, false); + } } - } else { - Slog.w(TAG, "binder not found"); - } - Duration delay = Duration.ofSeconds(SystemProperties.getLong(PERIODIC_DELAY_SECONDS_PROP, - DEFAULT_PERIODIC_DELAY_SECONDS)); - scheduleZramMaintenance(this, delay); + }.start(); return true; } @@ -92,27 +98,75 @@ public class ZramMaintenance extends JobService { } /** + * This is public to test ZramMaintenance logic. + * + * <p> + * We need to pass mmd as parameter because we can't mock "IMmd.Stub.asInterface". + * + * <p> + * Since IMmd.isZramMaintenanceSupported() is blocking call, this method should be executed on + * a worker thread. + */ + @VisibleForTesting + public static void startJob(Context context, JobParameters params, IMmd mmd) { + boolean checkStatus = params.getExtras().getBoolean(KEY_CHECK_STATUS); + if (mmd != null) { + try { + if (checkStatus && !mmd.isZramMaintenanceSupported()) { + Slog.i(TAG, "zram maintenance is not supported"); + return; + } + // Status check is required before the first doZramMaintenanceAsync() call once. + checkStatus = false; + + mmd.doZramMaintenanceAsync(); + } catch (RemoteException e) { + Slog.e(TAG, "Failed to binder call to mmd", e); + } + } else { + Slog.w(TAG, "binder not found"); + } + Duration delay = Duration.ofSeconds(getLongProperty(PERIODIC_DELAY_SECONDS_PROP, + DEFAULT_PERIODIC_DELAY_SECONDS)); + scheduleZramMaintenance(context, delay, checkStatus); + } + + /** * Starts periodical zram maintenance. */ public static void startZramMaintenance(Context context) { Duration delay = Duration.ofSeconds( - SystemProperties.getLong(FIRST_DELAY_SECONDS_PROP, DEFAULT_FIRST_DELAY_SECONDS)); - scheduleZramMaintenance(context, delay); + getLongProperty(FIRST_DELAY_SECONDS_PROP, DEFAULT_FIRST_DELAY_SECONDS)); + scheduleZramMaintenance(context, delay, true); } - private static void scheduleZramMaintenance(Context context, Duration delay) { + private static void scheduleZramMaintenance(Context context, Duration delay, + boolean checkStatus) { JobScheduler js = context.getSystemService(JobScheduler.class); if (js != null) { + final PersistableBundle bundle = new PersistableBundle(); + bundle.putBoolean(KEY_CHECK_STATUS, checkStatus); js.schedule(new JobInfo.Builder(JOB_ID, sZramMaintenance) .setMinimumLatency(delay.toMillis()) .setRequiresDeviceIdle( - SystemProperties.getBoolean(REQUIRE_DEVICE_IDLE_PROP, + getBooleanProperty(REQUIRE_DEVICE_IDLE_PROP, DEFAULT_REQUIRE_DEVICE_IDLE)) .setRequiresBatteryNotLow( - SystemProperties.getBoolean(REQUIRE_BATTERY_NOT_LOW_PROP, + getBooleanProperty(REQUIRE_BATTERY_NOT_LOW_PROP, DEFAULT_REQUIRE_BATTERY_NOT_LOW)) + .setExtras(bundle) .build()); } } + + private static long getLongProperty(String name, long defaultValue) { + return DeviceConfig.getLong(DeviceConfig.NAMESPACE_MM, name, + SystemProperties.getLong(SYSTEM_PROPERTY_PREFIX + name, defaultValue)); + } + + private static boolean getBooleanProperty(String name, boolean defaultValue) { + return DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_MM, name, + SystemProperties.getBoolean(SYSTEM_PROPERTY_PREFIX + name, defaultValue)); + } } diff --git a/services/core/java/com/android/server/notification/OWNERS b/services/core/java/com/android/server/notification/OWNERS index 9f16662fd749..43c68d10b3ce 100644 --- a/services/core/java/com/android/server/notification/OWNERS +++ b/services/core/java/com/android/server/notification/OWNERS @@ -2,8 +2,7 @@ juliacr@google.com yurilin@google.com -aroederer@google.com matiashe@google.com valiiftime@google.com jeffdq@google.com -dsandler@android.com
\ No newline at end of file +dsandler@android.com diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java index 2a03dcbdfbc5..6f9d53d1320a 100644 --- a/services/core/java/com/android/server/pm/PackageManagerService.java +++ b/services/core/java/com/android/server/pm/PackageManagerService.java @@ -1476,7 +1476,7 @@ public class PackageManagerService implements PackageSender, TestUtilityService ArchiveState archiveState; synchronized (mLock) { PackageSetting ps = mSettings.getPackageLPr(packageName); - if (ps == null) { + if (ps == null || snapshot.shouldFilterApplication(ps, binderUid, userId)) { return null; } var psi = ps.getUserStateOrDefault(userId); diff --git a/services/core/java/com/android/server/power/ShutdownCheckPoints.java b/services/core/java/com/android/server/power/ShutdownCheckPoints.java index dafaa7d5f134..399e214aa955 100644 --- a/services/core/java/com/android/server/power/ShutdownCheckPoints.java +++ b/services/core/java/com/android/server/power/ShutdownCheckPoints.java @@ -350,17 +350,23 @@ public final class ShutdownCheckPoints { private final ShutdownCheckPoints mInstance; private final File mBaseFile; + private final File mBaseDir; private final int mFileCountLimit; FileDumperThread(ShutdownCheckPoints instance, File baseFile, int fileCountLimit) { mInstance = instance; mBaseFile = baseFile; + mBaseDir = baseFile.getParentFile(); mFileCountLimit = fileCountLimit; } @Override public void run() { - mBaseFile.getParentFile().mkdirs(); + if (!mBaseDir.exists()) { + mBaseDir.mkdirs(); + mBaseDir.setExecutable(true, false); + mBaseDir.setReadable(true, false); + } File[] checkPointFiles = listCheckPointsFiles(); int filesToDelete = checkPointFiles.length - mFileCountLimit + 1; @@ -375,7 +381,7 @@ public final class ShutdownCheckPoints { private File[] listCheckPointsFiles() { String filePrefix = mBaseFile.getName() + "-"; - File[] files = mBaseFile.getParentFile().listFiles(new FilenameFilter() { + File[] files = mBaseDir.listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String name) { if (!name.startsWith(filePrefix)) { @@ -412,6 +418,7 @@ public final class ShutdownCheckPoints { } } mBaseFile.renameTo(file); + file.setReadable(true, false); } } } diff --git a/services/core/java/com/android/server/power/stats/OWNERS b/services/core/java/com/android/server/power/stats/OWNERS index 4068e2bc03b7..208b2ddb5e54 100644 --- a/services/core/java/com/android/server/power/stats/OWNERS +++ b/services/core/java/com/android/server/power/stats/OWNERS @@ -1 +1,4 @@ +# Bug component: 987260 +set noparent + include /BATTERY_STATS_OWNERS diff --git a/services/core/java/com/android/server/security/OWNERS b/services/core/java/com/android/server/security/OWNERS index fa4bf228c683..7a31a0006bb9 100644 --- a/services/core/java/com/android/server/security/OWNERS +++ b/services/core/java/com/android/server/security/OWNERS @@ -3,5 +3,6 @@ include /core/java/android/security/OWNERS per-file *AttestationVerification* = file:/core/java/android/security/attestationverification/OWNERS +per-file *CertificateRevocationStatus* = file:/core/java/android/security/attestationverification/OWNERS per-file FileIntegrity*.java = victorhsieh@google.com per-file KeyChainSystemService.java = file:platform/packages/apps/KeyChain:/OWNERS diff --git a/services/core/java/com/android/server/sensorprivacy/SensorPrivacyService.java b/services/core/java/com/android/server/sensorprivacy/SensorPrivacyService.java index 81217014bafe..16658e360cba 100644 --- a/services/core/java/com/android/server/sensorprivacy/SensorPrivacyService.java +++ b/services/core/java/com/android/server/sensorprivacy/SensorPrivacyService.java @@ -536,8 +536,12 @@ public final class SensorPrivacyService extends SystemService { user.getIdentifier()); String inputMethodPackageName = null; if (inputMethodComponent != null) { - inputMethodPackageName = ComponentName.unflattenFromString( - inputMethodComponent).getPackageName(); + ComponentName component = ComponentName.unflattenFromString(inputMethodComponent); + if (component != null) { + inputMethodPackageName = component.getPackageName(); + } else { + Log.w(TAG, "Failed to parse inputMethodComponent: " + inputMethodComponent); + } } int capability; diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index 4f9b1ccce6b1..1a3f54ae9a18 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -723,8 +723,14 @@ public class WindowManagerService extends IWindowManager.Stub new WallpaperVisibilityListeners(); IDisplayChangeWindowController mDisplayChangeController = null; - private final DeathRecipient mDisplayChangeControllerDeath = - () -> mDisplayChangeController = null; + private final DeathRecipient mDisplayChangeControllerDeath = new DeathRecipient() { + @Override + public void binderDied() { + synchronized (mGlobalLock) { + mDisplayChangeController = null; + } + } + }; final DisplayWindowListenerController mDisplayNotificationController; final TaskSystemBarsListenerController mTaskSystemBarsListenerController; diff --git a/services/tests/displayservicetests/src/com/android/server/display/LocalDisplayAdapterTest.java b/services/tests/displayservicetests/src/com/android/server/display/LocalDisplayAdapterTest.java index 120cc84193cd..0dd645587cc7 100644 --- a/services/tests/displayservicetests/src/com/android/server/display/LocalDisplayAdapterTest.java +++ b/services/tests/displayservicetests/src/com/android/server/display/LocalDisplayAdapterTest.java @@ -250,6 +250,34 @@ public class LocalDisplayAdapterTest { PORT_C, false); } + /** + * Confirm that display is marked as trusted, has own focus, disables steal top focus when it + * is listed in com.android.internal.R.array.config_localNotStealTopFocusDisplayPorts. + */ + @Test + public void testStealTopFocusDisabledDisplay() throws Exception { + setUpDisplay(new FakeDisplay(PORT_A)); + setUpDisplay(new FakeDisplay(PORT_B)); + setUpDisplay(new FakeDisplay(PORT_C)); + updateAvailableDisplays(); + + doReturn(new int[]{ PORT_B }).when(mMockedResources).getIntArray( + com.android.internal.R.array.config_localNotStealTopFocusDisplayPorts); + mAdapter.registerLocked(); + + waitForHandlerToComplete(mHandler, HANDLER_WAIT_MS); + + // This should not have the flags + assertNotStealTopFocusFlag(mListener.addedDisplays.get(0).getDisplayDeviceInfoLocked(), + PORT_A, false); + // This should have the flags + assertNotStealTopFocusFlag(mListener.addedDisplays.get(1).getDisplayDeviceInfoLocked(), + PORT_B, true); + // This should not have the flags + assertNotStealTopFocusFlag(mListener.addedDisplays.get(2).getDisplayDeviceInfoLocked(), + PORT_C, false); + } + @Test public void testSupportedDisplayModesGetOverriddenWhenDisplayIsUpdated() throws InterruptedException { @@ -314,6 +342,42 @@ public class LocalDisplayAdapterTest { } /** + * Confirm that all local displays are not trusted, do not have their own focus, and do not + * steal top focus when config_localNotStealTopFocusDisplayPorts is empty: + */ + @Test + public void testDisplayFlagsForNoConfigLocalNotStealTopFocusDisplayPorts() throws Exception { + setUpDisplay(new FakeDisplay(PORT_A)); + setUpDisplay(new FakeDisplay(PORT_C)); + updateAvailableDisplays(); + + // config_localNotStealTopFocusDisplayPorts is null + mAdapter.registerLocked(); + + waitForHandlerToComplete(mHandler, HANDLER_WAIT_MS); + + // This should not have the flags + assertNotStealTopFocusFlag(mListener.addedDisplays.get(0).getDisplayDeviceInfoLocked(), + PORT_A, false); + // This should not have the flags + assertNotStealTopFocusFlag(mListener.addedDisplays.get(1).getDisplayDeviceInfoLocked(), + PORT_C, false); + } + + private static void assertNotStealTopFocusFlag( + DisplayDeviceInfo info, int expectedPort, boolean shouldHaveFlags) { + final DisplayAddress.Physical address = (DisplayAddress.Physical) info.address; + assertNotNull(address); + assertEquals(expectedPort, address.getPort()); + assertEquals(DISPLAY_MODEL, address.getModel()); + assertEquals(shouldHaveFlags, + (info.flags & DisplayDeviceInfo.FLAG_STEAL_TOP_FOCUS_DISABLED) != 0); + assertEquals(shouldHaveFlags, (info.flags & DisplayDeviceInfo.FLAG_OWN_FOCUS) != 0); + // display is always trusted since it is created by the system + assertEquals(true, (info.flags & DisplayDeviceInfo.FLAG_TRUSTED) != 0); + } + + /** * Confirm that external display uses physical density. */ @Test diff --git a/services/tests/ondeviceintelligencetests/OWNERS b/services/tests/ondeviceintelligencetests/OWNERS index a4fc7582a785..d08d34ad3108 100644 --- a/services/tests/ondeviceintelligencetests/OWNERS +++ b/services/tests/ondeviceintelligencetests/OWNERS @@ -1,3 +1,2 @@ shiqing@google.com sandeepbandaru@google.com -shivanker@google.com diff --git a/services/tests/servicestests/src/com/android/server/accessibility/OWNERS b/services/tests/servicestests/src/com/android/server/accessibility/OWNERS index c824c3948e2d..c7c23f081044 100644 --- a/services/tests/servicestests/src/com/android/server/accessibility/OWNERS +++ b/services/tests/servicestests/src/com/android/server/accessibility/OWNERS @@ -1,3 +1,6 @@ -# Bug component: 44215 +# Bug component: 1530954 +# +# The above component is for automated test bugs. If you are a human looking to report +# a bug in this codebase then please use component 44215. include /core/java/android/view/accessibility/OWNERS diff --git a/services/tests/servicestests/src/com/android/server/accessibility/magnification/OWNERS b/services/tests/servicestests/src/com/android/server/accessibility/magnification/OWNERS new file mode 100644 index 000000000000..9592bfdfa73b --- /dev/null +++ b/services/tests/servicestests/src/com/android/server/accessibility/magnification/OWNERS @@ -0,0 +1,6 @@ +# Bug component: 1530954 +# +# The above component is for automated test bugs. If you are a human looking to report +# a bug in this codebase then please use component 770744. + +include /services/accessibility/java/com/android/server/accessibility/magnification/OWNERS diff --git a/services/tests/servicestests/src/com/android/server/media/projection/OWNERS b/services/tests/servicestests/src/com/android/server/media/projection/OWNERS index 832bcd9d70e6..3caf7faa13ec 100644 --- a/services/tests/servicestests/src/com/android/server/media/projection/OWNERS +++ b/services/tests/servicestests/src/com/android/server/media/projection/OWNERS @@ -1 +1,2 @@ +# Bug component: 1345447 include /media/java/android/media/projection/OWNERS diff --git a/services/tests/servicestests/src/com/android/server/memory/OWNERS b/services/tests/servicestests/src/com/android/server/memory/OWNERS new file mode 100644 index 000000000000..4df08c1fbc2e --- /dev/null +++ b/services/tests/servicestests/src/com/android/server/memory/OWNERS @@ -0,0 +1,3 @@ +include /MEMORY_OWNERS + +per-file ZramMaintenanceTest.kt = kawasin@google.com diff --git a/services/tests/servicestests/src/com/android/server/memory/ZramMaintenanceTest.kt b/services/tests/servicestests/src/com/android/server/memory/ZramMaintenanceTest.kt new file mode 100644 index 000000000000..1f59f45b05bf --- /dev/null +++ b/services/tests/servicestests/src/com/android/server/memory/ZramMaintenanceTest.kt @@ -0,0 +1,154 @@ +/* + * Copyright (C) 2024 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.server.memory + +import android.app.job.JobInfo +import android.app.job.JobParameters +import android.app.job.JobScheduler +import android.os.IMmd +import android.os.PersistableBundle +import android.os.RemoteException +import android.testing.TestableContext +import androidx.test.filters.SmallTest +import androidx.test.platform.app.InstrumentationRegistry + +import com.google.common.truth.Truth.assertThat + +import org.junit.Before +import org.junit.Test +import org.junit.runner.RunWith +import org.junit.runners.JUnit4 +import org.mockito.ArgumentCaptor +import org.mockito.Captor +import org.mockito.Mock +import org.mockito.Mockito.any +import org.mockito.Mockito.never +import org.mockito.Mockito.times +import org.mockito.Mockito.verify +import org.mockito.Mockito.`when` +import org.mockito.MockitoAnnotations + +private fun generateJobParameters(jobId: Int, extras: PersistableBundle): JobParameters { + return JobParameters( + null, "", jobId, extras, null, null, 0, false, false, false, null, null, null + ) +} + +@SmallTest +@RunWith(JUnit4::class) +class ZramMaintenanceTest { + private val context = TestableContext(InstrumentationRegistry.getInstrumentation().context) + + @Captor + private lateinit var jobInfoCaptor: ArgumentCaptor<JobInfo> + + @Mock + private lateinit var mockJobScheduler: JobScheduler + + @Mock + private lateinit var mockMmd: IMmd + + @Before + @Throws(RemoteException::class) + fun setUp() { + MockitoAnnotations.initMocks(this) + context.addMockSystemService(JobScheduler::class.java, mockJobScheduler) + } + + @Test + fun startZramMaintenance() { + ZramMaintenance.startZramMaintenance(context) + + verify(mockJobScheduler, times(1)).schedule(jobInfoCaptor.capture()) + val job = jobInfoCaptor.value + assertThat(job.id).isEqualTo(ZramMaintenance.JOB_ID) + assertThat(job.extras.getBoolean(ZramMaintenance.KEY_CHECK_STATUS)).isTrue() + } + + @Test + fun startJobForFirstTime() { + val extras = PersistableBundle() + extras.putBoolean(ZramMaintenance.KEY_CHECK_STATUS, true) + val params = generateJobParameters( + ZramMaintenance.JOB_ID, + extras, + ) + `when`(mockMmd.isZramMaintenanceSupported()).thenReturn(true) + + ZramMaintenance.startJob(context, params, mockMmd) + + verify(mockMmd, times(1)).isZramMaintenanceSupported() + verify(mockMmd, times(1)).doZramMaintenanceAsync() + verify(mockJobScheduler, times(1)).schedule(jobInfoCaptor.capture()) + val nextJob = jobInfoCaptor.value + assertThat(nextJob.id).isEqualTo(ZramMaintenance.JOB_ID) + assertThat(nextJob.extras.getBoolean(ZramMaintenance.KEY_CHECK_STATUS)).isFalse() + } + + @Test + fun startJobWithoutCheckStatus() { + val extras = PersistableBundle() + extras.putBoolean(ZramMaintenance.KEY_CHECK_STATUS, false) + val params = generateJobParameters( + ZramMaintenance.JOB_ID, + extras, + ) + + ZramMaintenance.startJob(context, params, mockMmd) + + verify(mockMmd, never()).isZramMaintenanceSupported() + verify(mockMmd, times(1)).doZramMaintenanceAsync() + verify(mockJobScheduler, times(1)).schedule(jobInfoCaptor.capture()) + val nextJob = jobInfoCaptor.value + assertThat(nextJob.id).isEqualTo(ZramMaintenance.JOB_ID) + assertThat(nextJob.extras.getBoolean(ZramMaintenance.KEY_CHECK_STATUS)).isFalse() + } + + @Test + fun startJobZramIsDisabled() { + val extras = PersistableBundle() + extras.putBoolean(ZramMaintenance.KEY_CHECK_STATUS, true) + val params = generateJobParameters( + ZramMaintenance.JOB_ID, + extras, + ) + `when`(mockMmd.isZramMaintenanceSupported()).thenReturn(false) + + ZramMaintenance.startJob(context, params, mockMmd) + + verify(mockMmd, times(1)).isZramMaintenanceSupported() + verify(mockMmd, never()).doZramMaintenanceAsync() + verify(mockJobScheduler, never()).schedule(any()) + } + + @Test + fun startJobMmdIsNotReadyYet() { + val extras = PersistableBundle() + extras.putBoolean(ZramMaintenance.KEY_CHECK_STATUS, true) + val params = generateJobParameters( + ZramMaintenance.JOB_ID, + extras, + ) + + ZramMaintenance.startJob(context, params, null) + + verify(mockJobScheduler, times(1)).schedule(jobInfoCaptor.capture()) + val nextJob = jobInfoCaptor.value + assertThat(nextJob.id).isEqualTo(ZramMaintenance.JOB_ID) + assertThat(nextJob.extras.getBoolean(ZramMaintenance.KEY_CHECK_STATUS)).isTrue() + } +}
\ No newline at end of file diff --git a/tests/SharedLibrary/lib/Android.bp b/tests/SharedLibrary/lib/Android.bp index 0595cb1e116a..abfd0e869b45 100644 --- a/tests/SharedLibrary/lib/Android.bp +++ b/tests/SharedLibrary/lib/Android.bp @@ -15,6 +15,7 @@ android_app { export_package_resources: true, privileged: true, optimize: { + keep_runtime_invisible_annotations: true, proguard_flags_files: ["proguard.proguard"], }, } diff --git a/tests/SharedLibrary/lib/proguard.proguard b/tests/SharedLibrary/lib/proguard.proguard index e5dfbe1c453d..699fbdaaadad 100644 --- a/tests/SharedLibrary/lib/proguard.proguard +++ b/tests/SharedLibrary/lib/proguard.proguard @@ -1,6 +1,8 @@ -keepparameternames -keepattributes Exceptions,InnerClasses,Signature,Deprecated, - SourceFile,LineNumberTable,*Annotation*,EnclosingMethod + SourceFile,LineNumberTable,EnclosingMethod, + RuntimeVisibleAnnotations,RuntimeVisibleParameterAnnotations, + RuntimeVisibleTypeAnnotations,AnnotationDefault -keep public class * { public protected *; diff --git a/tools/aosp/upload_aosp.sh b/tools/aosp/upload_aosp.sh new file mode 100755 index 000000000000..c36057b302cb --- /dev/null +++ b/tools/aosp/upload_aosp.sh @@ -0,0 +1,116 @@ +#!/bin/bash + +set -eu + +DRYRUN=false +VERBOSE=false +DEST_BRANCH_NAME="main" +AOSP_URL="" + +function log_info() { + echo -e "\033[32m$1\033[m" +} + +function log_warn() { + echo -e "\033[33m$1\033[m" +} + +function log_fatal() { + echo -e "\033[31mERROR: $1\033[m" > /dev/stderr + exit 1 +} + +while [[ $# -gt 0 ]]; do + case $1 in + -b|--branch) + DEST_BRANCH_NAME=$2 + shift + shift + ;; + -v|--verbose) + set -x + VERBOSE=true + shift + ;; + -n|--dryrun) + DRYRUN=true + shift + ;; + -u|--url) + AOSP_URL=$2 + shift + shift + ;; + --help) + echo "$0 <options>" + echo + echo "Options:" + echo " -b, --branch <branch> : destination AOSP branch, default is $DEST_BRANCH_NAME" + echo " -n, --dryrun : do not upload CL" + echo " -u, --url : AOSP repo URL. Default is to use existing 'aosp' remote or guess the URL." + echo " -v, --verbose : show verbose output" + echo + exit 0 + ;; + -*|--*) + echo "Unknown option $i" + exit 1 + ;; + *) + ;; + esac +done + +if $VERBOSE; then + log_info "DRYRUN=$DRYRUN" + log_info "DEST_BRANCH_NAME=$DEST_BRANCH_NAME" +fi + +current_branch=$(git branch --no-color --show-current) +if [ -z "$current_branch" ]; then + log_fatal "use 'repo start' first" +fi + +tmp_branch="aosp_$current_branch" + +if [ -z "$AOSP_URL" ]; then + AOSP_URL=$(git config --get remote.goog.url | sed 's/googleplex-//') +fi + +if $VERBOSE; then + log_info "AOSP_URL=$AOSP_URL" + log_info "current_branch=$current_branch" + log_info "tmp_branch=$tmp_branch" +fi + +log_info "Running repo hooks..." +repo upload -c . -n -y + +log_info "Setting up AOSP repo..." +existing_aosp_url=$(git config --get remote.aosp.url 2>/dev/null || true) +if [ -z "$existing_aosp_url" ]; then + git remote add aosp $AOSP_URL +elif [ "$existing_aosp_url" != "$AOSP_URL"]; then + log_warn "Remote 'aosp' uses $existing_aosp_url. Expected $AOSP_URL" +fi + +log_info "Fetching '$DEST_BRANCH_NAME'" +git fetch aosp $DEST_BRANCH_NAME + +log_info "Creating $tmp_branch and cherry-picking..." +git branch -D $tmp_branch 2>/dev/null || true +git checkout -b $tmp_branch +git branch --set-upstream-to aosp/$DEST_BRANCH_NAME +git reset --hard aosp/$DEST_BRANCH_NAME +git cherry-pick goog/$DEST_BRANCH_NAME..$current_branch + +if $DRYRUN; then + log_info "Dryrun specified, skipping CL upload" +else + log_info "Pushing to AOSP..." + git push aosp HEAD:refs/for/$DEST_BRANCH_NAME +fi + +log_info "Cleaning up..." +git checkout $current_branch +git branch -D $tmp_branch
\ No newline at end of file diff --git a/tools/localedata/extract_icu_data.py b/tools/localedata/extract_icu_data.py index ec531275af1c..899cd7f9ce5e 100755 --- a/tools/localedata/extract_icu_data.py +++ b/tools/localedata/extract_icu_data.py @@ -180,7 +180,14 @@ def pack_script_to_uint32(script): def dump_representative_locales(representative_locales): """Dump the set of representative locales.""" - print() + print(''' +/* + * TODO: Consider turning the below switch statement into binary search + * to save the disk space when the table is larger in the future. + * Disassembled code shows that the jump table emitted by clang can be + * 4x larger than the data in disk size, but it depends on the optimization option. + * However, a switch statement will benefit from the future of compiler improvement. + */''') print('bool isLocaleRepresentative(uint32_t language_and_region, const char* script) {') print(' const uint64_t packed_locale =') print(' ((static_cast<uint64_t>(language_and_region)) << 32u) |') |