Loading libs/WindowManager/Shell/src/com/android/wm/shell/draganddrop/DragAndDropController.java +24 −11 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ import static android.view.WindowManager.LayoutParams.SYSTEM_FLAG_SHOW_FOR_ALL_U import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY; import android.content.ClipDescription; import android.content.ComponentCallbacks2; import android.content.Context; import android.content.res.Configuration; import android.graphics.PixelFormat; Loading @@ -58,9 +59,9 @@ import com.android.launcher3.icons.IconProvider; import com.android.wm.shell.R; import com.android.wm.shell.common.DisplayController; import com.android.wm.shell.common.ShellExecutor; import com.android.wm.shell.common.annotations.ExternalMainThread; import com.android.wm.shell.protolog.ShellProtoLogGroup; import com.android.wm.shell.splitscreen.SplitScreenController; import com.android.wm.shell.sysui.ConfigurationChangeListener; import com.android.wm.shell.sysui.ShellController; import com.android.wm.shell.sysui.ShellInit; Loading @@ -70,7 +71,7 @@ import java.util.ArrayList; * Handles the global drag and drop handling for the Shell. */ public class DragAndDropController implements DisplayController.OnDisplaysChangedListener, View.OnDragListener, ConfigurationChangeListener { View.OnDragListener, ComponentCallbacks2 { private static final String TAG = DragAndDropController.class.getSimpleName(); Loading Loading @@ -119,7 +120,6 @@ public class DragAndDropController implements DisplayController.OnDisplaysChange mMainExecutor.executeDelayed(() -> { mDisplayController.addDisplayWindowListener(this); }, 0); mShellController.addConfigurationChangeListener(this); } /** Loading Loading @@ -180,6 +180,7 @@ public class DragAndDropController implements DisplayController.OnDisplaysChange try { wm.addView(rootView, layoutParams); addDisplayDropTarget(displayId, context, wm, rootView, dragLayout); context.registerComponentCallbacks(this); } catch (WindowManager.InvalidDisplayException e) { Slog.w(TAG, "Unable to add view for display id: " + displayId); } Loading Loading @@ -209,6 +210,7 @@ public class DragAndDropController implements DisplayController.OnDisplaysChange if (pd == null) { return; } pd.context.unregisterComponentCallbacks(this); pd.wm.removeViewImmediate(pd.rootView); mDisplayDropTargets.remove(displayId); } Loading Loading @@ -328,18 +330,29 @@ public class DragAndDropController implements DisplayController.OnDisplaysChange return mimeTypes; } // Note: Component callbacks are always called on the main thread of the process @ExternalMainThread @Override public void onThemeChanged() { public void onConfigurationChanged(Configuration newConfig) { mMainExecutor.execute(() -> { for (int i = 0; i < mDisplayDropTargets.size(); i++) { mDisplayDropTargets.get(i).dragLayout.onThemeChange(); mDisplayDropTargets.get(i).dragLayout.onConfigChanged(newConfig); } }); } // Note: Component callbacks are always called on the main thread of the process @ExternalMainThread @Override public void onConfigurationChanged(Configuration newConfig) { for (int i = 0; i < mDisplayDropTargets.size(); i++) { mDisplayDropTargets.get(i).dragLayout.onConfigChanged(newConfig); public void onTrimMemory(int level) { // Do nothing } // Note: Component callbacks are always called on the main thread of the process @ExternalMainThread @Override public void onLowMemory() { // Do nothing } private static class PerDisplay { Loading libs/WindowManager/Shell/src/com/android/wm/shell/draganddrop/DragLayout.java +13 −5 Original line number Diff line number Diff line Loading @@ -18,6 +18,8 @@ package com.android.wm.shell.draganddrop; import static android.app.StatusBarManager.DISABLE_NONE; import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD; import static android.content.pm.ActivityInfo.CONFIG_ASSETS_PATHS; import static android.content.pm.ActivityInfo.CONFIG_UI_MODE; import static android.view.ViewGroup.LayoutParams.MATCH_PARENT; import static com.android.wm.shell.common.split.SplitScreenConstants.SPLIT_POSITION_BOTTOM_OR_RIGHT; Loading Loading @@ -72,6 +74,7 @@ public class DragLayout extends LinearLayout { private final SplitScreenController mSplitScreenController; private final IconProvider mIconProvider; private final StatusBarManager mStatusBarManager; private final Configuration mLastConfiguration = new Configuration(); private DragAndDropPolicy.Target mCurrentTarget = null; private DropZoneView mDropZoneView1; Loading @@ -92,6 +95,7 @@ public class DragLayout extends LinearLayout { mIconProvider = iconProvider; mPolicy = new DragAndDropPolicy(context, splitScreenController); mStatusBarManager = context.getSystemService(StatusBarManager.class); mLastConfiguration.setTo(context.getResources().getConfiguration()); mDisplayMargin = context.getResources().getDimensionPixelSize( R.dimen.drop_layout_display_margin); Loading Loading @@ -132,11 +136,6 @@ public class DragLayout extends LinearLayout { return super.onApplyWindowInsets(insets); } public void onThemeChange() { mDropZoneView1.onThemeChange(); mDropZoneView2.onThemeChange(); } public void onConfigChanged(Configuration newConfig) { if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE && getOrientation() != HORIZONTAL) { Loading @@ -147,6 +146,15 @@ public class DragLayout extends LinearLayout { setOrientation(LinearLayout.VERTICAL); updateContainerMargins(newConfig.orientation); } final int diff = newConfig.diff(mLastConfiguration); final boolean themeChanged = (diff & CONFIG_ASSETS_PATHS) != 0 || (diff & CONFIG_UI_MODE) != 0; if (themeChanged) { mDropZoneView1.onThemeChange(); mDropZoneView2.onThemeChange(); } mLastConfiguration.setTo(newConfig); } private void updateContainerMarginsForSingleTask() { Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/draganddrop/DragAndDropControllerTest.java +1 −7 Original line number Diff line number Diff line Loading @@ -48,7 +48,6 @@ import com.android.launcher3.icons.IconProvider; import com.android.wm.shell.ShellTestCase; import com.android.wm.shell.common.DisplayController; import com.android.wm.shell.common.ShellExecutor; import com.android.wm.shell.splitscreen.SplitScreenController; import com.android.wm.shell.sysui.ShellController; import com.android.wm.shell.sysui.ShellInit; Loading Loading @@ -82,7 +81,7 @@ public class DragAndDropControllerTest extends ShellTestCase { @Mock private ShellExecutor mMainExecutor; @Mock private SplitScreenController mSplitScreenController; private WindowManager mWindowManager; private DragAndDropController mController; Loading @@ -99,11 +98,6 @@ public class DragAndDropControllerTest extends ShellTestCase { verify(mShellInit, times(1)).addInitCallback(any(), any()); } @Test public void instantiateController_registerConfigChangeListener() { verify(mShellController, times(1)).addConfigurationChangeListener(any()); } @Test public void testIgnoreNonDefaultDisplays() { final int nonDefaultDisplayId = 12345; Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/draganddrop/DragAndDropController.java +24 −11 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ import static android.view.WindowManager.LayoutParams.SYSTEM_FLAG_SHOW_FOR_ALL_U import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY; import android.content.ClipDescription; import android.content.ComponentCallbacks2; import android.content.Context; import android.content.res.Configuration; import android.graphics.PixelFormat; Loading @@ -58,9 +59,9 @@ import com.android.launcher3.icons.IconProvider; import com.android.wm.shell.R; import com.android.wm.shell.common.DisplayController; import com.android.wm.shell.common.ShellExecutor; import com.android.wm.shell.common.annotations.ExternalMainThread; import com.android.wm.shell.protolog.ShellProtoLogGroup; import com.android.wm.shell.splitscreen.SplitScreenController; import com.android.wm.shell.sysui.ConfigurationChangeListener; import com.android.wm.shell.sysui.ShellController; import com.android.wm.shell.sysui.ShellInit; Loading @@ -70,7 +71,7 @@ import java.util.ArrayList; * Handles the global drag and drop handling for the Shell. */ public class DragAndDropController implements DisplayController.OnDisplaysChangedListener, View.OnDragListener, ConfigurationChangeListener { View.OnDragListener, ComponentCallbacks2 { private static final String TAG = DragAndDropController.class.getSimpleName(); Loading Loading @@ -119,7 +120,6 @@ public class DragAndDropController implements DisplayController.OnDisplaysChange mMainExecutor.executeDelayed(() -> { mDisplayController.addDisplayWindowListener(this); }, 0); mShellController.addConfigurationChangeListener(this); } /** Loading Loading @@ -180,6 +180,7 @@ public class DragAndDropController implements DisplayController.OnDisplaysChange try { wm.addView(rootView, layoutParams); addDisplayDropTarget(displayId, context, wm, rootView, dragLayout); context.registerComponentCallbacks(this); } catch (WindowManager.InvalidDisplayException e) { Slog.w(TAG, "Unable to add view for display id: " + displayId); } Loading Loading @@ -209,6 +210,7 @@ public class DragAndDropController implements DisplayController.OnDisplaysChange if (pd == null) { return; } pd.context.unregisterComponentCallbacks(this); pd.wm.removeViewImmediate(pd.rootView); mDisplayDropTargets.remove(displayId); } Loading Loading @@ -328,18 +330,29 @@ public class DragAndDropController implements DisplayController.OnDisplaysChange return mimeTypes; } // Note: Component callbacks are always called on the main thread of the process @ExternalMainThread @Override public void onThemeChanged() { public void onConfigurationChanged(Configuration newConfig) { mMainExecutor.execute(() -> { for (int i = 0; i < mDisplayDropTargets.size(); i++) { mDisplayDropTargets.get(i).dragLayout.onThemeChange(); mDisplayDropTargets.get(i).dragLayout.onConfigChanged(newConfig); } }); } // Note: Component callbacks are always called on the main thread of the process @ExternalMainThread @Override public void onConfigurationChanged(Configuration newConfig) { for (int i = 0; i < mDisplayDropTargets.size(); i++) { mDisplayDropTargets.get(i).dragLayout.onConfigChanged(newConfig); public void onTrimMemory(int level) { // Do nothing } // Note: Component callbacks are always called on the main thread of the process @ExternalMainThread @Override public void onLowMemory() { // Do nothing } private static class PerDisplay { Loading
libs/WindowManager/Shell/src/com/android/wm/shell/draganddrop/DragLayout.java +13 −5 Original line number Diff line number Diff line Loading @@ -18,6 +18,8 @@ package com.android.wm.shell.draganddrop; import static android.app.StatusBarManager.DISABLE_NONE; import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD; import static android.content.pm.ActivityInfo.CONFIG_ASSETS_PATHS; import static android.content.pm.ActivityInfo.CONFIG_UI_MODE; import static android.view.ViewGroup.LayoutParams.MATCH_PARENT; import static com.android.wm.shell.common.split.SplitScreenConstants.SPLIT_POSITION_BOTTOM_OR_RIGHT; Loading Loading @@ -72,6 +74,7 @@ public class DragLayout extends LinearLayout { private final SplitScreenController mSplitScreenController; private final IconProvider mIconProvider; private final StatusBarManager mStatusBarManager; private final Configuration mLastConfiguration = new Configuration(); private DragAndDropPolicy.Target mCurrentTarget = null; private DropZoneView mDropZoneView1; Loading @@ -92,6 +95,7 @@ public class DragLayout extends LinearLayout { mIconProvider = iconProvider; mPolicy = new DragAndDropPolicy(context, splitScreenController); mStatusBarManager = context.getSystemService(StatusBarManager.class); mLastConfiguration.setTo(context.getResources().getConfiguration()); mDisplayMargin = context.getResources().getDimensionPixelSize( R.dimen.drop_layout_display_margin); Loading Loading @@ -132,11 +136,6 @@ public class DragLayout extends LinearLayout { return super.onApplyWindowInsets(insets); } public void onThemeChange() { mDropZoneView1.onThemeChange(); mDropZoneView2.onThemeChange(); } public void onConfigChanged(Configuration newConfig) { if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE && getOrientation() != HORIZONTAL) { Loading @@ -147,6 +146,15 @@ public class DragLayout extends LinearLayout { setOrientation(LinearLayout.VERTICAL); updateContainerMargins(newConfig.orientation); } final int diff = newConfig.diff(mLastConfiguration); final boolean themeChanged = (diff & CONFIG_ASSETS_PATHS) != 0 || (diff & CONFIG_UI_MODE) != 0; if (themeChanged) { mDropZoneView1.onThemeChange(); mDropZoneView2.onThemeChange(); } mLastConfiguration.setTo(newConfig); } private void updateContainerMarginsForSingleTask() { Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/draganddrop/DragAndDropControllerTest.java +1 −7 Original line number Diff line number Diff line Loading @@ -48,7 +48,6 @@ import com.android.launcher3.icons.IconProvider; import com.android.wm.shell.ShellTestCase; import com.android.wm.shell.common.DisplayController; import com.android.wm.shell.common.ShellExecutor; import com.android.wm.shell.splitscreen.SplitScreenController; import com.android.wm.shell.sysui.ShellController; import com.android.wm.shell.sysui.ShellInit; Loading Loading @@ -82,7 +81,7 @@ public class DragAndDropControllerTest extends ShellTestCase { @Mock private ShellExecutor mMainExecutor; @Mock private SplitScreenController mSplitScreenController; private WindowManager mWindowManager; private DragAndDropController mController; Loading @@ -99,11 +98,6 @@ public class DragAndDropControllerTest extends ShellTestCase { verify(mShellInit, times(1)).addInitCallback(any(), any()); } @Test public void instantiateController_registerConfigChangeListener() { verify(mShellController, times(1)).addConfigurationChangeListener(any()); } @Test public void testIgnoreNonDefaultDisplays() { final int nonDefaultDisplayId = 12345; Loading