summaryrefslogtreecommitdiffstats
path: root/core/java
diff options
context:
space:
mode:
authorAmith Yamasani <yamasani@google.com>2012-10-22 13:32:23 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-10-22 13:32:24 -0700
commit2278898126c1cea4bd345bb96313d381b4ad3993 (patch)
treed8b158e6fc1205970a0f2c43557acba84a4fbfd5 /core/java
parentcd92db84c6d9e0c9992abfbbda45d504c7f5e062 (diff)
parentcd75706117432e33d11639e675bcff50479a6bb9 (diff)
downloadframeworks_base-2278898126c1cea4bd345bb96313d381b4ad3993.zip
frameworks_base-2278898126c1cea4bd345bb96313d381b4ad3993.tar.gz
frameworks_base-2278898126c1cea4bd345bb96313d381b4ad3993.tar.bz2
Merge "System server should always send broadcasts to a specific or all users" into jb-mr1-dev
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/app/ContextImpl.java22
-rw-r--r--core/java/android/content/SyncManager.java2
2 files changed, 23 insertions, 1 deletions
diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java
index 3e1e358..95b6bed 100644
--- a/core/java/android/app/ContextImpl.java
+++ b/core/java/android/app/ContextImpl.java
@@ -77,6 +77,7 @@ import android.net.wifi.p2p.WifiP2pManager;
import android.nfc.NfcManager;
import android.os.Binder;
import android.os.Bundle;
+import android.os.Debug;
import android.os.DropBoxManager;
import android.os.Environment;
import android.os.FileUtils;
@@ -97,6 +98,7 @@ import android.telephony.TelephonyManager;
import android.content.ClipboardManager;
import android.util.AndroidRuntimeException;
import android.util.Log;
+import android.util.Slog;
import android.view.CompatibilityInfoHolder;
import android.view.ContextThemeWrapper;
import android.view.Display;
@@ -925,6 +927,7 @@ class ContextImpl extends Context {
@Override
public void startActivity(Intent intent) {
+ warnIfCallingFromSystemProcess();
startActivity(intent, null);
}
@@ -936,6 +939,7 @@ class ContextImpl extends Context {
@Override
public void startActivity(Intent intent, Bundle options) {
+ warnIfCallingFromSystemProcess();
if ((intent.getFlags()&Intent.FLAG_ACTIVITY_NEW_TASK) == 0) {
throw new AndroidRuntimeException(
"Calling startActivity() from outside of an Activity "
@@ -962,6 +966,7 @@ class ContextImpl extends Context {
@Override
public void startActivities(Intent[] intents) {
+ warnIfCallingFromSystemProcess();
startActivities(intents, null);
}
@@ -981,6 +986,7 @@ class ContextImpl extends Context {
@Override
public void startActivities(Intent[] intents, Bundle options) {
+ warnIfCallingFromSystemProcess();
if ((intents[0].getFlags()&Intent.FLAG_ACTIVITY_NEW_TASK) == 0) {
throw new AndroidRuntimeException(
"Calling startActivities() from outside of an Activity "
@@ -1023,6 +1029,7 @@ class ContextImpl extends Context {
@Override
public void sendBroadcast(Intent intent) {
+ warnIfCallingFromSystemProcess();
String resolvedType = intent.resolveTypeIfNeeded(getContentResolver());
try {
intent.setAllowFds(false);
@@ -1036,6 +1043,7 @@ class ContextImpl extends Context {
@Override
public void sendBroadcast(Intent intent, String receiverPermission) {
+ warnIfCallingFromSystemProcess();
String resolvedType = intent.resolveTypeIfNeeded(getContentResolver());
try {
intent.setAllowFds(false);
@@ -1050,6 +1058,7 @@ class ContextImpl extends Context {
@Override
public void sendOrderedBroadcast(Intent intent,
String receiverPermission) {
+ warnIfCallingFromSystemProcess();
String resolvedType = intent.resolveTypeIfNeeded(getContentResolver());
try {
intent.setAllowFds(false);
@@ -1066,6 +1075,7 @@ class ContextImpl extends Context {
String receiverPermission, BroadcastReceiver resultReceiver,
Handler scheduler, int initialCode, String initialData,
Bundle initialExtras) {
+ warnIfCallingFromSystemProcess();
IIntentReceiver rd = null;
if (resultReceiver != null) {
if (mPackageInfo != null) {
@@ -1154,6 +1164,7 @@ class ContextImpl extends Context {
@Override
public void sendStickyBroadcast(Intent intent) {
+ warnIfCallingFromSystemProcess();
String resolvedType = intent.resolveTypeIfNeeded(getContentResolver());
try {
intent.setAllowFds(false);
@@ -1170,6 +1181,7 @@ class ContextImpl extends Context {
BroadcastReceiver resultReceiver,
Handler scheduler, int initialCode, String initialData,
Bundle initialExtras) {
+ warnIfCallingFromSystemProcess();
IIntentReceiver rd = null;
if (resultReceiver != null) {
if (mPackageInfo != null) {
@@ -1337,11 +1349,13 @@ class ContextImpl extends Context {
@Override
public ComponentName startService(Intent service) {
+ warnIfCallingFromSystemProcess();
return startServiceAsUser(service, mUser);
}
@Override
public boolean stopService(Intent service) {
+ warnIfCallingFromSystemProcess();
return stopServiceAsUser(service, mUser);
}
@@ -1389,6 +1403,7 @@ class ContextImpl extends Context {
@Override
public boolean bindService(Intent service, ServiceConnection conn,
int flags) {
+ warnIfCallingFromSystemProcess();
return bindService(service, conn, flags, UserHandle.getUserId(Process.myUid()));
}
@@ -1697,6 +1712,13 @@ class ContextImpl extends Context {
message);
}
+ private void warnIfCallingFromSystemProcess() {
+ if (Process.myUid() == Process.SYSTEM_UID) {
+ Slog.w(TAG, "Calling a method in the system process without a qualified user: "
+ + Debug.getCallers(3));
+ }
+ }
+
@Override
public Context createPackageContext(String packageName, int flags)
throws NameNotFoundException {
diff --git a/core/java/android/content/SyncManager.java b/core/java/android/content/SyncManager.java
index 05bab9c..977b461 100644
--- a/core/java/android/content/SyncManager.java
+++ b/core/java/android/content/SyncManager.java
@@ -2530,7 +2530,7 @@ public class SyncManager {
syncStateIntent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
syncStateIntent.putExtra("active", mNeedSyncActiveNotification);
syncStateIntent.putExtra("failing", false);
- mContext.sendBroadcast(syncStateIntent);
+ mContext.sendBroadcastAsUser(syncStateIntent, UserHandle.OWNER);
}
private void installHandleTooManyDeletesNotification(Account account, String authority,