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:
@ -3573,6 +3573,17 @@
|
||||
visibility="public"
|
||||
>
|
||||
</field>
|
||||
<field name="finishOnCloseSystemDialogs"
|
||||
type="int"
|
||||
transient="false"
|
||||
volatile="false"
|
||||
value="16843431"
|
||||
static="true"
|
||||
final="true"
|
||||
deprecated="not deprecated"
|
||||
visibility="public"
|
||||
>
|
||||
</field>
|
||||
<field name="finishOnTaskLaunch"
|
||||
type="int"
|
||||
transient="false"
|
||||
@ -39185,6 +39196,17 @@
|
||||
visibility="public"
|
||||
>
|
||||
</field>
|
||||
<field name="FLAG_FINISH_ON_CLOSE_SYSTEM_DIALOGS"
|
||||
type="int"
|
||||
transient="false"
|
||||
volatile="false"
|
||||
value="256"
|
||||
static="true"
|
||||
final="true"
|
||||
deprecated="not deprecated"
|
||||
visibility="public"
|
||||
>
|
||||
</field>
|
||||
<field name="FLAG_FINISH_ON_TASK_LAUNCH"
|
||||
type="int"
|
||||
transient="false"
|
||||
@ -156755,6 +156777,19 @@
|
||||
visibility="public"
|
||||
>
|
||||
</method>
|
||||
<method name="onCloseSystemDialogs"
|
||||
return="void"
|
||||
abstract="false"
|
||||
native="false"
|
||||
synchronized="false"
|
||||
static="false"
|
||||
final="false"
|
||||
deprecated="not deprecated"
|
||||
visibility="public"
|
||||
>
|
||||
<parameter name="reason" type="java.lang.String">
|
||||
</parameter>
|
||||
</method>
|
||||
<method name="onCreateContextMenu"
|
||||
return="void"
|
||||
abstract="false"
|
||||
|
@ -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 {
|
||||
|
@ -1134,6 +1134,7 @@
|
||||
android:icon="@drawable/ic_launcher_android">
|
||||
<activity android:name="com.android.internal.app.ChooserActivity"
|
||||
android:theme="@style/Theme.Dialog.Alert"
|
||||
android:finishOnCloseSystemDialogs="true"
|
||||
android:excludeFromRecents="true"
|
||||
android:multiprocess="true">
|
||||
<intent-filter>
|
||||
|
@ -18,9 +18,14 @@
|
||||
-->
|
||||
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:interpolator="@anim/decelerate_interpolator">
|
||||
android:interpolator="@anim/decelerate_interpolator"
|
||||
android:zAdjustment="top">
|
||||
<!-- For now stay like the normal activity transition.
|
||||
<scale android:fromXScale="2.0" android:toXScale="1.0"
|
||||
android:fromYScale="2.0" android:toYScale="1.0"
|
||||
android:pivotX="50%p" android:pivotY="50%p"
|
||||
android:duration="@android:integer/config_mediumAnimTime" />
|
||||
android:pivotX="100%p" android:pivotY="50%p"
|
||||
android:duration="@android:integer/config_shortAnimTime" />
|
||||
-->
|
||||
<translate android:fromXDelta="-100%" android:toXDelta="0"
|
||||
android:duration="@android:integer/config_shortAnimTime"/>
|
||||
</set>
|
||||
|
@ -18,12 +18,7 @@
|
||||
-->
|
||||
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:interpolator="@anim/decelerate_interpolator"
|
||||
android:zAdjustment="top">
|
||||
<scale android:fromXScale="1.0" android:toXScale=".5"
|
||||
android:fromYScale="1.0" android:toYScale=".5"
|
||||
android:pivotX="50%p" android:pivotY="50%p"
|
||||
android:duration="@android:integer/config_mediumAnimTime" />
|
||||
<alpha android:fromAlpha="1.0" android:toAlpha="0"
|
||||
android:duration="@android:integer/config_mediumAnimTime"/>
|
||||
android:interpolator="@anim/decelerate_interpolator">
|
||||
<translate android:fromXDelta="0%" android:toXDelta="33%"
|
||||
android:duration="@android:integer/config_shortAnimTime"/>
|
||||
</set>
|
||||
|
@ -18,12 +18,7 @@
|
||||
-->
|
||||
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:interpolator="@anim/decelerate_interpolator"
|
||||
android:zAdjustment="top">
|
||||
<scale android:fromXScale=".5" android:toXScale="1.0"
|
||||
android:fromYScale=".5" android:toYScale="1.0"
|
||||
android:pivotX="50%p" android:pivotY="50%p"
|
||||
android:duration="@android:integer/config_mediumAnimTime" />
|
||||
<alpha android:fromAlpha="0.0" android:toAlpha="1.0"
|
||||
android:duration="@android:integer/config_mediumAnimTime"/>
|
||||
android:interpolator="@anim/decelerate_interpolator">
|
||||
<translate android:fromXDelta="33%" android:toXDelta="0"
|
||||
android:duration="@android:integer/config_shortAnimTime"/>
|
||||
</set>
|
||||
|
@ -18,9 +18,14 @@
|
||||
-->
|
||||
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:interpolator="@anim/decelerate_interpolator">
|
||||
android:interpolator="@anim/decelerate_interpolator"
|
||||
android:zAdjustment="top">
|
||||
<!-- For now stay like the normal activity transition.
|
||||
<scale android:fromXScale="1.0" android:toXScale="2.0"
|
||||
android:fromYScale="1.0" android:toYScale="2.0"
|
||||
android:pivotX="50%p" android:pivotY="50%p"
|
||||
android:duration="@android:integer/config_mediumAnimTime" />
|
||||
android:pivotX="100%p" android:pivotY="50%p"
|
||||
android:duration="@android:integer/config_shortAnimTime" />
|
||||
-->
|
||||
<translate android:fromXDelta="0%" android:toXDelta="-100%"
|
||||
android:duration="@android:integer/config_shortAnimTime"/>
|
||||
</set>
|
||||
|
@ -288,6 +288,12 @@
|
||||
ignored and the activity simply finished. -->
|
||||
<attr name="finishOnTaskLaunch" format="boolean" />
|
||||
|
||||
<!-- Specify whether an activity should be finished when a "close system
|
||||
windows" request has been made. This happens, for example, when
|
||||
the home key is pressed, when the device is locked, when a system
|
||||
dialog like recent apps is displayed, etc. -->
|
||||
<attr name="finishOnCloseSystemDialogs" format="boolean" />
|
||||
|
||||
<!-- Specify whether an activity's task should be cleared when it
|
||||
is re-launched from the home screen. As a result, every time the
|
||||
user starts the task, they will be brought to its root activity,
|
||||
@ -1078,6 +1084,7 @@
|
||||
<attr name="taskAffinity" />
|
||||
<attr name="allowTaskReparenting" />
|
||||
<attr name="finishOnTaskLaunch" />
|
||||
<attr name="finishOnCloseSystemDialogs" />
|
||||
<attr name="clearTaskOnLaunch" />
|
||||
<attr name="noHistory" />
|
||||
<attr name="alwaysRetainTaskState" />
|
||||
|
@ -30,7 +30,7 @@
|
||||
<integer name="config_shortAnimTime">150</integer>
|
||||
|
||||
<!-- The duration (in milliseconds) of a medium-length animation. -->
|
||||
<integer name="config_mediumAnimTime">250</integer>
|
||||
<integer name="config_mediumAnimTime">200</integer>
|
||||
|
||||
<!-- The duration (in milliseconds) of a long animation. -->
|
||||
<integer name="config_longAnimTime">400</integer>
|
||||
|
@ -1171,6 +1171,7 @@
|
||||
<public type="attr" name="detailSocialSummary" />
|
||||
<public type="attr" name="thumbnail" />
|
||||
<public type="attr" name="detachWallpaper" />
|
||||
<public type="attr" name="finishOnCloseSystemDialogs" />
|
||||
|
||||
<public type="style" name="Theme.Wallpaper" />
|
||||
<public type="style" name="Theme.Wallpaper.NoTitleBar" />
|
||||
|
@ -58,19 +58,6 @@
|
||||
<item name="activityOpenExitAnimation">@anim/activity_open_exit</item>
|
||||
<item name="activityCloseEnterAnimation">@anim/activity_close_enter</item>
|
||||
<item name="activityCloseExitAnimation">@anim/activity_close_exit</item>
|
||||
<item name="taskOpenEnterAnimation">@anim/activity_open_enter</item>
|
||||
<item name="taskOpenExitAnimation">@anim/activity_open_exit</item>
|
||||
<item name="taskCloseEnterAnimation">@anim/activity_close_enter</item>
|
||||
<item name="taskCloseExitAnimation">@anim/activity_close_exit</item>
|
||||
<item name="taskToFrontEnterAnimation">@anim/activity_open_enter</item>
|
||||
<item name="taskToFrontExitAnimation">@anim/activity_open_exit</item>
|
||||
<item name="taskToBackEnterAnimation">@anim/activity_close_enter</item>
|
||||
<item name="taskToBackExitAnimation">@anim/activity_close_exit</item>
|
||||
<!-- There is a good argument to be made that the user shouldn't
|
||||
be aware of task transitions, so we are going to use the same
|
||||
animation for them as we do for regular activity transitions. -->
|
||||
<!-- These provide an alternative animation for task transitions. -->
|
||||
<!--
|
||||
<item name="taskOpenEnterAnimation">@anim/task_open_enter</item>
|
||||
<item name="taskOpenExitAnimation">@anim/task_open_exit</item>
|
||||
<item name="taskCloseEnterAnimation">@anim/task_close_enter</item>
|
||||
@ -79,7 +66,6 @@
|
||||
<item name="taskToFrontExitAnimation">@anim/task_open_exit</item>
|
||||
<item name="taskToBackEnterAnimation">@anim/task_close_enter</item>
|
||||
<item name="taskToBackExitAnimation">@anim/task_close_exit</item>
|
||||
-->
|
||||
<item name="wallpaperOpenEnterAnimation">@anim/wallpaper_open_enter</item>
|
||||
<item name="wallpaperOpenExitAnimation">@anim/wallpaper_open_exit</item>
|
||||
<item name="wallpaperCloseEnterAnimation">@anim/wallpaper_close_enter</item>
|
||||
|
@ -3913,6 +3913,20 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
return mPolicy.inKeyguardRestrictedKeyInputMode();
|
||||
}
|
||||
|
||||
public void closeSystemDialogs(String reason) {
|
||||
synchronized(mWindowMap) {
|
||||
for (int i=mWindows.size()-1; i>=0; i--) {
|
||||
WindowState w = (WindowState)mWindows.get(i);
|
||||
if (w.mSurface != null) {
|
||||
try {
|
||||
w.mClient.closeSystemDialogs(reason);
|
||||
} catch (RemoteException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static float fixScale(float scale) {
|
||||
if (scale < 0) scale = 0;
|
||||
else if (scale > 20) scale = 20;
|
||||
|
@ -4957,6 +4957,16 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
|
||||
}
|
||||
mWatchers.finishBroadcast();
|
||||
|
||||
mWindowManager.closeSystemDialogs(reason);
|
||||
|
||||
for (i=mHistory.size()-1; i>=0; i--) {
|
||||
HistoryRecord r = (HistoryRecord)mHistory.get(i);
|
||||
if ((r.info.flags&ActivityInfo.FLAG_FINISH_ON_CLOSE_SYSTEM_DIALOGS) != 0) {
|
||||
finishActivityLocked(r, i,
|
||||
Activity.RESULT_CANCELED, null, "close-sys");
|
||||
}
|
||||
}
|
||||
|
||||
broadcastIntentLocked(null, null, intent, null,
|
||||
null, 0, null, null, null, false, false, -1, uid);
|
||||
}
|
||||
|
@ -1067,7 +1067,12 @@ public final class Bridge implements ILayoutBridge {
|
||||
public void wallpaperOffsetsComplete(IBinder window) {
|
||||
// pass for now.
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public void closeSystemDialogs(String reason) {
|
||||
// pass for now.
|
||||
}
|
||||
|
||||
public IBinder asBinder() {
|
||||
// pass for now.
|
||||
return null;
|
||||
@ -1126,6 +1131,11 @@ public final class Bridge implements ILayoutBridge {
|
||||
// pass for now.
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public void closeSystemDialogs(String reason) {
|
||||
// pass for now.
|
||||
}
|
||||
|
||||
public IBinder asBinder() {
|
||||
// pass for now.
|
||||
return null;
|
||||
|
Reference in New Issue
Block a user