Skip to content

Commit 4b21278

Browse files
Christopher TateAndroid Git Automerger
authored andcommitted
am 96fecb7: Merge "Make immersive mode public & imply update locking" into ics-aah
* commit '96fecb7f6b74176c0fad7bfa2c7ae9b80e1770cc': Make immersive mode public & imply update locking
2 parents b7536cf + 96fecb7 commit 4b21278

File tree

4 files changed

+40
-4
lines changed

4 files changed

+40
-4
lines changed

api/current.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2557,6 +2557,7 @@ package android.app {
25572557
method public boolean isChangingConfigurations();
25582558
method public final boolean isChild();
25592559
method public boolean isFinishing();
2560+
method public boolean isImmersive();
25602561
method public boolean isTaskRoot();
25612562
method public final deprecated android.database.Cursor managedQuery(android.net.Uri, java.lang.String[], java.lang.String, java.lang.String[], java.lang.String);
25622563
method public boolean moveTaskToBack(boolean);
@@ -2638,6 +2639,7 @@ package android.app {
26382639
method public final void setFeatureDrawableResource(int, int);
26392640
method public final void setFeatureDrawableUri(int, android.net.Uri);
26402641
method public void setFinishOnTouchOutside(boolean);
2642+
method public void setImmersive(boolean);
26412643
method public void setIntent(android.content.Intent);
26422644
method public final void setProgress(int);
26432645
method public final void setProgressBarIndeterminate(boolean);
@@ -5952,6 +5954,7 @@ package android.content.pm {
59525954
field public static final int FLAG_FINISH_ON_CLOSE_SYSTEM_DIALOGS = 256; // 0x100
59535955
field public static final int FLAG_FINISH_ON_TASK_LAUNCH = 2; // 0x2
59545956
field public static final int FLAG_HARDWARE_ACCELERATED = 512; // 0x200
5957+
field public static final int FLAG_IMMERSIVE = 1024; // 0x400
59555958
field public static final int FLAG_MULTIPROCESS = 1; // 0x1
59565959
field public static final int FLAG_NO_HISTORY = 128; // 0x80
59575960
field public static final int FLAG_STATE_NOT_NEEDED = 16; // 0x10

core/java/android/app/Activity.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4318,7 +4318,6 @@ public void dump(String prefix, FileDescriptor fd, PrintWriter writer, String[]
43184318
* {@link #setImmersive}.
43194319
*
43204320
* @see android.content.pm.ActivityInfo#FLAG_IMMERSIVE
4321-
* @hide
43224321
*/
43234322
public boolean isImmersive() {
43244323
try {
@@ -4341,7 +4340,6 @@ public boolean isImmersive() {
43414340
*
43424341
* @see #isImmersive
43434342
* @see android.content.pm.ActivityInfo#FLAG_IMMERSIVE
4344-
* @hide
43454343
*/
43464344
public void setImmersive(boolean i) {
43474345
try {

core/java/android/content/pm/ActivityInfo.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ public class ActivityInfo extends ComponentInfo
155155
*/
156156
public static final int FLAG_HARDWARE_ACCELERATED = 0x0200;
157157
/**
158-
* @hide
159158
* Bit in {@link #flags} corresponding to an immersive activity
160159
* that wishes not to be interrupted by notifications.
161160
* Applications that hide the system notification bar with

services/java/com/android/server/am/ActivityManagerService.java

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104
import android.os.StrictMode;
105105
import android.os.SystemClock;
106106
import android.os.SystemProperties;
107+
import android.os.UpdateLock;
107108
import android.provider.Settings;
108109
import android.text.format.Time;
109110
import android.util.EventLog;
@@ -172,6 +173,7 @@ public final class ActivityManagerService extends ActivityManagerNative
172173
static final boolean DEBUG_CONFIGURATION = localLOGV || false;
173174
static final boolean DEBUG_POWER = localLOGV || false;
174175
static final boolean DEBUG_POWER_QUICK = DEBUG_POWER || false;
176+
static final boolean DEBUG_IMMERSIVE = localLOGV || true;
175177
static final boolean VALIDATE_TOKENS = false;
176178
static final boolean SHOW_ACTIVITY_START_TIME = true;
177179

@@ -811,6 +813,12 @@ private class Identity {
811813

812814
long mLastWriteTime = 0;
813815

816+
/**
817+
* Used to retain an update lock when the foreground activity is in
818+
* immersive mode.
819+
*/
820+
final UpdateLock mUpdateLock = new UpdateLock("immersive");
821+
814822
/**
815823
* Set to true after the system has finished booting.
816824
*/
@@ -1710,6 +1718,21 @@ final void setFocusedActivityLocked(ActivityRecord r) {
17101718
if (r != null) {
17111719
mWindowManager.setFocusedApp(r.appToken, true);
17121720
}
1721+
applyUpdateLockStateLocked(r);
1722+
}
1723+
}
1724+
1725+
final void applyUpdateLockStateLocked(ActivityRecord r) {
1726+
final boolean nextState = r != null && r.immersive;
1727+
if (mUpdateLock.isHeld() != nextState) {
1728+
if (DEBUG_IMMERSIVE) {
1729+
Slog.d(TAG, "Applying new update lock state '" + nextState + "' for " + r);
1730+
}
1731+
if (nextState) {
1732+
mUpdateLock.acquire();
1733+
} else {
1734+
mUpdateLock.release();
1735+
}
17131736
}
17141737
}
17151738

@@ -6667,11 +6690,24 @@ public void unregisterProcessObserver(IProcessObserver observer) {
66676690

66686691
public void setImmersive(IBinder token, boolean immersive) {
66696692
synchronized(this) {
6670-
ActivityRecord r = mMainStack.isInStackLocked(token);
6693+
final ActivityRecord r = mMainStack.isInStackLocked(token);
66716694
if (r == null) {
66726695
throw new IllegalArgumentException();
66736696
}
66746697
r.immersive = immersive;
6698+
6699+
// update associated state if we're frontmost
6700+
if (r == mMainStack.topRunningActivityLocked(null)) {
6701+
long oldId = Binder.clearCallingIdentity();
6702+
try {
6703+
if (DEBUG_IMMERSIVE) {
6704+
Slog.d(TAG, "Frontmost changed immersion: "+ r);
6705+
}
6706+
applyUpdateLockStateLocked(r);
6707+
} finally {
6708+
Binder.restoreCallingIdentity(oldId);
6709+
}
6710+
}
66756711
}
66766712
}
66776713

0 commit comments

Comments
 (0)