Search in sources :

Example 26 with UserHandle

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));
}
Also used : UserHandle(android.os.UserHandle) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) RemoteException(android.os.RemoteException) Point(android.graphics.Point)

Example 27 with UserHandle

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));
                }
            }
        }
    }
}
Also used : ServiceConnection(android.content.ServiceConnection) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) Point(android.graphics.Point) IBinder(android.os.IBinder) UserHandle(android.os.UserHandle) IRemoteViewsFactory(com.android.internal.widget.IRemoteViewsFactory) FilterComparison(android.content.Intent.FilterComparison) ComponentName(android.content.ComponentName) RemoteException(android.os.RemoteException) Pair(android.util.Pair)

Example 28 with UserHandle

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);
        }
    }
}
Also used : UserHandle(android.os.UserHandle) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) Point(android.graphics.Point) WidgetBackupProvider(com.android.server.WidgetBackupProvider)

Example 29 with UserHandle

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;
}
Also used : UserHandle(android.os.UserHandle) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent)

Example 30 with UserHandle

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);
    }
}
Also used : IResultReceiver(com.android.internal.os.IResultReceiver) ActivityNotFoundException(android.content.ActivityNotFoundException) Bundle(android.os.Bundle) PersistableBundle(android.os.PersistableBundle) UserHandle(android.os.UserHandle) RemoteException(android.os.RemoteException)

Aggregations

UserHandle (android.os.UserHandle)568 Intent (android.content.Intent)231 RemoteException (android.os.RemoteException)163 PendingIntent (android.app.PendingIntent)132 ComponentName (android.content.ComponentName)69 Context (android.content.Context)68 UserInfo (android.content.pm.UserInfo)66 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)62 Bundle (android.os.Bundle)50 IBinder (android.os.IBinder)49 UserManager (android.os.UserManager)44 PackageManager (android.content.pm.PackageManager)40 ApplicationInfo (android.content.pm.ApplicationInfo)30 IOException (java.io.IOException)30 ArrayList (java.util.ArrayList)30 ActivityNotFoundException (android.content.ActivityNotFoundException)28 Notification (android.app.Notification)27 ServiceConnection (android.content.ServiceConnection)27 IPackageManager (android.content.pm.IPackageManager)27 Pair (android.util.Pair)23