Merge "Add rear display dialog methods to CommandQueue and StatusBarService" into tm-qpr-dev
This commit is contained in:
@@ -325,4 +325,7 @@ oneway interface IStatusBar
|
||||
|
||||
/** Dump protos from SystemUI. The proto definition is defined there */
|
||||
void dumpProto(in String[] args, in ParcelFileDescriptor pfd);
|
||||
|
||||
/** Shows rear display educational dialog */
|
||||
void showRearDisplayDialog(int currentBaseState);
|
||||
}
|
||||
|
||||
@@ -226,4 +226,7 @@ interface IStatusBarService
|
||||
|
||||
/** Unregisters a nearby media devices provider. */
|
||||
void unregisterNearbyMediaDevicesProvider(in INearbyMediaDevicesProvider provider);
|
||||
|
||||
/** Shows rear display educational dialog */
|
||||
void showRearDisplayDialog(int currentBaseState);
|
||||
}
|
||||
|
||||
@@ -165,6 +165,7 @@ public class CommandQueue extends IStatusBar.Stub implements
|
||||
private static final int MSG_REGISTER_NEARBY_MEDIA_DEVICE_PROVIDER = 66 << MSG_SHIFT;
|
||||
private static final int MSG_UNREGISTER_NEARBY_MEDIA_DEVICE_PROVIDER = 67 << MSG_SHIFT;
|
||||
private static final int MSG_TILE_SERVICE_REQUEST_LISTENING_STATE = 68 << MSG_SHIFT;
|
||||
private static final int MSG_SHOW_REAR_DISPLAY_DIALOG = 69 << MSG_SHIFT;
|
||||
|
||||
public static final int FLAG_EXCLUDE_NONE = 0;
|
||||
public static final int FLAG_EXCLUDE_SEARCH_PANEL = 1 << 0;
|
||||
@@ -474,6 +475,11 @@ public class CommandQueue extends IStatusBar.Stub implements
|
||||
*/
|
||||
default void unregisterNearbyMediaDevicesProvider(
|
||||
@NonNull INearbyMediaDevicesProvider provider) {}
|
||||
|
||||
/**
|
||||
* @see IStatusBar#showRearDisplayDialog
|
||||
*/
|
||||
default void showRearDisplayDialog(int currentBaseState) {}
|
||||
}
|
||||
|
||||
public CommandQueue(Context context) {
|
||||
@@ -1228,6 +1234,13 @@ public class CommandQueue extends IStatusBar.Stub implements
|
||||
.sendToTarget();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showRearDisplayDialog(int currentBaseState) {
|
||||
synchronized (mLock) {
|
||||
mHandler.obtainMessage(MSG_SHOW_REAR_DISPLAY_DIALOG, currentBaseState).sendToTarget();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestAddTile(
|
||||
@NonNull ComponentName componentName,
|
||||
@@ -1724,6 +1737,10 @@ public class CommandQueue extends IStatusBar.Stub implements
|
||||
mCallbacks.get(i).requestTileServiceListeningState(component);
|
||||
}
|
||||
break;
|
||||
case MSG_SHOW_REAR_DISPLAY_DIALOG:
|
||||
for (int i = 0; i < mCallbacks.size(); i++) {
|
||||
mCallbacks.get(i).showRearDisplayDialog((Integer) msg.obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -519,4 +519,12 @@ public class CommandQueueTest extends SysuiTestCase {
|
||||
waitForIdleSync();
|
||||
verify(mCallbacks).setNavigationBarLumaSamplingEnabled(eq(1), eq(true));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testShowRearDisplayDialog() {
|
||||
final int currentBaseState = 1;
|
||||
mCommandQueue.showRearDisplayDialog(currentBaseState);
|
||||
waitForIdleSync();
|
||||
verify(mCallbacks).showRearDisplayDialog(eq(currentBaseState));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,10 +17,7 @@
|
||||
package com.android.server.devicestate;
|
||||
|
||||
import static android.Manifest.permission.CONTROL_DEVICE_STATE;
|
||||
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
|
||||
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
|
||||
import static android.hardware.devicestate.DeviceStateManager.ACTION_SHOW_REAR_DISPLAY_OVERLAY;
|
||||
import static android.hardware.devicestate.DeviceStateManager.EXTRA_ORIGINAL_DEVICE_BASE_STATE;
|
||||
import static android.hardware.devicestate.DeviceStateManager.INVALID_DEVICE_STATE;
|
||||
import static android.hardware.devicestate.DeviceStateManager.MAXIMUM_DEVICE_STATE;
|
||||
import static android.hardware.devicestate.DeviceStateManager.MINIMUM_DEVICE_STATE;
|
||||
@@ -36,10 +33,7 @@ import android.annotation.IntDef;
|
||||
import android.annotation.IntRange;
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.app.ActivityOptions;
|
||||
import android.app.WindowConfiguration;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.hardware.devicestate.DeviceStateInfo;
|
||||
import android.hardware.devicestate.DeviceStateManager;
|
||||
import android.hardware.devicestate.DeviceStateManagerInternal;
|
||||
@@ -64,6 +58,7 @@ import com.android.internal.util.FrameworkStatsLog;
|
||||
import com.android.server.DisplayThread;
|
||||
import com.android.server.LocalServices;
|
||||
import com.android.server.SystemService;
|
||||
import com.android.server.statusbar.StatusBarManagerInternal;
|
||||
import com.android.server.wm.ActivityTaskManagerInternal;
|
||||
import com.android.server.wm.WindowProcessController;
|
||||
|
||||
@@ -731,19 +726,18 @@ public final class DeviceStateManagerService extends SystemService {
|
||||
|
||||
/**
|
||||
* If we get a request to enter rear display mode, we need to display an educational
|
||||
* overlay to let the user know what will happen. This creates the pending request and then
|
||||
* launches the {@link RearDisplayEducationActivity}
|
||||
* overlay to let the user know what will happen. This calls into the
|
||||
* {@link StatusBarManagerInternal} to notify SystemUI to display the educational dialog.
|
||||
*/
|
||||
@GuardedBy("mLock")
|
||||
private void showRearDisplayEducationalOverlayLocked(OverrideRequest request) {
|
||||
mRearDisplayPendingOverrideRequest = request;
|
||||
|
||||
Intent intent = new Intent(ACTION_SHOW_REAR_DISPLAY_OVERLAY);
|
||||
intent.setFlags(FLAG_ACTIVITY_NEW_TASK);
|
||||
intent.putExtra(EXTRA_ORIGINAL_DEVICE_BASE_STATE, mBaseState.get().getIdentifier());
|
||||
final ActivityOptions options = ActivityOptions.makeBasic();
|
||||
options.setLaunchWindowingMode(WindowConfiguration.WINDOWING_MODE_FULLSCREEN);
|
||||
getUiContext().startActivity(intent, options.toBundle());
|
||||
StatusBarManagerInternal statusBar =
|
||||
LocalServices.getService(StatusBarManagerInternal.class);
|
||||
if (statusBar != null) {
|
||||
statusBar.showRearDisplayDialog(mBaseState.get().getIdentifier());
|
||||
}
|
||||
}
|
||||
|
||||
private void cancelStateRequestInternal(int callingPid) {
|
||||
|
||||
@@ -172,4 +172,11 @@ public interface StatusBarManagerInternal {
|
||||
* @see com.android.internal.statusbar.IStatusBar#setUdfpsHbmListener(IUdfpsHbmListener)
|
||||
*/
|
||||
void setUdfpsHbmListener(IUdfpsHbmListener listener);
|
||||
|
||||
/**
|
||||
* Shows the rear display educational dialog
|
||||
*
|
||||
* @see com.android.internal.statusbar.IStatusBar#showRearDisplayDialog
|
||||
*/
|
||||
void showRearDisplayDialog(int currentBaseState);
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.server.statusbar;
|
||||
|
||||
import static android.Manifest.permission.CONTROL_DEVICE_STATE;
|
||||
import static android.Manifest.permission.INTERACT_ACROSS_USERS;
|
||||
import static android.Manifest.permission.INTERACT_ACROSS_USERS_FULL;
|
||||
import static android.app.StatusBarManager.DISABLE2_GLOBAL_ACTIONS;
|
||||
@@ -31,6 +32,7 @@ import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON_OVE
|
||||
import android.Manifest;
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.annotation.RequiresPermission;
|
||||
import android.app.ActivityManager;
|
||||
import android.app.ActivityManagerInternal;
|
||||
import android.app.ActivityThread;
|
||||
@@ -685,6 +687,15 @@ public class StatusBarManagerService extends IStatusBarService.Stub implements D
|
||||
} catch (RemoteException ex) { }
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showRearDisplayDialog(int currentBaseState) {
|
||||
if (mBar != null) {
|
||||
try {
|
||||
mBar.showRearDisplayDialog(currentBaseState);
|
||||
} catch (RemoteException ex) { }
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private final GlobalActionsProvider mGlobalActionsProvider = new GlobalActionsProvider() {
|
||||
@@ -1288,6 +1299,11 @@ public class StatusBarManagerService extends IStatusBarService.Stub implements D
|
||||
"StatusBarManagerService");
|
||||
}
|
||||
|
||||
@RequiresPermission(android.Manifest.permission.CONTROL_DEVICE_STATE)
|
||||
private void enforceControlDeviceStatePermission() {
|
||||
mContext.enforceCallingOrSelfPermission(CONTROL_DEVICE_STATE, "StatusBarManagerService");
|
||||
}
|
||||
|
||||
private boolean doesCallerHoldInteractAcrossUserPermission() {
|
||||
return mContext.checkCallingPermission(INTERACT_ACROSS_USERS_FULL) == PERMISSION_GRANTED
|
||||
|| mContext.checkCallingPermission(INTERACT_ACROSS_USERS) == PERMISSION_GRANTED;
|
||||
@@ -2171,6 +2187,19 @@ public class StatusBarManagerService extends IStatusBarService.Stub implements D
|
||||
}
|
||||
}
|
||||
|
||||
@RequiresPermission(android.Manifest.permission.CONTROL_DEVICE_STATE)
|
||||
@Override
|
||||
public void showRearDisplayDialog(int currentState) {
|
||||
enforceControlDeviceStatePermission();
|
||||
if (mBar != null) {
|
||||
try {
|
||||
mBar.showRearDisplayDialog(currentState);
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "showRearDisplayDialog", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
public void passThroughShellCommand(String[] args, FileDescriptor fd) {
|
||||
enforceStatusBarOrShell();
|
||||
|
||||
Reference in New Issue
Block a user