Loading libs/WindowManager/Shell/src/com/android/wm/shell/TaskView.java +11 −8 Original line number Diff line number Diff line Loading @@ -118,15 +118,15 @@ public class TaskView extends SurfaceView implements SurfaceHolder.Callback, * * @param shortcut the shortcut used to launch the activity. * @param options options for the activity. * @param sourceBounds the rect containing the source bounds of the clicked icon to open * this shortcut. * @param launchBounds the bounds (window size and position) that the activity should be * launched in, in pixels and in screen coordinates. */ public void startShortcutActivity(@NonNull ShortcutInfo shortcut, @NonNull ActivityOptions options, @Nullable Rect sourceBounds) { prepareActivityOptions(options); @NonNull ActivityOptions options, @Nullable Rect launchBounds) { prepareActivityOptions(options, launchBounds); LauncherApps service = mContext.getSystemService(LauncherApps.class); try { service.startShortcut(shortcut, sourceBounds, options.toBundle()); service.startShortcut(shortcut, null /* sourceBounds */, options.toBundle()); } catch (Exception e) { throw new RuntimeException(e); } Loading @@ -138,10 +138,12 @@ public class TaskView extends SurfaceView implements SurfaceHolder.Callback, * @param pendingIntent Intent used to launch an activity. * @param fillInIntent Additional Intent data, see {@link Intent#fillIn Intent.fillIn()} * @param options options for the activity. * @param launchBounds the bounds (window size and position) that the activity should be * launched in, in pixels and in screen coordinates. */ public void startActivity(@NonNull PendingIntent pendingIntent, @Nullable Intent fillInIntent, @NonNull ActivityOptions options) { prepareActivityOptions(options); @NonNull ActivityOptions options, @Nullable Rect launchBounds) { prepareActivityOptions(options, launchBounds); try { pendingIntent.send(mContext, 0 /* code */, fillInIntent, null /* onFinished */, null /* handler */, null /* requiredPermission */, Loading @@ -151,11 +153,12 @@ public class TaskView extends SurfaceView implements SurfaceHolder.Callback, } } private void prepareActivityOptions(ActivityOptions options) { private void prepareActivityOptions(ActivityOptions options, Rect launchBounds) { final Binder launchCookie = new Binder(); mShellExecutor.execute(() -> { mTaskOrganizer.setPendingLaunchCookieListener(launchCookie, this); }); options.setLaunchBounds(launchBounds); options.setLaunchCookie(launchCookie); options.setLaunchWindowingMode(WINDOWING_MODE_MULTI_WINDOW); options.setRemoveWithTaskOrganizer(true); Loading libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleExpandedView.java +6 −2 Original line number Diff line number Diff line Loading @@ -153,6 +153,9 @@ public class BubbleExpandedView extends LinearLayout { ActivityOptions options = ActivityOptions.makeCustomAnimation(getContext(), 0 /* enterResId */, 0 /* exitResId */); Rect launchBounds = new Rect(); mTaskView.getBoundsOnScreen(launchBounds); // TODO: I notice inconsistencies in lifecycle // Post to keep the lifecycle normal post(() -> { Loading @@ -166,7 +169,7 @@ public class BubbleExpandedView extends LinearLayout { if (!mIsOverflow && mBubble.hasMetadataShortcutId()) { options.setApplyActivityFlagsForBubbles(true); mTaskView.startShortcutActivity(mBubble.getShortcutInfo(), options, null /* sourceBounds */); options, launchBounds); } else { Intent fillInIntent = new Intent(); // Apply flags to make behaviour match documentLaunchMode=always. Loading @@ -175,7 +178,8 @@ public class BubbleExpandedView extends LinearLayout { if (mBubble != null) { mBubble.setIntentActive(); } mTaskView.startActivity(mPendingIntent, fillInIntent, options); mTaskView.startActivity(mPendingIntent, fillInIntent, options, launchBounds); } } catch (RuntimeException e) { // If there's a runtime exception here then there's something Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/TaskViewTest.java +2 −1 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ import android.app.ActivityManager; import android.app.ActivityOptions; import android.app.PendingIntent; import android.content.Context; import android.graphics.Rect; import android.testing.AndroidTestingRunner; import android.testing.TestableLooper; import android.view.SurfaceControl; Loading Loading @@ -125,7 +126,7 @@ public class TaskViewTest extends ShellTestCase { @Test public void testStartActivity() { ActivityOptions options = ActivityOptions.makeBasic(); mTaskView.startActivity(mock(PendingIntent.class), null, options); mTaskView.startActivity(mock(PendingIntent.class), null, options, new Rect(0, 0, 100, 100)); verify(mOrganizer).setPendingLaunchCookieListener(any(), eq(mTaskView)); assertThat(options.getLaunchWindowingMode()).isEqualTo(WINDOWING_MODE_MULTI_WINDOW); Loading packages/SystemUI/res/values/dimens.xml +1 −0 Original line number Diff line number Diff line Loading @@ -1333,6 +1333,7 @@ <dimen name="controls_setup_title">22sp</dimen> <dimen name="controls_setup_subtitle">14sp</dimen> <dimen name="controls_setup_vertical_padding">52dp</dimen> <dimen name="controls_detail_dialog_header_height">52dp</dimen> <!-- Home Controls activity view detail panel--> <dimen name="controls_activity_view_top_offset">100dp</dimen> Loading packages/SystemUI/src/com/android/systemui/controls/ui/DetailDialog.kt +21 −2 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import android.app.PendingIntent import android.content.ComponentName import android.content.Context import android.content.Intent import android.graphics.Rect import android.view.View import android.view.ViewGroup import android.view.WindowInsets Loading Loading @@ -83,8 +84,9 @@ class DetailDialog( taskView.startActivity( PendingIntent.getActivity(context, 0, launchIntent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE), null, options null /* fillInIntent */, options, getTaskViewBounds() ) } Loading Loading @@ -159,6 +161,23 @@ class DetailDialog( taskView.setListener(cvh.uiExecutor, stateCallback) } fun getTaskViewBounds(): Rect { val wm = context.getSystemService(WindowManager::class.java) val windowMetrics = wm.getCurrentWindowMetrics() val rect = windowMetrics.bounds val metricInsets = windowMetrics.windowInsets val insets = metricInsets.getInsetsIgnoringVisibility(Type.systemBars() or Type.displayCutout()) val headerHeight = context.resources.getDimensionPixelSize( R.dimen.controls_detail_dialog_header_height) val finalRect = Rect(rect.left - insets.left /* left */, rect.top + insets.top + headerHeight /* top */, rect.right - insets.right /* right */, rect.bottom - insets.bottom /* bottom */) return finalRect } override fun dismiss() { if (!isShowing()) return taskView.release() Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/TaskView.java +11 −8 Original line number Diff line number Diff line Loading @@ -118,15 +118,15 @@ public class TaskView extends SurfaceView implements SurfaceHolder.Callback, * * @param shortcut the shortcut used to launch the activity. * @param options options for the activity. * @param sourceBounds the rect containing the source bounds of the clicked icon to open * this shortcut. * @param launchBounds the bounds (window size and position) that the activity should be * launched in, in pixels and in screen coordinates. */ public void startShortcutActivity(@NonNull ShortcutInfo shortcut, @NonNull ActivityOptions options, @Nullable Rect sourceBounds) { prepareActivityOptions(options); @NonNull ActivityOptions options, @Nullable Rect launchBounds) { prepareActivityOptions(options, launchBounds); LauncherApps service = mContext.getSystemService(LauncherApps.class); try { service.startShortcut(shortcut, sourceBounds, options.toBundle()); service.startShortcut(shortcut, null /* sourceBounds */, options.toBundle()); } catch (Exception e) { throw new RuntimeException(e); } Loading @@ -138,10 +138,12 @@ public class TaskView extends SurfaceView implements SurfaceHolder.Callback, * @param pendingIntent Intent used to launch an activity. * @param fillInIntent Additional Intent data, see {@link Intent#fillIn Intent.fillIn()} * @param options options for the activity. * @param launchBounds the bounds (window size and position) that the activity should be * launched in, in pixels and in screen coordinates. */ public void startActivity(@NonNull PendingIntent pendingIntent, @Nullable Intent fillInIntent, @NonNull ActivityOptions options) { prepareActivityOptions(options); @NonNull ActivityOptions options, @Nullable Rect launchBounds) { prepareActivityOptions(options, launchBounds); try { pendingIntent.send(mContext, 0 /* code */, fillInIntent, null /* onFinished */, null /* handler */, null /* requiredPermission */, Loading @@ -151,11 +153,12 @@ public class TaskView extends SurfaceView implements SurfaceHolder.Callback, } } private void prepareActivityOptions(ActivityOptions options) { private void prepareActivityOptions(ActivityOptions options, Rect launchBounds) { final Binder launchCookie = new Binder(); mShellExecutor.execute(() -> { mTaskOrganizer.setPendingLaunchCookieListener(launchCookie, this); }); options.setLaunchBounds(launchBounds); options.setLaunchCookie(launchCookie); options.setLaunchWindowingMode(WINDOWING_MODE_MULTI_WINDOW); options.setRemoveWithTaskOrganizer(true); Loading
libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleExpandedView.java +6 −2 Original line number Diff line number Diff line Loading @@ -153,6 +153,9 @@ public class BubbleExpandedView extends LinearLayout { ActivityOptions options = ActivityOptions.makeCustomAnimation(getContext(), 0 /* enterResId */, 0 /* exitResId */); Rect launchBounds = new Rect(); mTaskView.getBoundsOnScreen(launchBounds); // TODO: I notice inconsistencies in lifecycle // Post to keep the lifecycle normal post(() -> { Loading @@ -166,7 +169,7 @@ public class BubbleExpandedView extends LinearLayout { if (!mIsOverflow && mBubble.hasMetadataShortcutId()) { options.setApplyActivityFlagsForBubbles(true); mTaskView.startShortcutActivity(mBubble.getShortcutInfo(), options, null /* sourceBounds */); options, launchBounds); } else { Intent fillInIntent = new Intent(); // Apply flags to make behaviour match documentLaunchMode=always. Loading @@ -175,7 +178,8 @@ public class BubbleExpandedView extends LinearLayout { if (mBubble != null) { mBubble.setIntentActive(); } mTaskView.startActivity(mPendingIntent, fillInIntent, options); mTaskView.startActivity(mPendingIntent, fillInIntent, options, launchBounds); } } catch (RuntimeException e) { // If there's a runtime exception here then there's something Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/TaskViewTest.java +2 −1 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ import android.app.ActivityManager; import android.app.ActivityOptions; import android.app.PendingIntent; import android.content.Context; import android.graphics.Rect; import android.testing.AndroidTestingRunner; import android.testing.TestableLooper; import android.view.SurfaceControl; Loading Loading @@ -125,7 +126,7 @@ public class TaskViewTest extends ShellTestCase { @Test public void testStartActivity() { ActivityOptions options = ActivityOptions.makeBasic(); mTaskView.startActivity(mock(PendingIntent.class), null, options); mTaskView.startActivity(mock(PendingIntent.class), null, options, new Rect(0, 0, 100, 100)); verify(mOrganizer).setPendingLaunchCookieListener(any(), eq(mTaskView)); assertThat(options.getLaunchWindowingMode()).isEqualTo(WINDOWING_MODE_MULTI_WINDOW); Loading
packages/SystemUI/res/values/dimens.xml +1 −0 Original line number Diff line number Diff line Loading @@ -1333,6 +1333,7 @@ <dimen name="controls_setup_title">22sp</dimen> <dimen name="controls_setup_subtitle">14sp</dimen> <dimen name="controls_setup_vertical_padding">52dp</dimen> <dimen name="controls_detail_dialog_header_height">52dp</dimen> <!-- Home Controls activity view detail panel--> <dimen name="controls_activity_view_top_offset">100dp</dimen> Loading
packages/SystemUI/src/com/android/systemui/controls/ui/DetailDialog.kt +21 −2 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import android.app.PendingIntent import android.content.ComponentName import android.content.Context import android.content.Intent import android.graphics.Rect import android.view.View import android.view.ViewGroup import android.view.WindowInsets Loading Loading @@ -83,8 +84,9 @@ class DetailDialog( taskView.startActivity( PendingIntent.getActivity(context, 0, launchIntent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE), null, options null /* fillInIntent */, options, getTaskViewBounds() ) } Loading Loading @@ -159,6 +161,23 @@ class DetailDialog( taskView.setListener(cvh.uiExecutor, stateCallback) } fun getTaskViewBounds(): Rect { val wm = context.getSystemService(WindowManager::class.java) val windowMetrics = wm.getCurrentWindowMetrics() val rect = windowMetrics.bounds val metricInsets = windowMetrics.windowInsets val insets = metricInsets.getInsetsIgnoringVisibility(Type.systemBars() or Type.displayCutout()) val headerHeight = context.resources.getDimensionPixelSize( R.dimen.controls_detail_dialog_header_height) val finalRect = Rect(rect.left - insets.left /* left */, rect.top + insets.top + headerHeight /* top */, rect.right - insets.right /* right */, rect.bottom - insets.bottom /* bottom */) return finalRect } override fun dismiss() { if (!isShowing()) return taskView.release() Loading