Skip to content

Commit 79f5777

Browse files
Dianne HackbornAndroid (Google) Code Review
authored andcommitted
Merge "A few odds and ends." into jb-dev
2 parents 1d36627 + e302a16 commit 79f5777

File tree

6 files changed

+83
-32
lines changed

6 files changed

+83
-32
lines changed

api/16.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,7 @@ package android {
485485
field public static final int focusable = 16842970; // 0x10100da
486486
field public static final int focusableInTouchMode = 16842971; // 0x10100db
487487
field public static final int focusedMonthDateColor = 16843587; // 0x1010343
488+
field public static final int fontFamily = 16843692; // 0x10103ac
488489
field public static final int footerDividersEnabled = 16843311; // 0x101022f
489490
field public static final int foreground = 16843017; // 0x1010109
490491
field public static final int foregroundGravity = 16843264; // 0x1010200
@@ -5822,6 +5823,7 @@ package android.content {
58225823
field public static final int FLAG_ACTIVITY_CLEAR_TASK = 32768; // 0x8000
58235824
field public static final int FLAG_ACTIVITY_CLEAR_TOP = 67108864; // 0x4000000
58245825
field public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 524288; // 0x80000
5826+
field public static final int FLAG_ACTIVITY_CLOSE_SYSTEM_DIALOGS = 8192; // 0x2000
58255827
field public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 8388608; // 0x800000
58265828
field public static final int FLAG_ACTIVITY_FORWARD_RESULT = 33554432; // 0x2000000
58275829
field public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 1048576; // 0x100000

api/current.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5823,6 +5823,7 @@ package android.content {
58235823
field public static final int FLAG_ACTIVITY_CLEAR_TASK = 32768; // 0x8000
58245824
field public static final int FLAG_ACTIVITY_CLEAR_TOP = 67108864; // 0x4000000
58255825
field public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 524288; // 0x80000
5826+
field public static final int FLAG_ACTIVITY_CLOSE_SYSTEM_DIALOGS = 8192; // 0x2000
58265827
field public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 8388608; // 0x800000
58275828
field public static final int FLAG_ACTIVITY_FORWARD_RESULT = 33554432; // 0x2000000
58285829
field public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 1048576; // 0x100000

core/java/android/content/Intent.java

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -808,13 +808,16 @@ public String toString() {
808808
* always present to the user a list of the things they can do, with a
809809
* nice title given by the caller such as "Send this photo with:".
810810
* <p>
811+
* If you need to grant URI permissions through a chooser, you must specify
812+
* the permissions to be granted on the ACTION_CHOOSER Intent
813+
* <em>in addition</em> to the EXTRA_INTENT inside. This means using
814+
* {@link #setClipData} to specify the URIs to be granted as well as
815+
* {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
816+
* {@link #FLAG_GRANT_WRITE_URI_PERMISSION} as appropriate.
817+
* <p>
811818
* As a convenience, an Intent of this form can be created with the
812819
* {@link #createChooser} function.
813820
* <p>
814-
* If the target {@link #EXTRA_INTENT} contains {@link ClipData}, you should
815-
* also copy it to this intent along with relevant flags, such as
816-
* {@link #FLAG_GRANT_READ_URI_PERMISSION}.
817-
* <p>
818821
* Input: No data should be specified. get*Extra must have
819822
* a {@link #EXTRA_INTENT} field containing the Intent being executed,
820823
* and can optionally have a {@link #EXTRA_TITLE} field containing the
@@ -828,6 +831,14 @@ public String toString() {
828831
/**
829832
* Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
830833
*
834+
* <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
835+
* target intent, also optionally supplying a title. If the target
836+
* intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
837+
* {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
838+
* set in the returned chooser intent, with its ClipData set appropriately:
839+
* either a direct reflection of {@link #getClipData()} if that is non-null,
840+
* or a new ClipData build from {@link #getData()}.
841+
*
831842
* @param target The Intent that the user will be selecting an activity
832843
* to perform.
833844
* @param title Optional title that will be displayed in the chooser.
@@ -843,12 +854,26 @@ public static Intent createChooser(Intent target, CharSequence title) {
843854
}
844855

845856
// Migrate any clip data and flags from target.
846-
final ClipData targetClipData = target.getClipData();
847-
if (targetClipData != null) {
848-
intent.setClipData(targetClipData);
849-
intent.addFlags(target.getFlags()
850-
& (FLAG_GRANT_READ_URI_PERMISSION | FLAG_GRANT_WRITE_URI_PERMISSION));
857+
int permFlags = target.getFlags()
858+
& (FLAG_GRANT_READ_URI_PERMISSION | FLAG_GRANT_WRITE_URI_PERMISSION);
859+
if (permFlags != 0) {
860+
ClipData targetClipData = target.getClipData();
861+
if (targetClipData == null && target.getData() != null) {
862+
ClipData.Item item = new ClipData.Item(target.getData());
863+
String[] mimeTypes;
864+
if (target.getType() != null) {
865+
mimeTypes = new String[] { target.getType() };
866+
} else {
867+
mimeTypes = new String[] { };
868+
}
869+
targetClipData = new ClipData(null, mimeTypes, item);
870+
}
871+
if (targetClipData != null) {
872+
intent.setClipData(targetClipData);
873+
intent.addFlags(permFlags);
874+
}
851875
}
876+
852877
return intent;
853878
}
854879

@@ -3077,6 +3102,17 @@ public static Intent createChooser(Intent target, CharSequence title) {
30773102
* saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
30783103
*/
30793104
public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
3105+
/**
3106+
* If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
3107+
* upon starting the activity the system will also clear any system dialogs that
3108+
* are currently shown. This is intended primarily for any actions that are
3109+
* associated with buttons in a notification: tapping on the button to launch
3110+
* the activity needs to also dismiss the notification window (which is one
3111+
* of the system dialogs); setting this flag on the Intent associated with that
3112+
* action will ensure that and other system dialogs are dismissed so that the
3113+
* user arrives in the new activity.
3114+
*/
3115+
public static final int FLAG_ACTIVITY_CLOSE_SYSTEM_DIALOGS = 0X00002000;
30803116
/**
30813117
* If set, when sending a broadcast only registered receivers will be
30823118
* called -- no BroadcastReceiver components will be launched.

docs/html/guide/topics/resources/providing-resources.jd

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -528,20 +528,22 @@ how this affects your application during runtime.</p>
528528
which indicates the current device orientation.</p>
529529
</td>
530530
</tr>
531-
<tr id="DockQualifier">
532-
<td>Dock mode</td>
531+
<tr id="UiModeQualifier">
532+
<td>UI mode</td>
533533
<td>
534534
<code>car</code><br/>
535-
<code>desk</code>
535+
<code>desk</code><br/>
536+
<code>television</code>
536537
</td>
537538
<td>
538539
<ul class="nolist">
539-
<li>{@code car}: Device is in a car dock</li>
540-
<li>{@code desk}: Device is in a desk dock</li>
540+
<li>{@code car}: Device is displaying in a car dock</li>
541+
<li>{@code desk}: Device is displaying in a desk dock</li>
542+
<li>{@code television}: Device is displaying on a television</li>
541543
</ul>
542-
<p><em>Added in API level 8.</em></p>
544+
<p><em>Added in API level 8, television added in API 13.</em></p>
543545
<p>This can change during the life of your application if the user places the device in a
544-
dock. You can enable or disable this mode using {@link
546+
dock. You can enable or disable some of these modes using {@link
545547
android.app.UiModeManager}. See <a href="runtime-changes.html">Handling Runtime Changes</a> for
546548
information about how this affects your application during runtime.</p>
547549
</td>

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

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3510,31 +3510,36 @@ public void killApplicationWithUid(String pkg, int uid) {
35103510

35113511
public void closeSystemDialogs(String reason) {
35123512
enforceNotIsolatedCaller("closeSystemDialogs");
3513+
3514+
final int uid = Binder.getCallingUid();
3515+
final long origId = Binder.clearCallingIdentity();
3516+
synchronized (this) {
3517+
closeSystemDialogsLocked(uid, reason);
3518+
}
3519+
Binder.restoreCallingIdentity(origId);
3520+
}
3521+
3522+
void closeSystemDialogsLocked(int callingUid, String reason) {
35133523
Intent intent = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
35143524
intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
35153525
if (reason != null) {
35163526
intent.putExtra("reason", reason);
35173527
}
3528+
mWindowManager.closeSystemDialogs(reason);
35183529

3519-
final int uid = Binder.getCallingUid();
3520-
final long origId = Binder.clearCallingIdentity();
3521-
synchronized (this) {
3522-
mWindowManager.closeSystemDialogs(reason);
3523-
3524-
for (int i=mMainStack.mHistory.size()-1; i>=0; i--) {
3525-
ActivityRecord r = (ActivityRecord)mMainStack.mHistory.get(i);
3526-
if ((r.info.flags&ActivityInfo.FLAG_FINISH_ON_CLOSE_SYSTEM_DIALOGS) != 0) {
3527-
r.stack.finishActivityLocked(r, i,
3528-
Activity.RESULT_CANCELED, null, "close-sys");
3529-
}
3530+
for (int i=mMainStack.mHistory.size()-1; i>=0; i--) {
3531+
ActivityRecord r = (ActivityRecord)mMainStack.mHistory.get(i);
3532+
if ((r.info.flags&ActivityInfo.FLAG_FINISH_ON_CLOSE_SYSTEM_DIALOGS) != 0) {
3533+
r.stack.finishActivityLocked(r, i,
3534+
Activity.RESULT_CANCELED, null, "close-sys");
35303535
}
3531-
3532-
broadcastIntentLocked(null, null, intent, null,
3533-
null, 0, null, null, null, false, false, -1, uid, 0 /* TODO: Verify */);
35343536
}
3535-
Binder.restoreCallingIdentity(origId);
3537+
3538+
broadcastIntentLocked(null, null, intent, null,
3539+
null, 0, null, null, null, false, false, -1,
3540+
callingUid, 0 /* TODO: Verify */);
35363541
}
3537-
3542+
35383543
public Debug.MemoryInfo[] getProcessMemoryInfo(int[] pids)
35393544
throws RemoteException {
35403545
enforceNotIsolatedCaller("getProcessMemoryInfo");

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
import android.os.Message;
5353
import android.os.ParcelFileDescriptor;
5454
import android.os.PowerManager;
55+
import android.os.Process;
5556
import android.os.RemoteException;
5657
import android.os.SystemClock;
5758
import android.os.UserId;
@@ -2532,6 +2533,10 @@ final int startActivityLocked(IApplicationThread caller,
25322533
mDismissKeyguardOnNextActivity = false;
25332534
mService.mWindowManager.dismissKeyguard();
25342535
}
2536+
if (err >= ActivityManager.START_SUCCESS &&
2537+
(launchFlags&Intent.FLAG_ACTIVITY_CLOSE_SYSTEM_DIALOGS) != 0) {
2538+
mService.closeSystemDialogsLocked(Process.myUid(), "launch");
2539+
}
25352540
return err;
25362541
}
25372542

0 commit comments

Comments
 (0)