Loading core/api/system-current.txt +4 −7 Original line number Diff line number Diff line Loading @@ -15621,7 +15621,7 @@ package android.view { public interface WindowManager extends android.view.ViewManager { method @RequiresPermission(android.Manifest.permission.RESTRICTED_VR_ACCESS) public android.graphics.Region getCurrentImeTouchRegion(); method public default void registerTaskFpsCallback(@IntRange(from=0) int, @NonNull android.window.TaskFpsCallback); method public default void registerTaskFpsCallback(@IntRange(from=0) int, @NonNull java.util.concurrent.Executor, @NonNull android.window.TaskFpsCallback); method public default void unregisterTaskFpsCallback(@NonNull android.window.TaskFpsCallback); } Loading Loading @@ -16213,12 +16213,9 @@ package android.webkit { package android.window { public final class TaskFpsCallback { ctor public TaskFpsCallback(@NonNull java.util.concurrent.Executor, @NonNull android.window.TaskFpsCallback.OnFpsCallbackListener); } public static interface TaskFpsCallback.OnFpsCallbackListener { method public void onFpsReported(float); public abstract class TaskFpsCallback { ctor public TaskFpsCallback(); method public abstract void onFpsReported(float); } } core/java/android/view/IWindowManager.aidl +5 −5 Original line number Diff line number Diff line Loading @@ -65,7 +65,7 @@ import android.view.WindowManager; import android.view.SurfaceControl; import android.view.displayhash.DisplayHash; import android.view.displayhash.VerifiedDisplayHash; import android.window.IOnFpsCallbackListener; import android.window.ITaskFpsCallback; /** * System private interface to the window manager. Loading Loading @@ -926,21 +926,21 @@ interface IWindowManager * registered, the registered callback will not be unregistered until * {@link unregisterTaskFpsCallback()} is called * @param taskId task id of the task. * @param listener listener to be registered. * @param callback callback to be registered. * * @hide */ void registerTaskFpsCallback(in int taskId, in IOnFpsCallbackListener listener); void registerTaskFpsCallback(in int taskId, in ITaskFpsCallback callback); /** * Unregisters the frame rate per second count callback which was registered with * {@link #registerTaskFpsCallback(int,TaskFpsCallback)}. * * @param listener listener to be unregistered. * @param callback callback to be unregistered. * * @hide */ void unregisterTaskFpsCallback(in IOnFpsCallbackListener listener); void unregisterTaskFpsCallback(in ITaskFpsCallback listener); /** * Take a snapshot using the same path that's used for Recents. This is used for Testing only. Loading core/java/android/view/WindowManager.java +7 −4 Original line number Diff line number Diff line Loading @@ -4865,21 +4865,24 @@ public interface WindowManager extends ViewManager { * Registers the frame rate per second count callback for one given task ID. * Each callback can only register for receiving FPS callback for one task id until unregister * is called. If there's no task associated with the given task id, * {@link IllegalArgumentException} will be thrown. If a task id destroyed after a callback is * registered, the registered callback will not be unregistered until * {@link #unregisterTaskFpsCallback(TaskFpsCallback))} is called * {@link IllegalArgumentException} will be thrown. Registered callbacks should always be * unregistered via {@link #unregisterTaskFpsCallback(TaskFpsCallback)} * even when the task id has been destroyed. * * @param taskId task id of the task. * @param executor Executor to execute the callback. * @param callback callback to be registered. * * @hide */ @SystemApi default void registerTaskFpsCallback(@IntRange(from = 0) int taskId, @NonNull Executor executor, @NonNull TaskFpsCallback callback) {} /** * Unregisters the frame rate per second count callback which was registered with * {@link #registerTaskFpsCallback(int,TaskFpsCallback)}. * {@link #registerTaskFpsCallback(Executor, int, TaskFpsCallback)}. * * @param callback callback to be unregistered. * Loading core/java/android/view/WindowManagerImpl.java +50 −6 Original line number Diff line number Diff line Loading @@ -39,14 +39,18 @@ import android.os.Bundle; import android.os.IBinder; import android.os.RemoteException; import android.os.StrictMode; import android.window.ITaskFpsCallback; import android.window.TaskFpsCallback; import android.window.WindowContext; import android.window.WindowProvider; import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.os.IResultReceiver; import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Set; import java.util.concurrent.Executor; Loading Loading @@ -99,6 +103,10 @@ public final class WindowManagerImpl implements WindowManager { @Nullable private final IBinder mWindowContextToken; @GuardedBy("mOnFpsCallbackListenerProxies") private final ArrayList<OnFpsCallbackListenerProxy> mOnFpsCallbackListenerProxies = new ArrayList<>(); public WindowManagerImpl(Context context) { this(context, null /* parentWindow */, null /* clientToken */); } Loading Loading @@ -424,20 +432,56 @@ public final class WindowManagerImpl implements WindowManager { } @Override public void registerTaskFpsCallback(@IntRange(from = 0) int taskId, TaskFpsCallback callback) { public void registerTaskFpsCallback(@IntRange(from = 0) int taskId, @NonNull Executor executor, TaskFpsCallback callback) { final OnFpsCallbackListenerProxy onFpsCallbackListenerProxy = new OnFpsCallbackListenerProxy(executor, callback); try { WindowManagerGlobal.getWindowManagerService().registerTaskFpsCallback( taskId, callback.getListener()); taskId, onFpsCallbackListenerProxy); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } synchronized (mOnFpsCallbackListenerProxies) { mOnFpsCallbackListenerProxies.add(onFpsCallbackListenerProxy); } } @Override public void unregisterTaskFpsCallback(TaskFpsCallback callback) { synchronized (mOnFpsCallbackListenerProxies) { final Iterator<OnFpsCallbackListenerProxy> iterator = mOnFpsCallbackListenerProxies.iterator(); while (iterator.hasNext()) { final OnFpsCallbackListenerProxy proxy = iterator.next(); if (proxy.mCallback == callback) { try { WindowManagerGlobal.getWindowManagerService().unregisterTaskFpsCallback( callback.getListener()); WindowManagerGlobal.getWindowManagerService() .unregisterTaskFpsCallback(proxy); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } iterator.remove(); } } } } private static class OnFpsCallbackListenerProxy extends ITaskFpsCallback.Stub { private final Executor mExecutor; private final TaskFpsCallback mCallback; private OnFpsCallbackListenerProxy(Executor executor, TaskFpsCallback callback) { mExecutor = executor; mCallback = callback; } @Override public void onFpsReported(float fps) { mExecutor.execute(() -> { mCallback.onFpsReported(fps); }); } } Loading core/java/android/window/IOnFpsCallbackListener.aidl→core/java/android/window/ITaskFpsCallback.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -19,7 +19,7 @@ package android.window; /** * @hide */ oneway interface IOnFpsCallbackListener { oneway interface ITaskFpsCallback { /** * Reports the fps from the registered task Loading Loading
core/api/system-current.txt +4 −7 Original line number Diff line number Diff line Loading @@ -15621,7 +15621,7 @@ package android.view { public interface WindowManager extends android.view.ViewManager { method @RequiresPermission(android.Manifest.permission.RESTRICTED_VR_ACCESS) public android.graphics.Region getCurrentImeTouchRegion(); method public default void registerTaskFpsCallback(@IntRange(from=0) int, @NonNull android.window.TaskFpsCallback); method public default void registerTaskFpsCallback(@IntRange(from=0) int, @NonNull java.util.concurrent.Executor, @NonNull android.window.TaskFpsCallback); method public default void unregisterTaskFpsCallback(@NonNull android.window.TaskFpsCallback); } Loading Loading @@ -16213,12 +16213,9 @@ package android.webkit { package android.window { public final class TaskFpsCallback { ctor public TaskFpsCallback(@NonNull java.util.concurrent.Executor, @NonNull android.window.TaskFpsCallback.OnFpsCallbackListener); } public static interface TaskFpsCallback.OnFpsCallbackListener { method public void onFpsReported(float); public abstract class TaskFpsCallback { ctor public TaskFpsCallback(); method public abstract void onFpsReported(float); } }
core/java/android/view/IWindowManager.aidl +5 −5 Original line number Diff line number Diff line Loading @@ -65,7 +65,7 @@ import android.view.WindowManager; import android.view.SurfaceControl; import android.view.displayhash.DisplayHash; import android.view.displayhash.VerifiedDisplayHash; import android.window.IOnFpsCallbackListener; import android.window.ITaskFpsCallback; /** * System private interface to the window manager. Loading Loading @@ -926,21 +926,21 @@ interface IWindowManager * registered, the registered callback will not be unregistered until * {@link unregisterTaskFpsCallback()} is called * @param taskId task id of the task. * @param listener listener to be registered. * @param callback callback to be registered. * * @hide */ void registerTaskFpsCallback(in int taskId, in IOnFpsCallbackListener listener); void registerTaskFpsCallback(in int taskId, in ITaskFpsCallback callback); /** * Unregisters the frame rate per second count callback which was registered with * {@link #registerTaskFpsCallback(int,TaskFpsCallback)}. * * @param listener listener to be unregistered. * @param callback callback to be unregistered. * * @hide */ void unregisterTaskFpsCallback(in IOnFpsCallbackListener listener); void unregisterTaskFpsCallback(in ITaskFpsCallback listener); /** * Take a snapshot using the same path that's used for Recents. This is used for Testing only. Loading
core/java/android/view/WindowManager.java +7 −4 Original line number Diff line number Diff line Loading @@ -4865,21 +4865,24 @@ public interface WindowManager extends ViewManager { * Registers the frame rate per second count callback for one given task ID. * Each callback can only register for receiving FPS callback for one task id until unregister * is called. If there's no task associated with the given task id, * {@link IllegalArgumentException} will be thrown. If a task id destroyed after a callback is * registered, the registered callback will not be unregistered until * {@link #unregisterTaskFpsCallback(TaskFpsCallback))} is called * {@link IllegalArgumentException} will be thrown. Registered callbacks should always be * unregistered via {@link #unregisterTaskFpsCallback(TaskFpsCallback)} * even when the task id has been destroyed. * * @param taskId task id of the task. * @param executor Executor to execute the callback. * @param callback callback to be registered. * * @hide */ @SystemApi default void registerTaskFpsCallback(@IntRange(from = 0) int taskId, @NonNull Executor executor, @NonNull TaskFpsCallback callback) {} /** * Unregisters the frame rate per second count callback which was registered with * {@link #registerTaskFpsCallback(int,TaskFpsCallback)}. * {@link #registerTaskFpsCallback(Executor, int, TaskFpsCallback)}. * * @param callback callback to be unregistered. * Loading
core/java/android/view/WindowManagerImpl.java +50 −6 Original line number Diff line number Diff line Loading @@ -39,14 +39,18 @@ import android.os.Bundle; import android.os.IBinder; import android.os.RemoteException; import android.os.StrictMode; import android.window.ITaskFpsCallback; import android.window.TaskFpsCallback; import android.window.WindowContext; import android.window.WindowProvider; import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.os.IResultReceiver; import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Set; import java.util.concurrent.Executor; Loading Loading @@ -99,6 +103,10 @@ public final class WindowManagerImpl implements WindowManager { @Nullable private final IBinder mWindowContextToken; @GuardedBy("mOnFpsCallbackListenerProxies") private final ArrayList<OnFpsCallbackListenerProxy> mOnFpsCallbackListenerProxies = new ArrayList<>(); public WindowManagerImpl(Context context) { this(context, null /* parentWindow */, null /* clientToken */); } Loading Loading @@ -424,20 +432,56 @@ public final class WindowManagerImpl implements WindowManager { } @Override public void registerTaskFpsCallback(@IntRange(from = 0) int taskId, TaskFpsCallback callback) { public void registerTaskFpsCallback(@IntRange(from = 0) int taskId, @NonNull Executor executor, TaskFpsCallback callback) { final OnFpsCallbackListenerProxy onFpsCallbackListenerProxy = new OnFpsCallbackListenerProxy(executor, callback); try { WindowManagerGlobal.getWindowManagerService().registerTaskFpsCallback( taskId, callback.getListener()); taskId, onFpsCallbackListenerProxy); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } synchronized (mOnFpsCallbackListenerProxies) { mOnFpsCallbackListenerProxies.add(onFpsCallbackListenerProxy); } } @Override public void unregisterTaskFpsCallback(TaskFpsCallback callback) { synchronized (mOnFpsCallbackListenerProxies) { final Iterator<OnFpsCallbackListenerProxy> iterator = mOnFpsCallbackListenerProxies.iterator(); while (iterator.hasNext()) { final OnFpsCallbackListenerProxy proxy = iterator.next(); if (proxy.mCallback == callback) { try { WindowManagerGlobal.getWindowManagerService().unregisterTaskFpsCallback( callback.getListener()); WindowManagerGlobal.getWindowManagerService() .unregisterTaskFpsCallback(proxy); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } iterator.remove(); } } } } private static class OnFpsCallbackListenerProxy extends ITaskFpsCallback.Stub { private final Executor mExecutor; private final TaskFpsCallback mCallback; private OnFpsCallbackListenerProxy(Executor executor, TaskFpsCallback callback) { mExecutor = executor; mCallback = callback; } @Override public void onFpsReported(float fps) { mExecutor.execute(() -> { mCallback.onFpsReported(fps); }); } } Loading
core/java/android/window/IOnFpsCallbackListener.aidl→core/java/android/window/ITaskFpsCallback.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -19,7 +19,7 @@ package android.window; /** * @hide */ oneway interface IOnFpsCallbackListener { oneway interface ITaskFpsCallback { /** * Reports the fps from the registered task Loading