Search in sources :

Example 76 with IBinder

use of android.os.IBinder 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 77 with IBinder

use of android.os.IBinder in project platform_frameworks_base by android.

the class AppWidgetServiceImpl method destroyRemoteViewsService.

// Destroys the cached factory on the RemoteViewsService's side related to the specified intent
private void destroyRemoteViewsService(final Intent intent, Widget widget) {
    final ServiceConnection conn = new ServiceConnection() {

        @Override
        public void onServiceConnected(ComponentName name, IBinder service) {
            final IRemoteViewsFactory cb = IRemoteViewsFactory.Stub.asInterface(service);
            try {
                cb.onDestroy(intent);
            } catch (RemoteException re) {
                Slog.e(TAG, "Error calling remove view factory", re);
            }
            mContext.unbindService(this);
        }

        @Override
        public void onServiceDisconnected(ComponentName name) {
        // Do nothing
        }
    };
    // Bind to the service and remove the static intent->factory mapping in the
    // RemoteViewsService.
    final long token = Binder.clearCallingIdentity();
    try {
        mContext.bindServiceAsUser(intent, conn, Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE_WHILE_AWAKE, widget.provider.info.getProfile());
    } finally {
        Binder.restoreCallingIdentity(token);
    }
}
Also used : ServiceConnection(android.content.ServiceConnection) IBinder(android.os.IBinder) IRemoteViewsFactory(com.android.internal.widget.IRemoteViewsFactory) ComponentName(android.content.ComponentName) RemoteException(android.os.RemoteException)

Example 78 with IBinder

use of android.os.IBinder in project platform_frameworks_base by android.

the class AccessibilityManagerService method getWindowToken.

@Override
public IBinder getWindowToken(int windowId, int userId) {
    mSecurityPolicy.enforceCallingPermission(Manifest.permission.RETRIEVE_WINDOW_TOKEN, GET_WINDOW_TOKEN);
    synchronized (mLock) {
        // We treat calls from a profile as if made by its parent as profiles
        // share the accessibility state of the parent. The call below
        // performs the current profile parent resolution.
        final int resolvedUserId = mSecurityPolicy.resolveCallingUserIdEnforcingPermissionsLocked(userId);
        if (resolvedUserId != mCurrentUserId) {
            return null;
        }
        if (mSecurityPolicy.findWindowById(windowId) == null) {
            return null;
        }
        IBinder token = mGlobalWindowTokens.get(windowId);
        if (token != null) {
            return token;
        }
        return getCurrentUserStateLocked().mWindowTokens.get(windowId);
    }
}
Also used : IBinder(android.os.IBinder) Point(android.graphics.Point)

Example 79 with IBinder

use of android.os.IBinder in project platform_frameworks_base by android.

the class ActiveServices method peekServiceLocked.

IBinder peekServiceLocked(Intent service, String resolvedType, String callingPackage) {
    ServiceLookupResult r = retrieveServiceLocked(service, resolvedType, callingPackage, Binder.getCallingPid(), Binder.getCallingUid(), UserHandle.getCallingUserId(), false, false, false);
    IBinder ret = null;
    if (r != null) {
        // r.record is null if findServiceLocked() failed the caller permission check
        if (r.record == null) {
            throw new SecurityException("Permission Denial: Accessing service" + " from pid=" + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid() + " requires " + r.permission);
        }
        IntentBindRecord ib = r.record.bindings.get(r.record.intent);
        if (ib != null) {
            ret = ib.binder;
        }
    }
    return ret;
}
Also used : IBinder(android.os.IBinder)

Example 80 with IBinder

use of android.os.IBinder in project platform_frameworks_base by android.

the class AndroidKeyStoreSignatureSpiBase method resetWhilePreservingInitState.

/**
     * Resets this cipher while preserving the initialized state. This must be equivalent to
     * rolling back the cipher's state to just after the most recent {@code engineInit} completed
     * successfully.
     *
     * <p>Subclasses storing additional post-init state should override this method, reset the
     * additional state, and then chain to superclass.
     */
@CallSuper
protected void resetWhilePreservingInitState() {
    IBinder operationToken = mOperationToken;
    if (operationToken != null) {
        mOperationToken = null;
        mKeyStore.abort(operationToken);
    }
    mOperationHandle = 0;
    mMessageStreamer = null;
    mCachedException = null;
}
Also used : IBinder(android.os.IBinder) CallSuper(android.annotation.CallSuper)

Aggregations

IBinder (android.os.IBinder)991 RemoteException (android.os.RemoteException)494 Intent (android.content.Intent)141 ComponentName (android.content.ComponentName)128 ServiceConnection (android.content.ServiceConnection)94 Parcel (android.os.Parcel)91 Point (android.graphics.Point)67 PendingIntent (android.app.PendingIntent)60 IOException (java.io.IOException)53 UserHandle (android.os.UserHandle)50 Bundle (android.os.Bundle)40 Binder (android.os.Binder)37 Message (android.os.Message)37 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)34 AndroidRuntimeException (android.util.AndroidRuntimeException)33 Handler (android.os.Handler)31 ArrayList (java.util.ArrayList)27 IContentProvider (android.content.IContentProvider)25 TransactionTooLargeException (android.os.TransactionTooLargeException)25 OperationResult (android.security.keymaster.OperationResult)25