Fix issue #2133206: dialogs/menus should auto-dismiss when screen turns off
Lot of infrastructure for more things to go away when "clear system dialogs" happens, and now do this when we turn on the lock screen. Change-Id: I567130296fe47ce82df065ed58ef21b37416ceaf
This commit is contained in:
@@ -126,13 +126,21 @@ public class ActivityInfo extends ComponentInfo
|
||||
* {@link android.R.attr#noHistory} attribute.
|
||||
*/
|
||||
public static final int FLAG_NO_HISTORY = 0x0080;
|
||||
/**
|
||||
* Bit in {@link #flags} indicating that, when a request to close system
|
||||
* windows happens, this activity is finished.
|
||||
* Set from the
|
||||
* {@link android.R.attr#finishOnCloseSystemDialogs} attribute.
|
||||
*/
|
||||
public static final int FLAG_FINISH_ON_CLOSE_SYSTEM_DIALOGS = 0x0100;
|
||||
/**
|
||||
* Options that have been set in the activity declaration in the
|
||||
* manifest: {@link #FLAG_MULTIPROCESS},
|
||||
* {@link #FLAG_FINISH_ON_TASK_LAUNCH}, {@link #FLAG_CLEAR_TASK_ON_LAUNCH},
|
||||
* {@link #FLAG_ALWAYS_RETAIN_TASK_STATE},
|
||||
* {@link #FLAG_STATE_NOT_NEEDED}, {@link #FLAG_EXCLUDE_FROM_RECENTS},
|
||||
* {@link #FLAG_ALLOW_TASK_REPARENTING}, {@link #FLAG_NO_HISTORY}.
|
||||
* {@link #FLAG_ALLOW_TASK_REPARENTING}, {@link #FLAG_NO_HISTORY},
|
||||
* {@link #FLAG_FINISH_ON_CLOSE_SYSTEM_DIALOGS}.
|
||||
*/
|
||||
public int flags;
|
||||
|
||||
|
||||
@@ -1658,6 +1658,12 @@ public class PackageParser {
|
||||
a.info.flags |= ActivityInfo.FLAG_ALLOW_TASK_REPARENTING;
|
||||
}
|
||||
|
||||
if (sa.getBoolean(
|
||||
com.android.internal.R.styleable.AndroidManifestActivity_finishOnCloseSystemDialogs,
|
||||
false)) {
|
||||
a.info.flags |= ActivityInfo.FLAG_FINISH_ON_CLOSE_SYSTEM_DIALOGS;
|
||||
}
|
||||
|
||||
if (!receiver) {
|
||||
a.info.launchMode = sa.getInt(
|
||||
com.android.internal.R.styleable.AndroidManifestActivity_launchMode,
|
||||
|
||||
@@ -57,6 +57,8 @@ oneway interface IWindow {
|
||||
*/
|
||||
void windowFocusChanged(boolean hasFocus, boolean inTouchMode);
|
||||
|
||||
void closeSystemDialogs(String reason);
|
||||
|
||||
/**
|
||||
* Called for wallpaper windows when their offsets change.
|
||||
*/
|
||||
|
||||
@@ -90,6 +90,8 @@ interface IWindowManager
|
||||
void exitKeyguardSecurely(IOnKeyguardExitResult callback);
|
||||
boolean inKeyguardRestrictedInputMode();
|
||||
|
||||
void closeSystemDialogs(String reason);
|
||||
|
||||
// These can only be called with the SET_ANIMATON_SCALE permission.
|
||||
float getAnimationScale(int which);
|
||||
float[] getAnimationScales();
|
||||
|
||||
@@ -8098,6 +8098,13 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
|
||||
(flags&HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING) != 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* This needs to be a better API (NOT ON VIEW) before it is exposed. If
|
||||
* it is ever exposed at all.
|
||||
*/
|
||||
public void onCloseSystemDialogs(String reason) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a Drawable whose bounds have been set to draw into this view,
|
||||
* update a Region being computed for {@link #gatherTransparentRegion} so
|
||||
|
||||
@@ -1610,6 +1610,7 @@ public final class ViewRoot extends Handler implements ViewParent,
|
||||
public final static int DISPATCH_KEY_FROM_IME = 1011;
|
||||
public final static int FINISH_INPUT_CONNECTION = 1012;
|
||||
public final static int CHECK_FOCUS = 1013;
|
||||
public final static int CLOSE_SYSTEM_DIALOGS = 1014;
|
||||
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
@@ -1867,6 +1868,11 @@ public final class ViewRoot extends Handler implements ViewParent,
|
||||
imm.checkFocus();
|
||||
}
|
||||
} break;
|
||||
case CLOSE_SYSTEM_DIALOGS: {
|
||||
if (mView != null) {
|
||||
mView.onCloseSystemDialogs((String)msg.obj);
|
||||
}
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2630,6 +2636,13 @@ public final class ViewRoot extends Handler implements ViewParent,
|
||||
sendMessage(msg);
|
||||
}
|
||||
|
||||
public void dispatchCloseSystemDialogs(String reason) {
|
||||
Message msg = Message.obtain();
|
||||
msg.what = CLOSE_SYSTEM_DIALOGS;
|
||||
msg.obj = reason;
|
||||
sendMessage(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* The window is getting focus so if there is anything focused/selected
|
||||
* send an {@link AccessibilityEvent} to announce that.
|
||||
@@ -2869,6 +2882,13 @@ public final class ViewRoot extends Handler implements ViewParent,
|
||||
}
|
||||
}
|
||||
|
||||
public void closeSystemDialogs(String reason) {
|
||||
final ViewRoot viewRoot = mViewRoot.get();
|
||||
if (viewRoot != null) {
|
||||
viewRoot.dispatchCloseSystemDialogs(reason);
|
||||
}
|
||||
}
|
||||
|
||||
public void dispatchWallpaperOffsets(float x, float y, boolean sync) {
|
||||
if (sync) {
|
||||
try {
|
||||
|
||||
@@ -90,6 +90,9 @@ public class BaseIWindow extends IWindow.Stub {
|
||||
public void executeCommand(String command, String parameters, ParcelFileDescriptor out) {
|
||||
}
|
||||
|
||||
public void closeSystemDialogs(String reason) {
|
||||
}
|
||||
|
||||
public void dispatchWallpaperOffsets(float x, float y, boolean sync) {
|
||||
if (sync) {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user