Loading core/java/android/app/IActivityTaskManager.aidl +4 −1 Original line number Diff line number Diff line Loading @@ -69,6 +69,7 @@ import android.os.WorkSource; import android.service.voice.IVoiceInteractionSession; import android.view.IRecentsAnimationRunner; import android.view.IRemoteAnimationRunner; import android.view.IWindowFocusObserver; import android.view.RemoteAnimationDefinition; import android.view.RemoteAnimationAdapter; import android.window.IWindowOrganizerController; Loading Loading @@ -352,6 +353,8 @@ interface IActivityTaskManager { * Prepare the back navigation in the server. This setups the leashed for sysui to animate * the back gesture and returns the data needed for the animation. * @param requestAnimation true if the caller wishes to animate the back navigation * @param focusObserver a remote callback to nofify shell when the focused window lost focus. */ android.window.BackNavigationInfo startBackNavigation(in boolean requestAnimation); android.window.BackNavigationInfo startBackNavigation(in boolean requestAnimation, in IWindowFocusObserver focusObserver); } core/java/android/view/ViewRootImpl.java +0 −1 Original line number Diff line number Diff line Loading @@ -3759,7 +3759,6 @@ public final class ViewRootImpl implements ViewParent, } } mFirstInputStage.onWindowFocusChanged(hasWindowFocus); mOnBackInvokedDispatcher.onWindowFocusChanged(hasWindowFocus); // NOTE: there's no view visibility (appeared / disapparead) events when the windows focus // is lost, so we don't need to to force a flush - there might be other events such as Loading core/java/android/window/BackNavigationInfo.java +1 −1 Original line number Diff line number Diff line Loading @@ -118,7 +118,7 @@ public final class BackNavigationInfo implements Parcelable { * back preview. * @param onBackInvokedCallback The back callback registered by the current top level window. */ public BackNavigationInfo(@BackTargetType int type, private BackNavigationInfo(@BackTargetType int type, @Nullable RemoteAnimationTarget departingAnimationTarget, @Nullable SurfaceControl screenshotSurface, @Nullable HardwareBuffer screenshotBuffer, Loading core/java/android/window/ImeOnBackInvokedDispatcher.java +1 −2 Original line number Diff line number Diff line Loading @@ -83,8 +83,7 @@ public class ImeOnBackInvokedDispatcher implements OnBackInvokedDispatcher, Parc final Bundle bundle = new Bundle(); // Always invoke back for ime without checking the window focus. final IOnBackInvokedCallback iCallback = new WindowOnBackInvokedDispatcher.OnBackInvokedCallbackWrapper(callback, () -> true); new WindowOnBackInvokedDispatcher.OnBackInvokedCallbackWrapper(callback); bundle.putBinder(RESULT_KEY_CALLBACK, iCallback.asBinder()); bundle.putInt(RESULT_KEY_PRIORITY, priority); bundle.putInt(RESULT_KEY_ID, callback.hashCode()); Loading core/java/android/window/WindowOnBackInvokedDispatcher.java +2 −22 Original line number Diff line number Diff line Loading @@ -32,7 +32,6 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Objects; import java.util.TreeMap; import java.util.function.Supplier; /** * Provides window based implementation of {@link OnBackInvokedDispatcher}. Loading Loading @@ -65,7 +64,6 @@ public class WindowOnBackInvokedDispatcher implements OnBackInvokedDispatcher { private final TreeMap<Integer, ArrayList<OnBackInvokedCallback>> mOnBackInvokedCallbacks = new TreeMap<>(); private final Checker mChecker; private boolean mHasFocus; public WindowOnBackInvokedDispatcher(boolean applicationCallBackEnabled) { mChecker = new Checker(applicationCallBackEnabled); Loading Loading @@ -191,7 +189,7 @@ public class WindowOnBackInvokedDispatcher implements OnBackInvokedDispatcher { .ImeOnBackInvokedCallback ? ((ImeOnBackInvokedDispatcher.ImeOnBackInvokedCallback) callback).getIOnBackInvokedCallback() : new OnBackInvokedCallbackWrapper(callback, this::hasFocus); : new OnBackInvokedCallbackWrapper(callback); callbackInfo = new OnBackInvokedCallbackInfo(iCallback, priority); } mWindowSession.setOnBackInvokedCallbackInfo(mWindow, callbackInfo); Loading @@ -200,17 +198,6 @@ public class WindowOnBackInvokedDispatcher implements OnBackInvokedDispatcher { } } /** * Called when window focus changed. */ public void onWindowFocusChanged(boolean hasFocus) { mHasFocus = hasFocus; } private boolean hasFocus() { return mHasFocus; } public OnBackInvokedCallback getTopCallback() { if (mAllCallbacks.isEmpty()) { return null; Loading @@ -234,11 +221,8 @@ public class WindowOnBackInvokedDispatcher implements OnBackInvokedDispatcher { static class OnBackInvokedCallbackWrapper extends IOnBackInvokedCallback.Stub { private final WeakReference<OnBackInvokedCallback> mCallback; private final Supplier<Boolean> mHasFocus; OnBackInvokedCallbackWrapper(@NonNull OnBackInvokedCallback callback, @NonNull Supplier<Boolean> hasFocus) { OnBackInvokedCallbackWrapper(@NonNull OnBackInvokedCallback callback) { mCallback = new WeakReference<>(callback); mHasFocus = hasFocus; } @Override Loading Loading @@ -278,10 +262,6 @@ public class WindowOnBackInvokedDispatcher implements OnBackInvokedDispatcher { if (callback == null) { return; } if (!mHasFocus.get()) { Log.w(TAG, "Skip back invoke due to current focus has lost."); return; } callback.onBackInvoked(); }); } Loading Loading
core/java/android/app/IActivityTaskManager.aidl +4 −1 Original line number Diff line number Diff line Loading @@ -69,6 +69,7 @@ import android.os.WorkSource; import android.service.voice.IVoiceInteractionSession; import android.view.IRecentsAnimationRunner; import android.view.IRemoteAnimationRunner; import android.view.IWindowFocusObserver; import android.view.RemoteAnimationDefinition; import android.view.RemoteAnimationAdapter; import android.window.IWindowOrganizerController; Loading Loading @@ -352,6 +353,8 @@ interface IActivityTaskManager { * Prepare the back navigation in the server. This setups the leashed for sysui to animate * the back gesture and returns the data needed for the animation. * @param requestAnimation true if the caller wishes to animate the back navigation * @param focusObserver a remote callback to nofify shell when the focused window lost focus. */ android.window.BackNavigationInfo startBackNavigation(in boolean requestAnimation); android.window.BackNavigationInfo startBackNavigation(in boolean requestAnimation, in IWindowFocusObserver focusObserver); }
core/java/android/view/ViewRootImpl.java +0 −1 Original line number Diff line number Diff line Loading @@ -3759,7 +3759,6 @@ public final class ViewRootImpl implements ViewParent, } } mFirstInputStage.onWindowFocusChanged(hasWindowFocus); mOnBackInvokedDispatcher.onWindowFocusChanged(hasWindowFocus); // NOTE: there's no view visibility (appeared / disapparead) events when the windows focus // is lost, so we don't need to to force a flush - there might be other events such as Loading
core/java/android/window/BackNavigationInfo.java +1 −1 Original line number Diff line number Diff line Loading @@ -118,7 +118,7 @@ public final class BackNavigationInfo implements Parcelable { * back preview. * @param onBackInvokedCallback The back callback registered by the current top level window. */ public BackNavigationInfo(@BackTargetType int type, private BackNavigationInfo(@BackTargetType int type, @Nullable RemoteAnimationTarget departingAnimationTarget, @Nullable SurfaceControl screenshotSurface, @Nullable HardwareBuffer screenshotBuffer, Loading
core/java/android/window/ImeOnBackInvokedDispatcher.java +1 −2 Original line number Diff line number Diff line Loading @@ -83,8 +83,7 @@ public class ImeOnBackInvokedDispatcher implements OnBackInvokedDispatcher, Parc final Bundle bundle = new Bundle(); // Always invoke back for ime without checking the window focus. final IOnBackInvokedCallback iCallback = new WindowOnBackInvokedDispatcher.OnBackInvokedCallbackWrapper(callback, () -> true); new WindowOnBackInvokedDispatcher.OnBackInvokedCallbackWrapper(callback); bundle.putBinder(RESULT_KEY_CALLBACK, iCallback.asBinder()); bundle.putInt(RESULT_KEY_PRIORITY, priority); bundle.putInt(RESULT_KEY_ID, callback.hashCode()); Loading
core/java/android/window/WindowOnBackInvokedDispatcher.java +2 −22 Original line number Diff line number Diff line Loading @@ -32,7 +32,6 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Objects; import java.util.TreeMap; import java.util.function.Supplier; /** * Provides window based implementation of {@link OnBackInvokedDispatcher}. Loading Loading @@ -65,7 +64,6 @@ public class WindowOnBackInvokedDispatcher implements OnBackInvokedDispatcher { private final TreeMap<Integer, ArrayList<OnBackInvokedCallback>> mOnBackInvokedCallbacks = new TreeMap<>(); private final Checker mChecker; private boolean mHasFocus; public WindowOnBackInvokedDispatcher(boolean applicationCallBackEnabled) { mChecker = new Checker(applicationCallBackEnabled); Loading Loading @@ -191,7 +189,7 @@ public class WindowOnBackInvokedDispatcher implements OnBackInvokedDispatcher { .ImeOnBackInvokedCallback ? ((ImeOnBackInvokedDispatcher.ImeOnBackInvokedCallback) callback).getIOnBackInvokedCallback() : new OnBackInvokedCallbackWrapper(callback, this::hasFocus); : new OnBackInvokedCallbackWrapper(callback); callbackInfo = new OnBackInvokedCallbackInfo(iCallback, priority); } mWindowSession.setOnBackInvokedCallbackInfo(mWindow, callbackInfo); Loading @@ -200,17 +198,6 @@ public class WindowOnBackInvokedDispatcher implements OnBackInvokedDispatcher { } } /** * Called when window focus changed. */ public void onWindowFocusChanged(boolean hasFocus) { mHasFocus = hasFocus; } private boolean hasFocus() { return mHasFocus; } public OnBackInvokedCallback getTopCallback() { if (mAllCallbacks.isEmpty()) { return null; Loading @@ -234,11 +221,8 @@ public class WindowOnBackInvokedDispatcher implements OnBackInvokedDispatcher { static class OnBackInvokedCallbackWrapper extends IOnBackInvokedCallback.Stub { private final WeakReference<OnBackInvokedCallback> mCallback; private final Supplier<Boolean> mHasFocus; OnBackInvokedCallbackWrapper(@NonNull OnBackInvokedCallback callback, @NonNull Supplier<Boolean> hasFocus) { OnBackInvokedCallbackWrapper(@NonNull OnBackInvokedCallback callback) { mCallback = new WeakReference<>(callback); mHasFocus = hasFocus; } @Override Loading Loading @@ -278,10 +262,6 @@ public class WindowOnBackInvokedDispatcher implements OnBackInvokedDispatcher { if (callback == null) { return; } if (!mHasFocus.get()) { Log.w(TAG, "Skip back invoke due to current focus has lost."); return; } callback.onBackInvoked(); }); } Loading