am 87f83418: am 329465c6: Merge "Add APIs for interacting across users." into jb-mr1-dev

* commit '87f83418e823625069ccbd60d4799414eb434eca':
  Add APIs for interacting across users.
This commit is contained in:
Dianne Hackborn
2012-08-02 19:19:29 -07:00
committed by Android Git Automerger
21 changed files with 278 additions and 52 deletions

View File

@@ -896,7 +896,7 @@ public class AccountManagerService
private void sendAccountsChangedBroadcast(int userId) {
Log.i(TAG, "the accounts changed, sending broadcast of "
+ ACCOUNTS_CHANGED_INTENT.getAction());
mContext.sendBroadcast(ACCOUNTS_CHANGED_INTENT, userId);
mContext.sendBroadcastToUser(ACCOUNTS_CHANGED_INTENT, userId);
}
public void clearPassword(Account account) {

View File

@@ -966,9 +966,8 @@ class ContextImpl extends Context {
}
}
/** @hide */
@Override
public void sendBroadcast(Intent intent, int userId) {
public void sendBroadcastToUser(Intent intent, int userId) {
String resolvedType = intent.resolveTypeIfNeeded(getContentResolver());
try {
intent.setAllowFds(false);

View File

@@ -988,12 +988,14 @@ public abstract class Context {
public abstract void sendBroadcast(Intent intent);
/**
* Same as #sendBroadcast(Intent intent), but for a specific user. Used by the system only.
* Same as #sendBroadcast(Intent intent), but for a specific user. This broadcast
* can only be sent to receivers that are part of the calling application. It
* requires holding the {@link android.Manifest.permission#INTERACT_ACROSS_USERS}
* permission.
* @param intent the intent to broadcast
* @param userId user to send the intent to
* @hide
*/
public void sendBroadcast(Intent intent, int userId) {
public void sendBroadcastToUser(Intent intent, int userId) {
throw new RuntimeException("Not implemented. Must override in a subclass.");
}

View File

@@ -312,10 +312,9 @@ public class ContextWrapper extends Context {
mBase.sendBroadcast(intent);
}
/** @hide */
@Override
public void sendBroadcast(Intent intent, int userId) {
mBase.sendBroadcast(intent, userId);
public void sendBroadcastToUser(Intent intent, int userId) {
mBase.sendBroadcastToUser(intent, userId);
}
@Override

View File

@@ -2703,7 +2703,7 @@ public class PackageParser {
return null;
}
final boolean setExported = sa.hasValue(
boolean setExported = sa.hasValue(
com.android.internal.R.styleable.AndroidManifestService_exported);
if (setExported) {
s.info.exported = sa.getBoolean(
@@ -2729,6 +2729,18 @@ public class PackageParser {
false)) {
s.info.flags |= ServiceInfo.FLAG_ISOLATED_PROCESS;
}
if (sa.getBoolean(
com.android.internal.R.styleable.AndroidManifestService_singleUser,
false)) {
s.info.flags |= ServiceInfo.FLAG_SINGLE_USER;
if (s.info.exported) {
Slog.w(TAG, "Service exported request ignored due to singleUser: "
+ s.className + " at " + mArchiveSourcePath + " "
+ parser.getPositionDescription());
s.info.exported = false;
}
setExported = true;
}
sa.recycle();

View File

@@ -48,6 +48,13 @@ public class ServiceInfo extends ComponentInfo
*/
public static final int FLAG_ISOLATED_PROCESS = 0x0002;
/**
* Bit in {@link #flags}: If set, a single instance of the service will
* run for all users on the device. Set from the
* {@link android.R.attr#singleUser} attribute.
*/
public static final int FLAG_SINGLE_USER = 0x0004;
/**
* Options that have been set in the service declaration in the
* manifest.