Skip to content

Commit fd8bf5c

Browse files
author
Dianne Hackborn
committed
Fix another issue #7097984 java.lang.SecurityException: Permission Denial:
broadcast asks to run as user -1 but is calling from user 0; this requires Dupped bug of a different problem. Change-Id: I15f4ab08b81f5f5746ba1cd183dee4f0b1281df5
1 parent d2a8df9 commit fd8bf5c

File tree

2 files changed

+27
-7
lines changed

2 files changed

+27
-7
lines changed

services/java/com/android/server/AppWidgetService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@ public void systemReady(boolean safeMode) {
155155

156156
// Register for configuration changes so we can update the names
157157
// of the widgets when the locale changes.
158-
mContext.registerReceiver(mBroadcastReceiver, new IntentFilter(
159-
Intent.ACTION_CONFIGURATION_CHANGED), null, null);
158+
mContext.registerReceiverAsUser(mBroadcastReceiver, UserHandle.ALL,
159+
new IntentFilter(Intent.ACTION_CONFIGURATION_CHANGED), null, null);
160160

161161
// Register for broadcasts about package install, etc., so we can
162162
// update the provider list.

services/java/com/android/server/ConnectivityService.java

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1852,8 +1852,13 @@ private void sendDataActivityBroadcast(int deviceType, boolean active) {
18521852
Intent intent = new Intent(ConnectivityManager.ACTION_DATA_ACTIVITY_CHANGE);
18531853
intent.putExtra(ConnectivityManager.EXTRA_DEVICE_TYPE, deviceType);
18541854
intent.putExtra(ConnectivityManager.EXTRA_IS_ACTIVE, active);
1855-
mContext.sendOrderedBroadcastAsUser(intent, UserHandle.ALL,
1856-
RECEIVE_DATA_ACTIVITY_CHANGE, null, null, 0, null, null);
1855+
final long ident = Binder.clearCallingIdentity();
1856+
try {
1857+
mContext.sendOrderedBroadcastAsUser(intent, UserHandle.ALL,
1858+
RECEIVE_DATA_ACTIVITY_CHANGE, null, null, 0, null, null);
1859+
} finally {
1860+
Binder.restoreCallingIdentity(ident);
1861+
}
18571862
}
18581863

18591864
/**
@@ -1927,7 +1932,12 @@ private void sendStickyBroadcast(Intent intent) {
19271932
log("sendStickyBroadcast: action=" + intent.getAction());
19281933
}
19291934

1930-
mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
1935+
final long ident = Binder.clearCallingIdentity();
1936+
try {
1937+
mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
1938+
} finally {
1939+
Binder.restoreCallingIdentity(ident);
1940+
}
19311941
}
19321942
}
19331943

@@ -2467,7 +2477,12 @@ private void bumpDns() {
24672477
* Connectivity events can happen before boot has completed ...
24682478
*/
24692479
intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
2470-
mContext.sendBroadcastAsUser(intent, UserHandle.ALL);
2480+
final long ident = Binder.clearCallingIdentity();
2481+
try {
2482+
mContext.sendBroadcastAsUser(intent, UserHandle.ALL);
2483+
} finally {
2484+
Binder.restoreCallingIdentity(ident);
2485+
}
24712486
}
24722487

24732488
// Caller must grab mDnsLock.
@@ -3112,7 +3127,12 @@ private void sendProxyBroadcast(ProxyProperties proxy) {
31123127
intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING |
31133128
Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
31143129
intent.putExtra(Proxy.EXTRA_PROXY_INFO, proxy);
3115-
mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
3130+
final long ident = Binder.clearCallingIdentity();
3131+
try {
3132+
mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
3133+
} finally {
3134+
Binder.restoreCallingIdentity(ident);
3135+
}
31163136
}
31173137

31183138
private static class SettingsObserver extends ContentObserver {

0 commit comments

Comments
 (0)