Merge "System server should always send broadcasts to a specific or all users" into jb-mr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
2278898126
@@ -77,6 +77,7 @@ import android.net.wifi.p2p.WifiP2pManager;
|
|||||||
import android.nfc.NfcManager;
|
import android.nfc.NfcManager;
|
||||||
import android.os.Binder;
|
import android.os.Binder;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Debug;
|
||||||
import android.os.DropBoxManager;
|
import android.os.DropBoxManager;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.os.FileUtils;
|
import android.os.FileUtils;
|
||||||
@@ -97,6 +98,7 @@ import android.telephony.TelephonyManager;
|
|||||||
import android.content.ClipboardManager;
|
import android.content.ClipboardManager;
|
||||||
import android.util.AndroidRuntimeException;
|
import android.util.AndroidRuntimeException;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.util.Slog;
|
||||||
import android.view.CompatibilityInfoHolder;
|
import android.view.CompatibilityInfoHolder;
|
||||||
import android.view.ContextThemeWrapper;
|
import android.view.ContextThemeWrapper;
|
||||||
import android.view.Display;
|
import android.view.Display;
|
||||||
@@ -925,6 +927,7 @@ class ContextImpl extends Context {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void startActivity(Intent intent) {
|
public void startActivity(Intent intent) {
|
||||||
|
warnIfCallingFromSystemProcess();
|
||||||
startActivity(intent, null);
|
startActivity(intent, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -936,6 +939,7 @@ class ContextImpl extends Context {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void startActivity(Intent intent, Bundle options) {
|
public void startActivity(Intent intent, Bundle options) {
|
||||||
|
warnIfCallingFromSystemProcess();
|
||||||
if ((intent.getFlags()&Intent.FLAG_ACTIVITY_NEW_TASK) == 0) {
|
if ((intent.getFlags()&Intent.FLAG_ACTIVITY_NEW_TASK) == 0) {
|
||||||
throw new AndroidRuntimeException(
|
throw new AndroidRuntimeException(
|
||||||
"Calling startActivity() from outside of an Activity "
|
"Calling startActivity() from outside of an Activity "
|
||||||
@@ -962,6 +966,7 @@ class ContextImpl extends Context {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void startActivities(Intent[] intents) {
|
public void startActivities(Intent[] intents) {
|
||||||
|
warnIfCallingFromSystemProcess();
|
||||||
startActivities(intents, null);
|
startActivities(intents, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -981,6 +986,7 @@ class ContextImpl extends Context {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void startActivities(Intent[] intents, Bundle options) {
|
public void startActivities(Intent[] intents, Bundle options) {
|
||||||
|
warnIfCallingFromSystemProcess();
|
||||||
if ((intents[0].getFlags()&Intent.FLAG_ACTIVITY_NEW_TASK) == 0) {
|
if ((intents[0].getFlags()&Intent.FLAG_ACTIVITY_NEW_TASK) == 0) {
|
||||||
throw new AndroidRuntimeException(
|
throw new AndroidRuntimeException(
|
||||||
"Calling startActivities() from outside of an Activity "
|
"Calling startActivities() from outside of an Activity "
|
||||||
@@ -1023,6 +1029,7 @@ class ContextImpl extends Context {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendBroadcast(Intent intent) {
|
public void sendBroadcast(Intent intent) {
|
||||||
|
warnIfCallingFromSystemProcess();
|
||||||
String resolvedType = intent.resolveTypeIfNeeded(getContentResolver());
|
String resolvedType = intent.resolveTypeIfNeeded(getContentResolver());
|
||||||
try {
|
try {
|
||||||
intent.setAllowFds(false);
|
intent.setAllowFds(false);
|
||||||
@@ -1036,6 +1043,7 @@ class ContextImpl extends Context {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendBroadcast(Intent intent, String receiverPermission) {
|
public void sendBroadcast(Intent intent, String receiverPermission) {
|
||||||
|
warnIfCallingFromSystemProcess();
|
||||||
String resolvedType = intent.resolveTypeIfNeeded(getContentResolver());
|
String resolvedType = intent.resolveTypeIfNeeded(getContentResolver());
|
||||||
try {
|
try {
|
||||||
intent.setAllowFds(false);
|
intent.setAllowFds(false);
|
||||||
@@ -1050,6 +1058,7 @@ class ContextImpl extends Context {
|
|||||||
@Override
|
@Override
|
||||||
public void sendOrderedBroadcast(Intent intent,
|
public void sendOrderedBroadcast(Intent intent,
|
||||||
String receiverPermission) {
|
String receiverPermission) {
|
||||||
|
warnIfCallingFromSystemProcess();
|
||||||
String resolvedType = intent.resolveTypeIfNeeded(getContentResolver());
|
String resolvedType = intent.resolveTypeIfNeeded(getContentResolver());
|
||||||
try {
|
try {
|
||||||
intent.setAllowFds(false);
|
intent.setAllowFds(false);
|
||||||
@@ -1066,6 +1075,7 @@ class ContextImpl extends Context {
|
|||||||
String receiverPermission, BroadcastReceiver resultReceiver,
|
String receiverPermission, BroadcastReceiver resultReceiver,
|
||||||
Handler scheduler, int initialCode, String initialData,
|
Handler scheduler, int initialCode, String initialData,
|
||||||
Bundle initialExtras) {
|
Bundle initialExtras) {
|
||||||
|
warnIfCallingFromSystemProcess();
|
||||||
IIntentReceiver rd = null;
|
IIntentReceiver rd = null;
|
||||||
if (resultReceiver != null) {
|
if (resultReceiver != null) {
|
||||||
if (mPackageInfo != null) {
|
if (mPackageInfo != null) {
|
||||||
@@ -1154,6 +1164,7 @@ class ContextImpl extends Context {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendStickyBroadcast(Intent intent) {
|
public void sendStickyBroadcast(Intent intent) {
|
||||||
|
warnIfCallingFromSystemProcess();
|
||||||
String resolvedType = intent.resolveTypeIfNeeded(getContentResolver());
|
String resolvedType = intent.resolveTypeIfNeeded(getContentResolver());
|
||||||
try {
|
try {
|
||||||
intent.setAllowFds(false);
|
intent.setAllowFds(false);
|
||||||
@@ -1170,6 +1181,7 @@ class ContextImpl extends Context {
|
|||||||
BroadcastReceiver resultReceiver,
|
BroadcastReceiver resultReceiver,
|
||||||
Handler scheduler, int initialCode, String initialData,
|
Handler scheduler, int initialCode, String initialData,
|
||||||
Bundle initialExtras) {
|
Bundle initialExtras) {
|
||||||
|
warnIfCallingFromSystemProcess();
|
||||||
IIntentReceiver rd = null;
|
IIntentReceiver rd = null;
|
||||||
if (resultReceiver != null) {
|
if (resultReceiver != null) {
|
||||||
if (mPackageInfo != null) {
|
if (mPackageInfo != null) {
|
||||||
@@ -1337,11 +1349,13 @@ class ContextImpl extends Context {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ComponentName startService(Intent service) {
|
public ComponentName startService(Intent service) {
|
||||||
|
warnIfCallingFromSystemProcess();
|
||||||
return startServiceAsUser(service, mUser);
|
return startServiceAsUser(service, mUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean stopService(Intent service) {
|
public boolean stopService(Intent service) {
|
||||||
|
warnIfCallingFromSystemProcess();
|
||||||
return stopServiceAsUser(service, mUser);
|
return stopServiceAsUser(service, mUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1389,6 +1403,7 @@ class ContextImpl extends Context {
|
|||||||
@Override
|
@Override
|
||||||
public boolean bindService(Intent service, ServiceConnection conn,
|
public boolean bindService(Intent service, ServiceConnection conn,
|
||||||
int flags) {
|
int flags) {
|
||||||
|
warnIfCallingFromSystemProcess();
|
||||||
return bindService(service, conn, flags, UserHandle.getUserId(Process.myUid()));
|
return bindService(service, conn, flags, UserHandle.getUserId(Process.myUid()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1697,6 +1712,13 @@ class ContextImpl extends Context {
|
|||||||
message);
|
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
|
@Override
|
||||||
public Context createPackageContext(String packageName, int flags)
|
public Context createPackageContext(String packageName, int flags)
|
||||||
throws NameNotFoundException {
|
throws NameNotFoundException {
|
||||||
|
|||||||
@@ -2530,7 +2530,7 @@ public class SyncManager {
|
|||||||
syncStateIntent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
|
syncStateIntent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
|
||||||
syncStateIntent.putExtra("active", mNeedSyncActiveNotification);
|
syncStateIntent.putExtra("active", mNeedSyncActiveNotification);
|
||||||
syncStateIntent.putExtra("failing", false);
|
syncStateIntent.putExtra("failing", false);
|
||||||
mContext.sendBroadcast(syncStateIntent);
|
mContext.sendBroadcastAsUser(syncStateIntent, UserHandle.OWNER);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void installHandleTooManyDeletesNotification(Account account, String authority,
|
private void installHandleTooManyDeletesNotification(Account account, String authority,
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import android.content.IntentFilter;
|
|||||||
import android.database.ContentObserver;
|
import android.database.ContentObserver;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
import android.os.UserHandle;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.text.format.DateFormat;
|
import android.text.format.DateFormat;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
@@ -172,7 +173,7 @@ public class ClockView extends RelativeLayout {
|
|||||||
filter.addAction(Intent.ACTION_TIME_TICK);
|
filter.addAction(Intent.ACTION_TIME_TICK);
|
||||||
filter.addAction(Intent.ACTION_TIME_CHANGED);
|
filter.addAction(Intent.ACTION_TIME_CHANGED);
|
||||||
filter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
|
filter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
|
||||||
mContext.registerReceiver(mIntentReceiver, filter);
|
mContext.registerReceiverAsUser(mIntentReceiver, UserHandle.OWNER, filter, null, null );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* monitor 12/24-hour display preference */
|
/* monitor 12/24-hour display preference */
|
||||||
|
|||||||
@@ -836,7 +836,8 @@ class BackupManagerService extends IBackupManager.Stub {
|
|||||||
if ((info.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
|
if ((info.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
|
||||||
if (DEBUG) Slog.v(TAG, "Binding to Google transport");
|
if (DEBUG) Slog.v(TAG, "Binding to Google transport");
|
||||||
Intent intent = new Intent().setComponent(transportComponent);
|
Intent intent = new Intent().setComponent(transportComponent);
|
||||||
context.bindService(intent, mGoogleConnection, Context.BIND_AUTO_CREATE);
|
context.bindService(intent, mGoogleConnection, Context.BIND_AUTO_CREATE,
|
||||||
|
UserHandle.USER_OWNER);
|
||||||
} else {
|
} else {
|
||||||
Slog.w(TAG, "Possible Google transport spoof: ignoring " + info);
|
Slog.w(TAG, "Possible Google transport spoof: ignoring " + info);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1561,7 +1561,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
intent.putExtra(SuggestionSpan.SUGGESTION_SPAN_PICKED_BEFORE, originalString);
|
intent.putExtra(SuggestionSpan.SUGGESTION_SPAN_PICKED_BEFORE, originalString);
|
||||||
intent.putExtra(SuggestionSpan.SUGGESTION_SPAN_PICKED_AFTER, suggestions[index]);
|
intent.putExtra(SuggestionSpan.SUGGESTION_SPAN_PICKED_AFTER, suggestions[index]);
|
||||||
intent.putExtra(SuggestionSpan.SUGGESTION_SPAN_PICKED_HASHCODE, span.hashCode());
|
intent.putExtra(SuggestionSpan.SUGGESTION_SPAN_PICKED_HASHCODE, span.hashCode());
|
||||||
mContext.sendBroadcast(intent);
|
mContext.sendBroadcastAsUser(intent, UserHandle.CURRENT);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1649,7 +1649,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
|
|||||||
Intent intent = new Intent(Intent.ACTION_INPUT_METHOD_CHANGED);
|
Intent intent = new Intent(Intent.ACTION_INPUT_METHOD_CHANGED);
|
||||||
intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
|
intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
|
||||||
intent.putExtra("input_method_id", id);
|
intent.putExtra("input_method_id", id);
|
||||||
mContext.sendBroadcast(intent);
|
mContext.sendBroadcastAsUser(intent, UserHandle.CURRENT);
|
||||||
}
|
}
|
||||||
unbindCurrentClientLocked();
|
unbindCurrentClientLocked();
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ import android.os.ServiceManager;
|
|||||||
import android.os.StrictMode;
|
import android.os.StrictMode;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.os.SystemProperties;
|
import android.os.SystemProperties;
|
||||||
|
import android.os.UserHandle;
|
||||||
import android.server.search.SearchManagerService;
|
import android.server.search.SearchManagerService;
|
||||||
import android.service.dreams.DreamService;
|
import android.service.dreams.DreamService;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
@@ -1005,7 +1006,7 @@ class ServerThread extends Thread {
|
|||||||
intent.setComponent(new ComponentName("com.android.systemui",
|
intent.setComponent(new ComponentName("com.android.systemui",
|
||||||
"com.android.systemui.SystemUIService"));
|
"com.android.systemui.SystemUIService"));
|
||||||
Slog.d(TAG, "Starting service: " + intent);
|
Slog.d(TAG, "Starting service: " + intent);
|
||||||
context.startService(intent);
|
context.startServiceAsUser(intent, UserHandle.OWNER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import android.os.Handler;
|
|||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.IBinder.DeathRecipient;
|
import android.os.IBinder.DeathRecipient;
|
||||||
|
import android.os.UserHandle;
|
||||||
import android.service.dreams.DreamService;
|
import android.service.dreams.DreamService;
|
||||||
import android.service.dreams.IDreamService;
|
import android.service.dreams.IDreamService;
|
||||||
import android.util.Slog;
|
import android.util.Slog;
|
||||||
@@ -83,8 +84,8 @@ final class DreamController {
|
|||||||
public void startDream(Binder token, ComponentName name, boolean isTest, int userId) {
|
public void startDream(Binder token, ComponentName name, boolean isTest, int userId) {
|
||||||
stopDream();
|
stopDream();
|
||||||
|
|
||||||
// Close the notification shade
|
// Close the notification shade. Don't need to send to all, but better to be explicit.
|
||||||
mContext.sendBroadcast(mCloseNotificationShadeIntent);
|
mContext.sendBroadcastAsUser(mCloseNotificationShadeIntent, UserHandle.ALL);
|
||||||
|
|
||||||
Slog.i(TAG, "Starting dream: name=" + name + ", isTest=" + isTest + ", userId=" + userId);
|
Slog.i(TAG, "Starting dream: name=" + name + ", isTest=" + isTest + ", userId=" + userId);
|
||||||
|
|
||||||
@@ -128,7 +129,7 @@ final class DreamController {
|
|||||||
+ ", isTest=" + oldDream.mIsTest + ", userId=" + oldDream.mUserId);
|
+ ", isTest=" + oldDream.mIsTest + ", userId=" + oldDream.mUserId);
|
||||||
|
|
||||||
if (oldDream.mSentStartBroadcast) {
|
if (oldDream.mSentStartBroadcast) {
|
||||||
mContext.sendBroadcast(mDreamingStoppedIntent);
|
mContext.sendBroadcastAsUser(mDreamingStoppedIntent, UserHandle.ALL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oldDream.mService != null) {
|
if (oldDream.mService != null) {
|
||||||
@@ -180,7 +181,7 @@ final class DreamController {
|
|||||||
mCurrentDream.mService = service;
|
mCurrentDream.mService = service;
|
||||||
|
|
||||||
if (!mCurrentDream.mIsTest) {
|
if (!mCurrentDream.mIsTest) {
|
||||||
mContext.sendBroadcast(mDreamingStartedIntent);
|
mContext.sendBroadcastAsUser(mDreamingStartedIntent, UserHandle.ALL);
|
||||||
mCurrentDream.mSentStartBroadcast = true;
|
mCurrentDream.mSentStartBroadcast = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user