use of android.os.UserHandle in project platform_frameworks_base by android.
the class WallpaperManagerService method notifyCallbacksLocked.
private void notifyCallbacksLocked(WallpaperData wallpaper) {
final int n = wallpaper.callbacks.beginBroadcast();
for (int i = 0; i < n; i++) {
try {
wallpaper.callbacks.getBroadcastItem(i).onWallpaperChanged();
} catch (RemoteException e) {
// The RemoteCallbackList will take care of removing
// the dead object for us.
}
}
wallpaper.callbacks.finishBroadcast();
final Intent intent = new Intent(Intent.ACTION_WALLPAPER_CHANGED);
mContext.sendBroadcastAsUser(intent, new UserHandle(mCurrentUserId));
}
use of android.os.UserHandle in project platform_frameworks_base by android.
the class AppWidgetServiceImpl method handleNotifyAppWidgetViewDataChanged.
private void handleNotifyAppWidgetViewDataChanged(Host host, IAppWidgetHost callbacks, int appWidgetId, int viewId, long requestTime) {
try {
callbacks.viewDataChanged(appWidgetId, viewId);
host.lastWidgetUpdateTime = requestTime;
} catch (RemoteException re) {
// It failed; remove the callback. No need to prune because
// we know that this host is still referenced by this instance.
callbacks = null;
}
// RemoteViewsFactory.onDataSetChanged() directly
synchronized (mLock) {
if (callbacks == null) {
host.callbacks = null;
Set<Pair<Integer, FilterComparison>> keys = mRemoteViewsServicesAppWidgets.keySet();
for (Pair<Integer, FilterComparison> key : keys) {
if (mRemoteViewsServicesAppWidgets.get(key).contains(appWidgetId)) {
final ServiceConnection connection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
IRemoteViewsFactory cb = IRemoteViewsFactory.Stub.asInterface(service);
try {
cb.onDataSetChangedAsync();
} catch (RemoteException e) {
Slog.e(TAG, "Error calling onDataSetChangedAsync()", e);
}
mContext.unbindService(this);
}
@Override
public void onServiceDisconnected(android.content.ComponentName name) {
// Do nothing
}
};
final int userId = UserHandle.getUserId(key.first);
Intent intent = key.second.getIntent();
// Bind to the service and call onDataSetChanged()
bindService(intent, connection, new UserHandle(userId));
}
}
}
}
}
use of android.os.UserHandle in project platform_frameworks_base by android.
the class AppWidgetServiceImpl method createAppWidgetConfigIntentSender.
@Override
public IntentSender createAppWidgetConfigIntentSender(String callingPackage, int appWidgetId, final int intentFlags) {
final int userId = UserHandle.getCallingUserId();
if (DEBUG) {
Slog.i(TAG, "createAppWidgetConfigIntentSender() " + userId);
}
// Make sure the package runs under the caller uid.
mSecurityPolicy.enforceCallFromPackage(callingPackage);
synchronized (mLock) {
ensureGroupStateLoadedLocked(userId);
// NOTE: The lookup is enforcing security across users by making
// sure the caller can only access widgets it hosts or provides.
Widget widget = lookupWidgetLocked(appWidgetId, Binder.getCallingUid(), callingPackage);
if (widget == null) {
throw new IllegalArgumentException("Bad widget id " + appWidgetId);
}
Provider provider = widget.provider;
if (provider == null) {
throw new IllegalArgumentException("Widget not bound " + appWidgetId);
}
// Make sure only safe flags can be passed it.
final int secureFlags = intentFlags & ~Intent.IMMUTABLE_FLAGS;
Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_CONFIGURE);
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
intent.setComponent(provider.info.configure);
intent.setFlags(secureFlags);
// All right, create the sender.
final long identity = Binder.clearCallingIdentity();
try {
return PendingIntent.getActivityAsUser(mContext, 0, intent, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_CANCEL_CURRENT, null, new UserHandle(provider.getUserId())).getIntentSender();
} finally {
Binder.restoreCallingIdentity(identity);
}
}
}
use of android.os.UserHandle in project platform_frameworks_base by android.
the class ActivityManagerService method requestTargetProviderPermissionsReviewIfNeededLocked.
private boolean requestTargetProviderPermissionsReviewIfNeededLocked(ProviderInfo cpi, ProcessRecord r, final int userId) {
if (getPackageManagerInternalLocked().isPermissionsReviewRequired(cpi.packageName, userId)) {
final boolean callerForeground = r == null || r.setSchedGroup != ProcessList.SCHED_GROUP_BACKGROUND;
// Show a permission review UI only for starting from a foreground app
if (!callerForeground) {
Slog.w(TAG, "u" + userId + " Instantiating a provider in package" + cpi.packageName + " requires a permissions review");
return false;
}
final Intent intent = new Intent(Intent.ACTION_REVIEW_PERMISSIONS);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
intent.putExtra(Intent.EXTRA_PACKAGE_NAME, cpi.packageName);
if (DEBUG_PERMISSIONS_REVIEW) {
Slog.i(TAG, "u" + userId + " Launching permission review " + "for package " + cpi.packageName);
}
final UserHandle userHandle = new UserHandle(userId);
mHandler.post(new Runnable() {
@Override
public void run() {
mContext.startActivityAsUser(intent, userHandle);
}
});
return false;
}
return true;
}
use of android.os.UserHandle in project platform_frameworks_base by android.
the class ActivityManagerService method reportAssistContextExtras.
public void reportAssistContextExtras(IBinder token, Bundle extras, AssistStructure structure, AssistContent content, Uri referrer) {
PendingAssistExtras pae = (PendingAssistExtras) token;
synchronized (pae) {
pae.result = extras;
pae.structure = structure;
pae.content = content;
if (referrer != null) {
pae.extras.putParcelable(Intent.EXTRA_REFERRER, referrer);
}
pae.haveResult = true;
pae.notifyAll();
if (pae.intent == null && pae.receiver == null) {
// Caller is just waiting for the result.
return;
}
}
// We are now ready to launch the assist activity.
IResultReceiver sendReceiver = null;
Bundle sendBundle = null;
synchronized (this) {
buildAssistBundleLocked(pae, extras);
boolean exists = mPendingAssistExtras.remove(pae);
mUiHandler.removeCallbacks(pae);
if (!exists) {
// Timed out.
return;
}
if ((sendReceiver = pae.receiver) != null) {
// Caller wants result sent back to them.
sendBundle = new Bundle();
sendBundle.putBundle(VoiceInteractionSession.KEY_DATA, pae.extras);
sendBundle.putParcelable(VoiceInteractionSession.KEY_STRUCTURE, pae.structure);
sendBundle.putParcelable(VoiceInteractionSession.KEY_CONTENT, pae.content);
sendBundle.putBundle(VoiceInteractionSession.KEY_RECEIVER_EXTRAS, pae.receiverExtras);
}
}
if (sendReceiver != null) {
try {
sendReceiver.send(0, sendBundle);
} catch (RemoteException e) {
}
return;
}
long ident = Binder.clearCallingIdentity();
try {
pae.intent.replaceExtras(pae.extras);
pae.intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
closeSystemDialogs("assist");
try {
mContext.startActivityAsUser(pae.intent, new UserHandle(pae.userHandle));
} catch (ActivityNotFoundException e) {
Slog.w(TAG, "No activity to handle assist action.", e);
}
} finally {
Binder.restoreCallingIdentity(ident);
}
}
Aggregations