Skip to content

Commit d4ac8d7

Browse files
author
Dianne Hackborn
committed
Fix issue #7211769 and #7244492, thrash around on #7226656.
Issue #7211769: Crash dialog from background user has non-working "report" The report button now launches the issue reporter for the correct user. Also for crashes on background users, either disable the report button, or simply don't show the dialog depending on the build config. Issue #7244492: Bugreport button in Quick Settings doesn't actually do anything Now they do. Issue #7226656: second user seeing primary user's apps I haven't had any success at reproducing this. I have tried to tighten up the path where we create the user to ensure nothing could cause the user's applications to be accessed before the user it fully created and thus make them installed... but I can't convince myself that is the actual problem. Also tightened up the user switch code to use forground broadcasts for all of the updates about the switch (since this is really a foreground operation), added a facility to have BOOT_COMPELTED broadcasts not get launched for secondary users and use that on a few key system receivers, fixed some debug output. Change-Id: Iadf8f8e4878a86def2e495e9d0dc40c4fb347021
1 parent 97298cd commit d4ac8d7

File tree

19 files changed

+324
-90
lines changed

19 files changed

+324
-90
lines changed

cmds/am/src/com/android/commands/am/Am.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ private void run(String[] args) throws Exception {
127127
runSetDebugApp();
128128
} else if (op.equals("clear-debug-app")) {
129129
runClearDebugApp();
130+
} else if (op.equals("bug-report")) {
131+
runBugReport();
130132
} else if (op.equals("monitor")) {
131133
runMonitor();
132134
} else if (op.equals("screen-compat")) {
@@ -844,6 +846,11 @@ private void runClearDebugApp() throws Exception {
844846
mAm.setDebugApp(null, false, true);
845847
}
846848

849+
private void runBugReport() throws Exception {
850+
mAm.requestBugReport();
851+
System.out.println("Your lovely bug report is being created; please be patient.");
852+
}
853+
847854
private void runSwitchUser() throws Exception {
848855
String user = nextArgRequired();
849856
mAm.switchUser(Integer.parseInt(user));
@@ -1508,6 +1515,9 @@ private static void showUsage() {
15081515
"\n" +
15091516
"am clear-debug-app: clear the previously set-debug-app.\n" +
15101517
"\n" +
1518+
"am bug-report: request bug report generation; will launch UI\n" +
1519+
" when done to select where it should be delivered." +
1520+
"\n" +
15111521
"am monitor: start monitoring for crashes or ANRs.\n" +
15121522
" --gdb: start gdbserv on the given port at crash/ANR\n" +
15131523
"\n" +

core/java/android/app/ActivityManagerNative.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1783,6 +1783,12 @@ public boolean onTransact(int code, Parcel data, Parcel reply, int flags)
17831783
return true;
17841784
}
17851785

1786+
case REQUEST_BUG_REPORT_TRANSACTION: {
1787+
data.enforceInterface(IActivityManager.descriptor);
1788+
requestBugReport();
1789+
return true;
1790+
}
1791+
17861792
}
17871793

17881794
return super.onTransact(code, data, reply, flags);
@@ -4066,5 +4072,15 @@ public void unregisterUserSwitchObserver(IUserSwitchObserver observer) throws Re
40664072
reply.recycle();
40674073
}
40684074

4075+
public void requestBugReport() throws RemoteException {
4076+
Parcel data = Parcel.obtain();
4077+
Parcel reply = Parcel.obtain();
4078+
data.writeInterfaceToken(IActivityManager.descriptor);
4079+
mRemote.transact(REQUEST_BUG_REPORT_TRANSACTION, data, reply, 0);
4080+
reply.readException();
4081+
data.recycle();
4082+
reply.recycle();
4083+
}
4084+
40694085
private IBinder mRemote;
40704086
}

core/java/android/app/IActivityManager.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,8 @@ public boolean navigateUpTo(IBinder token, Intent target, int resultCode, Intent
361361
public void registerUserSwitchObserver(IUserSwitchObserver observer) throws RemoteException;
362362
public void unregisterUserSwitchObserver(IUserSwitchObserver observer) throws RemoteException;
363363

364+
public void requestBugReport() throws RemoteException;
365+
364366
/*
365367
* Private non-Binder interfaces
366368
*/
@@ -613,4 +615,5 @@ private WaitResult(Parcel source) {
613615
int REGISTER_USER_SWITCH_OBSERVER_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+154;
614616
int UNREGISTER_USER_SWITCH_OBSERVER_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+155;
615617
int GET_RUNNING_USER_IDS_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+156;
618+
int REQUEST_BUG_REPORT_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+157;
616619
}

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,17 @@ public class ActivityInfo extends ComponentInfo
171171
* {@see android.app.Notification#FLAG_HIGH_PRIORITY}
172172
*/
173173
public static final int FLAG_IMMERSIVE = 0x0400;
174+
/**
175+
* @hide Bit in {@link #flags}: If set, this component will only be seen
176+
* by the primary user. Only works with broadcast receivers. Set from the
177+
* {@link android.R.attr#primaryUserOnly} attribute.
178+
*/
179+
public static final int FLAG_PRIMARY_USER_ONLY = 0x20000000;
174180
/**
175181
* Bit in {@link #flags}: If set, a single instance of the receiver will
176182
* run for all users on the device. Set from the
177183
* {@link android.R.attr#singleUser} attribute. Note that this flag is
178-
* only relevent for ActivityInfo structures that are describiner receiver
184+
* only relevant for ActivityInfo structures that are describing receiver
179185
* components; it is not applied to activities.
180186
*/
181187
public static final int FLAG_SINGLE_USER = 0x40000000;

core/java/android/content/pm/PackageParser.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2193,7 +2193,7 @@ private Activity parseActivity(Package owner, Resources res,
21932193
if (sa.getBoolean(
21942194
com.android.internal.R.styleable.AndroidManifestActivity_singleUser,
21952195
false)) {
2196-
a.info.flags |= ServiceInfo.FLAG_SINGLE_USER;
2196+
a.info.flags |= ActivityInfo.FLAG_SINGLE_USER;
21972197
if (a.info.exported) {
21982198
Slog.w(TAG, "Activity exported request ignored due to singleUser: "
21992199
+ a.className + " at " + mArchiveSourcePath + " "
@@ -2202,6 +2202,11 @@ private Activity parseActivity(Package owner, Resources res,
22022202
}
22032203
setExported = true;
22042204
}
2205+
if (sa.getBoolean(
2206+
com.android.internal.R.styleable.AndroidManifestActivity_primaryUserOnly,
2207+
false)) {
2208+
a.info.flags |= ActivityInfo.FLAG_PRIMARY_USER_ONLY;
2209+
}
22052210
}
22062211

22072212
sa.recycle();

core/java/android/content/pm/PackageUserState.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ public class PackageUserState {
3434
public HashSet<String> enabledComponents;
3535

3636
public PackageUserState() {
37+
this(true);
38+
}
39+
40+
/** @hide */
41+
public PackageUserState(boolean isSystem) {
42+
if (!isSystem) {
43+
stopped = notLaunched = true;
44+
}
3745
installed = true;
3846
enabled = COMPONENT_ENABLED_STATE_DEFAULT;
3947
}

core/java/android/content/pm/UserInfo.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ public class UserInfo implements Parcelable {
7171
public long creationTime;
7272
public long lastLoggedInTime;
7373

74+
/** User is only partially created. */
75+
public boolean partial;
76+
7477
public UserInfo(int id, String name, int flags) {
7578
this(id, name, null, flags);
7679
}
@@ -105,6 +108,7 @@ public UserInfo(UserInfo orig) {
105108
serialNumber = orig.serialNumber;
106109
creationTime = orig.creationTime;
107110
lastLoggedInTime = orig.lastLoggedInTime;
111+
partial = orig.partial;
108112
}
109113

110114
public UserHandle getUserHandle() {
@@ -128,6 +132,7 @@ public void writeToParcel(Parcel dest, int parcelableFlags) {
128132
dest.writeInt(serialNumber);
129133
dest.writeLong(creationTime);
130134
dest.writeLong(lastLoggedInTime);
135+
dest.writeInt(partial ? 1 : 0);
131136
}
132137

133138
public static final Parcelable.Creator<UserInfo> CREATOR
@@ -148,5 +153,6 @@ private UserInfo(Parcel source) {
148153
serialNumber = source.readInt();
149154
creationTime = source.readLong();
150155
lastLoggedInTime = source.readLong();
156+
partial = source.readInt() != 0;
151157
}
152158
}

core/res/AndroidManifest.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2140,7 +2140,8 @@
21402140
android:process=":ui">
21412141
</activity>
21422142

2143-
<receiver android:name="com.android.server.BootReceiver" >
2143+
<receiver android:name="com.android.server.BootReceiver"
2144+
android:primaryUserOnly="true">
21442145
<intent-filter>
21452146
<action android:name="android.intent.action.BOOT_COMPLETED" />
21462147
</intent-filter>

core/res/res/values/attrs_manifest.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1391,6 +1391,9 @@
13911391
<attr name="uiOptions" />
13921392
<attr name="parentActivityName" />
13931393
<attr name="singleUser" />
1394+
<!-- @hide This broacast receiver will only receive broadcasts for the
1395+
primary user. Can only be used with receivers. -->
1396+
<attr name="primaryUserOnly" format="boolean" />
13941397
</declare-styleable>
13951398

13961399
<!-- The <code>activity-alias</code> tag declares a new

packages/SystemUI/AndroidManifest.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
23
package="com.android.systemui"
34
coreApp="true">
45

@@ -91,7 +92,7 @@
9192
android:permission="android.permission.BIND_WALLPAPER"
9293
android:exported="true" />
9394

94-
<receiver android:name=".BootReceiver" >
95+
<receiver android:name=".BootReceiver" androidprv:primaryUserOnly="true">
9596
<intent-filter>
9697
<action android:name="android.intent.action.BOOT_COMPLETED" />
9798
</intent-filter>

0 commit comments

Comments
 (0)