Separating the UI logic for SettingsPanel and ModeSwitchButton
The existence of magnification settings panel is controlled in system UI. In MagnificationController, we would only like to guarantee that the settings panel is removed when the situation that could show settings panel is not satisfied. Bug: 279377146 Test: Manually - attach video to the bug Change-Id: I1db69a48fab4779fbec11080966f1ba08932b49f
This commit is contained in:
@@ -203,19 +203,27 @@ public class MagnificationController implements WindowMagnificationManager.Callb
|
||||
|
||||
private void updateMagnificationUIControls(int displayId, int mode) {
|
||||
final boolean isActivated = isActivated(displayId, mode);
|
||||
final boolean showUIControls;
|
||||
final boolean showModeSwitchButton;
|
||||
final boolean enableSettingsPanel;
|
||||
synchronized (mLock) {
|
||||
showUIControls = isActivated && mMagnificationCapabilities
|
||||
== Settings.Secure.ACCESSIBILITY_MAGNIFICATION_MODE_ALL;
|
||||
showModeSwitchButton = isActivated
|
||||
&& mMagnificationCapabilities == ACCESSIBILITY_MAGNIFICATION_MODE_ALL;
|
||||
enableSettingsPanel = isActivated
|
||||
&& (mMagnificationCapabilities == ACCESSIBILITY_MAGNIFICATION_MODE_ALL
|
||||
|| mMagnificationCapabilities == ACCESSIBILITY_MAGNIFICATION_MODE_WINDOW);
|
||||
}
|
||||
if (showUIControls) {
|
||||
// we only need to show magnification button, the settings panel showing should be
|
||||
// triggered only on sysui side.
|
||||
|
||||
if (showModeSwitchButton) {
|
||||
getWindowMagnificationMgr().showMagnificationButton(displayId, mode);
|
||||
} else {
|
||||
getWindowMagnificationMgr().removeMagnificationSettingsPanel(displayId);
|
||||
getWindowMagnificationMgr().removeMagnificationButton(displayId);
|
||||
}
|
||||
|
||||
if (!enableSettingsPanel) {
|
||||
// Whether the settings panel needs to be shown is controlled in system UI.
|
||||
// Here, we only guarantee that the settings panel is closed when it is not needed.
|
||||
getWindowMagnificationMgr().removeMagnificationSettingsPanel(displayId);
|
||||
}
|
||||
}
|
||||
|
||||
/** Returns {@code true} if the platform supports window magnification feature. */
|
||||
|
||||
@@ -593,6 +593,10 @@ public class MagnificationControllerTest {
|
||||
// The second time is triggered when magnification spec is changed.
|
||||
verify(mWindowMagnificationManager, times(2)).showMagnificationButton(eq(TEST_DISPLAY),
|
||||
eq(MODE_FULLSCREEN));
|
||||
// Never call removeMagnificationSettingsPanel if it is allowed to show the settings panel
|
||||
// in current capability and mode, and the magnification is activated.
|
||||
verify(mWindowMagnificationManager, never()).removeMagnificationSettingsPanel(
|
||||
eq(TEST_DISPLAY));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -758,6 +762,10 @@ public class MagnificationControllerTest {
|
||||
// The second time is triggered when accessibility action performed.
|
||||
verify(mWindowMagnificationManager, times(2)).showMagnificationButton(eq(TEST_DISPLAY),
|
||||
eq(MODE_WINDOW));
|
||||
// Never call removeMagnificationSettingsPanel if it is allowed to show the settings panel
|
||||
// in current capability and mode, and the magnification is activated.
|
||||
verify(mWindowMagnificationManager, never()).removeMagnificationSettingsPanel(
|
||||
eq(TEST_DISPLAY));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -772,6 +780,10 @@ public class MagnificationControllerTest {
|
||||
// The first time is triggered when window mode is activated.
|
||||
// The second time is triggered when accessibility action performed.
|
||||
verify(mWindowMagnificationManager, times(2)).removeMagnificationButton(eq(TEST_DISPLAY));
|
||||
// Never call removeMagnificationSettingsPanel if it is allowed to show the settings panel
|
||||
// in current capability and mode, and the magnification is activated.
|
||||
verify(mWindowMagnificationManager, never()).removeMagnificationSettingsPanel(
|
||||
eq(TEST_DISPLAY));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -939,6 +951,10 @@ public class MagnificationControllerTest {
|
||||
// The third time is triggered when user interaction changed.
|
||||
verify(mWindowMagnificationManager, times(3)).showMagnificationButton(eq(TEST_DISPLAY),
|
||||
eq(MODE_FULLSCREEN));
|
||||
// Never call removeMagnificationSettingsPanel if it is allowed to show the settings panel
|
||||
// in current capability and mode, and the magnification is activated.
|
||||
verify(mWindowMagnificationManager, never()).removeMagnificationSettingsPanel(
|
||||
eq(TEST_DISPLAY));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -953,6 +969,10 @@ public class MagnificationControllerTest {
|
||||
// The third time is triggered when user interaction changed.
|
||||
verify(mWindowMagnificationManager, times(3)).showMagnificationButton(eq(TEST_DISPLAY),
|
||||
eq(MODE_FULLSCREEN));
|
||||
// Never call removeMagnificationSettingsPanel if it is allowed to show the settings panel
|
||||
// in current capability and mode, and the magnification is activated.
|
||||
verify(mWindowMagnificationManager, never()).removeMagnificationSettingsPanel(
|
||||
eq(TEST_DISPLAY));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -966,6 +986,10 @@ public class MagnificationControllerTest {
|
||||
// The second time is triggered when user interaction changed.
|
||||
verify(mWindowMagnificationManager, times(2)).showMagnificationButton(eq(TEST_DISPLAY),
|
||||
eq(MODE_WINDOW));
|
||||
// Never call removeMagnificationSettingsPanel if it is allowed to show the settings panel
|
||||
// in current capability and mode, and the magnification is activated.
|
||||
verify(mWindowMagnificationManager, never()).removeMagnificationSettingsPanel(
|
||||
eq(TEST_DISPLAY));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -979,6 +1003,10 @@ public class MagnificationControllerTest {
|
||||
// The second time is triggered when user interaction changed.
|
||||
verify(mWindowMagnificationManager, times(2)).showMagnificationButton(eq(TEST_DISPLAY),
|
||||
eq(MODE_WINDOW));
|
||||
// Never call removeMagnificationSettingsPanel if it is allowed to show the settings panel
|
||||
// in current capability and mode, and the magnification is activated.
|
||||
verify(mWindowMagnificationManager, never()).removeMagnificationSettingsPanel(
|
||||
eq(TEST_DISPLAY));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -993,11 +1021,16 @@ public class MagnificationControllerTest {
|
||||
|
||||
verify(mWindowMagnificationManager, never()).showMagnificationButton(eq(TEST_DISPLAY),
|
||||
eq(MODE_FULLSCREEN));
|
||||
// The first time is triggered when fullscreen mode is activated.
|
||||
// The second time is triggered when magnification spec is changed.
|
||||
verify(mWindowMagnificationManager, times(2)).removeMagnificationSettingsPanel(
|
||||
eq(TEST_DISPLAY));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void onTouchInteractionChanged_fullscreenNotActivated_notShowMagnificationButton()
|
||||
public void
|
||||
onTouchInteractionChanged_fullscreenNotActivated_notShowMagnificationButton()
|
||||
throws RemoteException {
|
||||
setMagnificationModeSettings(MODE_FULLSCREEN);
|
||||
|
||||
@@ -1006,6 +1039,8 @@ public class MagnificationControllerTest {
|
||||
|
||||
verify(mWindowMagnificationManager, never()).showMagnificationButton(eq(TEST_DISPLAY),
|
||||
eq(MODE_FULLSCREEN));
|
||||
verify(mWindowMagnificationManager, times(2)).removeMagnificationSettingsPanel(
|
||||
eq(TEST_DISPLAY));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1015,6 +1050,10 @@ public class MagnificationControllerTest {
|
||||
|
||||
verify(mWindowMagnificationManager).showMagnificationButton(eq(TEST_DISPLAY),
|
||||
eq(MODE_WINDOW));
|
||||
// Never call removeMagnificationSettingsPanel if it is allowed to show the settings panel
|
||||
// in current capability and mode, and the magnification is activated.
|
||||
verify(mWindowMagnificationManager, never()).removeMagnificationSettingsPanel(
|
||||
eq(TEST_DISPLAY));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1029,25 +1068,32 @@ public class MagnificationControllerTest {
|
||||
// The third time is triggered when fullscreen mode activation state is updated.
|
||||
verify(mWindowMagnificationManager, times(3)).showMagnificationButton(eq(TEST_DISPLAY),
|
||||
eq(MODE_FULLSCREEN));
|
||||
// Never call removeMagnificationSettingsPanel if it is allowed to show the settings panel
|
||||
// in current capability and mode, and the magnification is activated.
|
||||
verify(mWindowMagnificationManager, never()).removeMagnificationSettingsPanel(
|
||||
eq(TEST_DISPLAY));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void disableWindowMode_windowEnabled_removeMagnificationButton()
|
||||
public void disableWindowMode_windowEnabled_removeMagnificationButtonAndSettingsPanel()
|
||||
throws RemoteException {
|
||||
setMagnificationEnabled(MODE_WINDOW);
|
||||
|
||||
mWindowMagnificationManager.disableWindowMagnification(TEST_DISPLAY, false);
|
||||
|
||||
verify(mWindowMagnificationManager).removeMagnificationButton(eq(TEST_DISPLAY));
|
||||
verify(mWindowMagnificationManager).removeMagnificationSettingsPanel(eq(TEST_DISPLAY));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onFullScreenDeactivated_fullScreenEnabled_removeMagnificationButton()
|
||||
public void
|
||||
onFullScreenDeactivated_fullScreenEnabled_removeMagnificationButtonAneSettingsPanel()
|
||||
throws RemoteException {
|
||||
setMagnificationEnabled(MODE_FULLSCREEN);
|
||||
mScreenMagnificationController.reset(TEST_DISPLAY, /* animate= */ true);
|
||||
|
||||
verify(mWindowMagnificationManager).removeMagnificationButton(eq(TEST_DISPLAY));
|
||||
verify(mWindowMagnificationManager).removeMagnificationSettingsPanel(eq(TEST_DISPLAY));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1064,6 +1110,8 @@ public class MagnificationControllerTest {
|
||||
// The third time is triggered when the disable-magnification callback is triggered.
|
||||
verify(mWindowMagnificationManager, times(3)).showMagnificationButton(eq(TEST_DISPLAY),
|
||||
eq(MODE_FULLSCREEN));
|
||||
// It is triggered when the disable-magnification callback is triggered.
|
||||
verify(mWindowMagnificationManager).removeMagnificationSettingsPanel(eq(TEST_DISPLAY));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1083,6 +1131,8 @@ public class MagnificationControllerTest {
|
||||
// The second time is triggered when the disable-magnification callback is triggered.
|
||||
verify(mWindowMagnificationManager, times(2)).showMagnificationButton(eq(TEST_DISPLAY),
|
||||
eq(MODE_WINDOW));
|
||||
// It is triggered when the disable-magnification callback is triggered.
|
||||
verify(mWindowMagnificationManager).removeMagnificationSettingsPanel(eq(TEST_DISPLAY));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user