Merge "Add route for rotation suggestions from StatusBar to CommandQueue"

This commit is contained in:
Mike Digman
2017-11-29 18:10:06 +00:00
committed by Android (Google) Code Review
4 changed files with 38 additions and 0 deletions

View File

@@ -112,6 +112,11 @@ oneway interface IStatusBar
*/
void showGlobalActionsMenu();
/**
* Notifies the status bar that a new rotation suggestion is available.
*/
void onProposedRotationChanged(int rotation);
/**
* Set whether the top app currently hides the statusbar.
*

View File

@@ -82,6 +82,7 @@ public class CommandQueue extends IStatusBar.Stub {
private static final int MSG_TOGGLE_PANEL = 35 << MSG_SHIFT;
private static final int MSG_SHOW_SHUTDOWN_UI = 36 << MSG_SHIFT;
private static final int MSG_SET_TOP_APP_HIDES_STATUS_BAR = 37 << MSG_SHIFT;
private static final int MSG_ROTATION_PROPOSAL = 38 << MSG_SHIFT;
public static final int FLAG_EXCLUDE_NONE = 0;
public static final int FLAG_EXCLUDE_SEARCH_PANEL = 1 << 0;
@@ -142,6 +143,8 @@ public class CommandQueue extends IStatusBar.Stub {
default void handleSystemKey(int arg1) { }
default void handleShowGlobalActionsMenu() { }
default void handleShowShutdownUi(boolean isReboot, String reason) { }
default void onRotationProposal(int rotation) { }
}
@VisibleForTesting
@@ -458,6 +461,15 @@ public class CommandQueue extends IStatusBar.Stub {
}
}
@Override
public void onProposedRotationChanged(int rotation) {
synchronized (mLock) {
mHandler.removeMessages(MSG_ROTATION_PROPOSAL);
mHandler.obtainMessage(MSG_ROTATION_PROPOSAL, rotation, 0,
null).sendToTarget();
}
}
private final class H extends Handler {
private H(Looper l) {
super(l);
@@ -654,6 +666,11 @@ public class CommandQueue extends IStatusBar.Stub {
mCallbacks.get(i).setTopAppHidesStatusBar(msg.arg1 != 0);
}
break;
case MSG_ROTATION_PROPOSAL:
for (int i = 0; i < mCallbacks.size(); i++) {
mCallbacks.get(i).onRotationProposal(msg.arg1);
}
break;
}
}
}

View File

@@ -90,6 +90,13 @@ public interface StatusBarManagerInternal {
boolean showShutdownUi(boolean isReboot, String requestString);
/**
* Show a rotation suggestion that a user may approve to rotate the screen.
*
* @param rotation rotation suggestion
*/
void onProposedRotationChanged(int rotation);
public interface GlobalActionsListener {
/**
* Called when sysui starts and connects its status bar, or when the status bar binder

View File

@@ -406,6 +406,15 @@ public class StatusBarManagerService extends IStatusBarService.Stub {
}
return false;
}
@Override
public void onProposedRotationChanged(int rotation) {
if (mBar != null){
try {
mBar.onProposedRotationChanged(rotation);
} catch (RemoteException ex) {}
}
}
};
// ================================================================================