Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6df1d751 authored by Yan Yan's avatar Yan Yan
Browse files

Expose Handler methods for mainlining VCN

Expose the following three methods as a prerequisite
for moving VCN to mainline.
- #hasMessagesOrCallbacks()
- #removeCallbacksAndEqualMessages(Object)
- #removeEqualMessages(int, Object)

Bug: 366598445
Test: atest CtsOsTestCases:HandlerTest
Flag: android.os.mainline_vcn_platform_api
Change-Id: If16bbcdd5aba7438397f50d82b2ffd1555b2dddf
Merged-In: If16bbcdd5aba7438397f50d82b2ffd1555b2dddf
parent f54eb9cb
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -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();
+28 −2
Original line number Diff line number Diff line
@@ -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);
    }
+8 −0
Original line number Diff line number Diff line
@@ -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"
}