Merge "Add screenshot back to power menu for some devices" into rvc-dev am: 30233e0682 am: ab73ba71fb
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/12549895 Change-Id: Idbebc1a6ba29ab7eed0efbeec216b804f8c45a2c
This commit is contained in:
@@ -2774,6 +2774,7 @@
|
|||||||
<item>power</item>
|
<item>power</item>
|
||||||
<item>restart</item>
|
<item>restart</item>
|
||||||
<item>logout</item>
|
<item>logout</item>
|
||||||
|
<item>screenshot</item>
|
||||||
<item>bugreport</item>
|
<item>bugreport</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import static android.view.WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
|
|||||||
import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
|
import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
|
||||||
import static android.view.WindowManager.ScreenshotSource.SCREENSHOT_GLOBAL_ACTIONS;
|
import static android.view.WindowManager.ScreenshotSource.SCREENSHOT_GLOBAL_ACTIONS;
|
||||||
import static android.view.WindowManager.TAKE_SCREENSHOT_FULLSCREEN;
|
import static android.view.WindowManager.TAKE_SCREENSHOT_FULLSCREEN;
|
||||||
|
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_2BUTTON;
|
||||||
|
|
||||||
import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.SOME_AUTH_REQUIRED_AFTER_USER_REQUEST;
|
import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.SOME_AUTH_REQUIRED_AFTER_USER_REQUEST;
|
||||||
import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STRONG_AUTH_NOT_REQUIRED;
|
import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STRONG_AUTH_NOT_REQUIRED;
|
||||||
@@ -547,7 +548,7 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
|
|||||||
if (!mDeviceProvisioned && !action.showBeforeProvisioning()) {
|
if (!mDeviceProvisioned && !action.showBeforeProvisioning()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return action.shouldShow();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -962,6 +963,8 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
|
|||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
class ScreenshotAction extends SinglePressAction implements LongPressAction {
|
class ScreenshotAction extends SinglePressAction implements LongPressAction {
|
||||||
|
final String KEY_SYSTEM_NAV_2BUTTONS = "system_nav_2buttons";
|
||||||
|
|
||||||
public ScreenshotAction() {
|
public ScreenshotAction() {
|
||||||
super(R.drawable.ic_screenshot, R.string.global_action_screenshot);
|
super(R.drawable.ic_screenshot, R.string.global_action_screenshot);
|
||||||
}
|
}
|
||||||
@@ -993,6 +996,19 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldShow() {
|
||||||
|
// Include screenshot in power menu for legacy nav because it is not accessible
|
||||||
|
// through Recents in that mode
|
||||||
|
return is2ButtonNavigationEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean is2ButtonNavigationEnabled() {
|
||||||
|
return NAV_BAR_MODE_2BUTTON == mContext.getResources().getInteger(
|
||||||
|
com.android.internal.R.integer.config_navBarInteractionMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onLongPress() {
|
public boolean onLongPress() {
|
||||||
if (FeatureFlagUtils.isEnabled(mContext, FeatureFlagUtils.SCREENRECORD_LONG_PRESS)) {
|
if (FeatureFlagUtils.isEnabled(mContext, FeatureFlagUtils.SCREENRECORD_LONG_PRESS)) {
|
||||||
@@ -1616,6 +1632,10 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
CharSequence getMessage();
|
CharSequence getMessage();
|
||||||
|
|
||||||
|
default boolean shouldShow() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ import android.testing.TestableLooper;
|
|||||||
import android.util.FeatureFlagUtils;
|
import android.util.FeatureFlagUtils;
|
||||||
import android.view.IWindowManager;
|
import android.view.IWindowManager;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.WindowManagerPolicyConstants;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
|
|
||||||
import androidx.test.filters.SmallTest;
|
import androidx.test.filters.SmallTest;
|
||||||
@@ -241,6 +242,28 @@ public class GlobalActionsDialogTest extends SysuiTestCase {
|
|||||||
verifyLogPosted(GlobalActionsDialog.GlobalActionsEvent.GA_SCREENSHOT_LONG_PRESS);
|
verifyLogPosted(GlobalActionsDialog.GlobalActionsEvent.GA_SCREENSHOT_LONG_PRESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testShouldShowScreenshot() {
|
||||||
|
mContext.getOrCreateTestableResources().addOverride(
|
||||||
|
com.android.internal.R.integer.config_navBarInteractionMode,
|
||||||
|
WindowManagerPolicyConstants.NAV_BAR_MODE_2BUTTON);
|
||||||
|
|
||||||
|
GlobalActionsDialog.ScreenshotAction screenshotAction =
|
||||||
|
mGlobalActionsDialog.makeScreenshotActionForTesting();
|
||||||
|
assertThat(screenshotAction.shouldShow()).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testShouldNotShowScreenshot() {
|
||||||
|
mContext.getOrCreateTestableResources().addOverride(
|
||||||
|
com.android.internal.R.integer.config_navBarInteractionMode,
|
||||||
|
WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON);
|
||||||
|
|
||||||
|
GlobalActionsDialog.ScreenshotAction screenshotAction =
|
||||||
|
mGlobalActionsDialog.makeScreenshotActionForTesting();
|
||||||
|
assertThat(screenshotAction.shouldShow()).isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
private void verifyLogPosted(GlobalActionsDialog.GlobalActionsEvent event) {
|
private void verifyLogPosted(GlobalActionsDialog.GlobalActionsEvent event) {
|
||||||
mTestableLooper.processAllMessages();
|
mTestableLooper.processAllMessages();
|
||||||
verify(mUiEventLogger, times(1))
|
verify(mUiEventLogger, times(1))
|
||||||
|
|||||||
Reference in New Issue
Block a user