diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml index acc03c43d34ca..60d71260058f3 100644 --- a/packages/SystemUI/res/values/strings.xml +++ b/packages/SystemUI/res/values/strings.xml @@ -1345,6 +1345,7 @@ This keeps it in view until you unpin. Touch & hold Back and Overview to unpin. This keeps it in view until you unpin. Touch & hold Back and Home to unpin. + This keeps it in view until you unpin. Swipe up & hold to unpin. This keeps it in view until you unpin. Touch & hold Overview to unpin. This keeps it in view until you unpin. Touch & hold Home to unpin. diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/recents/ISystemUiProxy.aidl b/packages/SystemUI/shared/src/com/android/systemui/shared/recents/ISystemUiProxy.aidl index 6f44623eb3203..2c5fa60d3516a 100644 --- a/packages/SystemUI/shared/src/com/android/systemui/shared/recents/ISystemUiProxy.aidl +++ b/packages/SystemUI/shared/src/com/android/systemui/shared/recents/ISystemUiProxy.aidl @@ -96,4 +96,9 @@ interface ISystemUiProxy { * Notifies that the accessibility button in the system's navigation area has been long clicked */ void notifyAccessibilityButtonLongClicked() = 16; + + /** + * Ends the system screen pinning. + */ + void stopScreenPinning() = 17; } diff --git a/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java b/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java index 3ace7050c743a..5ed6a429cc2f8 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java +++ b/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java @@ -35,6 +35,7 @@ import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_N import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_SCREEN_PINNING; import android.annotation.FloatRange; +import android.app.ActivityTaskManager; import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.Context; @@ -150,6 +151,25 @@ public class OverviewProxyService implements CallbackController { + try { + ActivityTaskManager.getService().stopSystemLockTaskMode(); + } catch (RemoteException e) { + Log.e(TAG_OPS, "Failed to stop screen pinning"); + } + }); + } finally { + Binder.restoreCallingIdentity(token); + } + } + @Override public void onStatusBarMotionEvent(MotionEvent event) { if (!verifyCaller("onStatusBarMotionEvent")) { diff --git a/packages/SystemUI/src/com/android/systemui/recents/ScreenPinningRequest.java b/packages/SystemUI/src/com/android/systemui/recents/ScreenPinningRequest.java index 07391ed5867f6..ade903d7e2721 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/ScreenPinningRequest.java +++ b/packages/SystemUI/src/com/android/systemui/recents/ScreenPinningRequest.java @@ -48,14 +48,17 @@ import android.widget.TextView; import com.android.systemui.Dependency; import com.android.systemui.R; import com.android.systemui.SysUiServiceProvider; +import com.android.systemui.shared.system.QuickStepContract; import com.android.systemui.shared.system.WindowManagerWrapper; import com.android.systemui.statusbar.phone.NavigationBarView; +import com.android.systemui.statusbar.phone.NavigationModeController; import com.android.systemui.statusbar.phone.StatusBar; import com.android.systemui.util.leak.RotationUtils; import java.util.ArrayList; -public class ScreenPinningRequest implements View.OnClickListener { +public class ScreenPinningRequest implements View.OnClickListener, + NavigationModeController.ModeChangedListener { private final Context mContext; @@ -64,6 +67,7 @@ public class ScreenPinningRequest implements View.OnClickListener { private final OverviewProxyService mOverviewProxyService; private RequestWindowView mRequestWindow; + private int mNavBarMode; // Id of task to be pinned or locked. private int taskId; @@ -75,6 +79,7 @@ public class ScreenPinningRequest implements View.OnClickListener { mWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE); mOverviewProxyService = Dependency.get(OverviewProxyService.class); + mNavBarMode = Dependency.get(NavigationModeController.class).addListener(this); } public void clearPrompt() { @@ -103,6 +108,11 @@ public class ScreenPinningRequest implements View.OnClickListener { mWindowManager.addView(mRequestWindow, lp); } + @Override + public void onNavigationModeChanged(int mode) { + mNavBarMode = mode; + } + public void onConfigurationChanged() { if (mRequestWindow != null) { mRequestWindow.onConfigurationChanged(); @@ -224,7 +234,9 @@ public class ScreenPinningRequest implements View.OnClickListener { mLayout.findViewById(R.id.screen_pinning_text_area) .setLayoutDirection(View.LAYOUT_DIRECTION_LOCALE); View buttons = mLayout.findViewById(R.id.screen_pinning_buttons); - if (WindowManagerWrapper.getInstance().hasSoftNavigationBar(mContext.getDisplayId())) { + WindowManagerWrapper wm = WindowManagerWrapper.getInstance(); + if (!QuickStepContract.isGesturalMode(mNavBarMode) + && wm.hasSoftNavigationBar(mContext.getDisplayId())) { buttons.setLayoutDirection(View.LAYOUT_DIRECTION_LOCALE); swapChildrenIfRtlAndVertical(buttons); } else { @@ -248,7 +260,9 @@ public class ScreenPinningRequest implements View.OnClickListener { && navigationBarView.isRecentsButtonVisible(); boolean touchExplorationEnabled = mAccessibilityService.isTouchExplorationEnabled(); int descriptionStringResId; - if (recentsVisible) { + if (QuickStepContract.isGesturalMode(mNavBarMode)) { + descriptionStringResId = R.string.screen_pinning_description_gestural; + } else if (recentsVisible) { mLayout.findViewById(R.id.screen_pinning_recents_group).setVisibility(VISIBLE); mLayout.findViewById(R.id.screen_pinning_home_bg_light).setVisibility(INVISIBLE); mLayout.findViewById(R.id.screen_pinning_home_bg).setVisibility(INVISIBLE);