Update topFocusedWindowChanged API
For certain situations it's useful to know the exact activity that's being hosted in the focused window when it changes, not just the package name. Bug: 237317934 Test: manual Change-Id: I21ef229e9b29110957d9176357851720edc1f117
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
|
||||
package android.view;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.view.InsetsSourceControl;
|
||||
import android.view.InsetsState;
|
||||
import android.view.InsetsVisibilities;
|
||||
@@ -30,10 +31,11 @@ oneway interface IDisplayWindowInsetsController {
|
||||
/**
|
||||
* Called when top focused window changes to determine whether or not to take over insets
|
||||
* control. Won't be called if config_remoteInsetsControllerControlsSystemBars is false.
|
||||
* @param packageName: Passes the top package name
|
||||
* @param component: Passes the top application component in the focused window.
|
||||
* @param requestedVisibilities The insets visibilities requested by the focussed window.
|
||||
*/
|
||||
void topFocusedWindowChanged(String packageName, in InsetsVisibilities insetsVisibilities);
|
||||
void topFocusedWindowChanged(in ComponentName component,
|
||||
in InsetsVisibilities insetsVisibilities);
|
||||
|
||||
/**
|
||||
* @see IWindow#insetsChanged
|
||||
|
||||
@@ -20,6 +20,7 @@ import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.annotation.IntDef;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Point;
|
||||
@@ -324,7 +325,7 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged
|
||||
}
|
||||
|
||||
@Override
|
||||
public void topFocusedWindowChanged(String packageName,
|
||||
public void topFocusedWindowChanged(ComponentName component,
|
||||
InsetsVisibilities requestedVisibilities) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.wm.shell.common;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Slog;
|
||||
import android.util.SparseArray;
|
||||
@@ -171,14 +172,14 @@ public class DisplayInsetsController implements DisplayController.OnDisplaysChan
|
||||
}
|
||||
}
|
||||
|
||||
private void topFocusedWindowChanged(String packageName,
|
||||
private void topFocusedWindowChanged(ComponentName component,
|
||||
InsetsVisibilities requestedVisibilities) {
|
||||
CopyOnWriteArrayList<OnInsetsChangedListener> listeners = mListeners.get(mDisplayId);
|
||||
if (listeners == null) {
|
||||
return;
|
||||
}
|
||||
for (OnInsetsChangedListener listener : listeners) {
|
||||
listener.topFocusedWindowChanged(packageName, requestedVisibilities);
|
||||
listener.topFocusedWindowChanged(component, requestedVisibilities);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,10 +187,10 @@ public class DisplayInsetsController implements DisplayController.OnDisplaysChan
|
||||
private class DisplayWindowInsetsControllerImpl
|
||||
extends IDisplayWindowInsetsController.Stub {
|
||||
@Override
|
||||
public void topFocusedWindowChanged(String packageName,
|
||||
public void topFocusedWindowChanged(ComponentName component,
|
||||
InsetsVisibilities requestedVisibilities) throws RemoteException {
|
||||
mMainExecutor.execute(() -> {
|
||||
PerDisplay.this.topFocusedWindowChanged(packageName, requestedVisibilities);
|
||||
PerDisplay.this.topFocusedWindowChanged(component, requestedVisibilities);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -234,10 +235,10 @@ public class DisplayInsetsController implements DisplayController.OnDisplaysChan
|
||||
/**
|
||||
* Called when top focused window changes to determine whether or not to take over insets
|
||||
* control. Won't be called if config_remoteInsetsControllerControlsSystemBars is false.
|
||||
* @param packageName The name of the package that is open in the top focussed window.
|
||||
* @param component The application component that is open in the top focussed window.
|
||||
* @param requestedVisibilities The insets visibilities requested by the focussed window.
|
||||
*/
|
||||
default void topFocusedWindowChanged(String packageName,
|
||||
default void topFocusedWindowChanged(ComponentName component,
|
||||
InsetsVisibilities requestedVisibilities) {}
|
||||
|
||||
/**
|
||||
|
||||
@@ -24,6 +24,7 @@ import static org.mockito.ArgumentMatchers.notNull;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.os.RemoteException;
|
||||
import android.util.SparseArray;
|
||||
import android.view.IDisplayWindowInsetsController;
|
||||
@@ -165,7 +166,7 @@ public class DisplayInsetsControllerTest extends ShellTestCase {
|
||||
int hideInsetsCount = 0;
|
||||
|
||||
@Override
|
||||
public void topFocusedWindowChanged(String packageName,
|
||||
public void topFocusedWindowChanged(ComponentName component,
|
||||
InsetsVisibilities requestedVisibilities) {
|
||||
topFocusedWindowChangedCount++;
|
||||
}
|
||||
|
||||
@@ -161,6 +161,7 @@ import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.app.ActivityManager;
|
||||
import android.app.ActivityManagerInternal;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.pm.ActivityInfo.ScreenOrientation;
|
||||
@@ -6508,12 +6509,13 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
|
||||
/**
|
||||
* Notifies the remote insets controller that the top focused window has changed.
|
||||
*
|
||||
* @param packageName The name of the package that is open in the top focused window.
|
||||
* @param component The application component that is open in the top focussed window.
|
||||
* @param requestedVisibilities The insets visibilities requested by the focussed window.
|
||||
*/
|
||||
void topFocusedWindowChanged(String packageName, InsetsVisibilities requestedVisibilities) {
|
||||
void topFocusedWindowChanged(ComponentName component,
|
||||
InsetsVisibilities requestedVisibilities) {
|
||||
try {
|
||||
mRemoteInsetsController.topFocusedWindowChanged(packageName, requestedVisibilities);
|
||||
mRemoteInsetsController.topFocusedWindowChanged(component, requestedVisibilities);
|
||||
} catch (RemoteException e) {
|
||||
Slog.w(TAG, "Failed to deliver package in top focused window change", e);
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@ import android.annotation.Nullable;
|
||||
import android.app.ActivityTaskManager;
|
||||
import android.app.StatusBarManager;
|
||||
import android.app.WindowConfiguration;
|
||||
import android.content.ComponentName;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Rect;
|
||||
import android.util.ArrayMap;
|
||||
@@ -548,8 +549,10 @@ class InsetsPolicy {
|
||||
return focusedWin;
|
||||
}
|
||||
if (remoteInsetsControllerControlsSystemBars(focusedWin)) {
|
||||
ComponentName component = focusedWin.mActivityRecord != null
|
||||
? focusedWin.mActivityRecord.mActivityComponent : null;
|
||||
mDisplayContent.mRemoteInsetsControlTarget.topFocusedWindowChanged(
|
||||
focusedWin.mAttrs.packageName, focusedWin.getRequestedVisibilities());
|
||||
component, focusedWin.getRequestedVisibilities());
|
||||
return mDisplayContent.mRemoteInsetsControlTarget;
|
||||
}
|
||||
if (mPolicy.areSystemBarsForcedShownLw()) {
|
||||
@@ -606,8 +609,10 @@ class InsetsPolicy {
|
||||
return null;
|
||||
}
|
||||
if (remoteInsetsControllerControlsSystemBars(focusedWin)) {
|
||||
ComponentName component = focusedWin.mActivityRecord != null
|
||||
? focusedWin.mActivityRecord.mActivityComponent : null;
|
||||
mDisplayContent.mRemoteInsetsControlTarget.topFocusedWindowChanged(
|
||||
focusedWin.mAttrs.packageName, focusedWin.getRequestedVisibilities());
|
||||
component, focusedWin.getRequestedVisibilities());
|
||||
return mDisplayContent.mRemoteInsetsControlTarget;
|
||||
}
|
||||
if (mPolicy.areSystemBarsForcedShownLw()) {
|
||||
|
||||
@@ -811,7 +811,7 @@ class WindowTestsBase extends SystemServiceTestsBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void topFocusedWindowChanged(String packageName,
|
||||
public void topFocusedWindowChanged(ComponentName component,
|
||||
InsetsVisibilities requestedVisibilities) {
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user