diff options
| -rw-r--r-- | core/api/module-lib-current.txt | 6 | ||||
| -rw-r--r-- | core/java/android/os/Handler.java | 30 | ||||
| -rw-r--r-- | core/java/android/os/flags.aconfig | 8 |
3 files changed, 42 insertions, 2 deletions
diff --git a/core/api/module-lib-current.txt b/core/api/module-lib-current.txt index 24e73352ff33..84f2ab2f0915 100644 --- a/core/api/module-lib-current.txt +++ b/core/api/module-lib-current.txt @@ -380,6 +380,12 @@ package android.os { method @FlaggedApi("android.crashrecovery.flags.enable_crashrecovery") @NonNull public static java.io.File getDataSystemDeDirectory(); } + public class Handler { + method @FlaggedApi("android.os.mainline_vcn_platform_api") public final boolean hasMessagesOrCallbacks(); + method @FlaggedApi("android.os.mainline_vcn_platform_api") public final void removeCallbacksAndEqualMessages(@Nullable Object); + method @FlaggedApi("android.os.mainline_vcn_platform_api") public final void removeEqualMessages(int, @Nullable Object); + } + public class IpcDataCache<Query, Result> { ctor public IpcDataCache(int, @NonNull String, @NonNull String, @NonNull String, @NonNull android.os.IpcDataCache.QueryHandler<Query,Result>); method public void disableForCurrentProcess(); diff --git a/core/java/android/os/Handler.java b/core/java/android/os/Handler.java index 80f39bfbdc21..d0828c384664 100644 --- a/core/java/android/os/Handler.java +++ b/core/java/android/os/Handler.java @@ -16,8 +16,10 @@ package android.os; +import android.annotation.FlaggedApi; import android.annotation.NonNull; import android.annotation.Nullable; +import android.annotation.SystemApi; import android.compat.annotation.UnsupportedAppUsage; import android.util.Log; import android.util.Printer; @@ -819,16 +821,25 @@ public class Handler { } /** + * WARNING: This API is dangerous because if the implementation + * of equals() is broken, it would delete unrelated events. For example, + * if object.equals() always returns true, it'd remove all messages. + * + * For this reason, never expose this API to non-platform code. i.e. + * this shouldn't be exposed to SystemApi.PRIVILEGED_APPS. + * * Remove any pending posts of messages with code 'what' and whose obj is * 'object' that are in the message queue. If <var>object</var> is null, * all messages will be removed. - * <p> - * Similar to {@link #removeMessages(int, Object)} but uses object equality + * + * <p>Similar to {@link #removeMessages(int, Object)} but uses object equality * ({@link Object#equals(Object)}) instead of reference equality (==) in * determining whether object is the message's obj'. * *@hide */ + @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES) + @FlaggedApi(android.os.Flags.FLAG_MAINLINE_VCN_PLATFORM_API) public final void removeEqualMessages(int what, @Nullable Object object) { mQueue.removeEqualMessages(this, what, disallowNullArgumentIfShared(object)); } @@ -843,12 +854,25 @@ public class Handler { } /** + * WARNING: This API is dangerous because if the implementation + * of equals() is broken, it would delete unrelated events. For example, + * if object.equals() always returns true, it'd remove all messages. + * + * For this reason, never expose this API to non-platform code. i.e. + * this shouldn't be exposed to SystemApi.PRIVILEGED_APPS. + * * Remove any pending posts of callbacks and sent messages whose * <var>obj</var> is <var>token</var>. If <var>token</var> is null, * all callbacks and messages will be removed. * + * <p>Similar to {@link #removeCallbacksAndMessages(Object)} but uses object + * equality ({@link Object#equals(Object)}) instead of reference equality (==) in + * determining whether object is the message's obj'. + * *@hide */ + @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES) + @FlaggedApi(android.os.Flags.FLAG_MAINLINE_VCN_PLATFORM_API) public final void removeCallbacksAndEqualMessages(@Nullable Object token) { mQueue.removeCallbacksAndEqualMessages(this, disallowNullArgumentIfShared(token)); } @@ -864,6 +888,8 @@ public class Handler { * Return whether there are any messages or callbacks currently scheduled on this handler. * @hide */ + @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES) + @FlaggedApi(android.os.Flags.FLAG_MAINLINE_VCN_PLATFORM_API) public final boolean hasMessagesOrCallbacks() { return mQueue.hasMessages(this); } diff --git a/core/java/android/os/flags.aconfig b/core/java/android/os/flags.aconfig index 11b1b08b787d..941ae892f428 100644 --- a/core/java/android/os/flags.aconfig +++ b/core/java/android/os/flags.aconfig @@ -209,3 +209,11 @@ flag { description: "Tracing using Perfetto SDK." bug: "303199244" } + +flag { + name: "mainline_vcn_platform_api" + namespace: "vcn" + description: "Expose platform APIs to mainline VCN" + is_exported: true + bug: "366598445" +} |