Search in sources :

Example 21 with IBinder

use of android.os.IBinder in project android_frameworks_base by ParanoidAndroid.

the class ContentService method notifyChange.

/**
     * Notify observers of a particular user's view of the provider.
     * @param userHandle the user whose view of the provider is to be notified.  May be
     *     the calling user without requiring any permission, otherwise the caller needs to
     *     hold the INTERACT_ACROSS_USERS_FULL permission.  Pseudousers USER_ALL and
     *     USER_CURRENT are properly interpreted; no other pseudousers are allowed.
     */
@Override
public void notifyChange(Uri uri, IContentObserver observer, boolean observerWantsSelfNotifications, boolean syncToNetwork, int userHandle) {
    if (Log.isLoggable(TAG, Log.VERBOSE)) {
        Log.v(TAG, "Notifying update of " + uri + " for user " + userHandle + " from observer " + observer + ", syncToNetwork " + syncToNetwork);
    }
    // Notify for any user other than the caller's own requires permission.
    final int callingUserHandle = UserHandle.getCallingUserId();
    if (userHandle != callingUserHandle) {
        mContext.enforceCallingOrSelfPermission(Manifest.permission.INTERACT_ACROSS_USERS_FULL, "no permission to notify other users");
    }
    // We passed the permission check; resolve pseudouser targets as appropriate
    if (userHandle < 0) {
        if (userHandle == UserHandle.USER_CURRENT) {
            userHandle = ActivityManager.getCurrentUser();
        } else if (userHandle != UserHandle.USER_ALL) {
            throw new InvalidParameterException("Bad user handle for notifyChange: " + userHandle);
        }
    }
    final int uid = Binder.getCallingUid();
    // This makes it so that future permission checks will be in the context of this
    // process rather than the caller's process. We will restore this before returning.
    long identityToken = clearCallingIdentity();
    try {
        ArrayList<ObserverCall> calls = new ArrayList<ObserverCall>();
        synchronized (mRootNode) {
            mRootNode.collectObserversLocked(uri, 0, observer, observerWantsSelfNotifications, userHandle, calls);
        }
        final int numCalls = calls.size();
        for (int i = 0; i < numCalls; i++) {
            ObserverCall oc = calls.get(i);
            try {
                oc.mObserver.onChange(oc.mSelfChange, uri);
                if (Log.isLoggable(TAG, Log.VERBOSE)) {
                    Log.v(TAG, "Notified " + oc.mObserver + " of " + "update at " + uri);
                }
            } catch (RemoteException ex) {
                synchronized (mRootNode) {
                    Log.w(TAG, "Found dead observer, removing");
                    IBinder binder = oc.mObserver.asBinder();
                    final ArrayList<ObserverNode.ObserverEntry> list = oc.mNode.mObservers;
                    int numList = list.size();
                    for (int j = 0; j < numList; j++) {
                        ObserverNode.ObserverEntry oe = list.get(j);
                        if (oe.observer.asBinder() == binder) {
                            list.remove(j);
                            j--;
                            numList--;
                        }
                    }
                }
            }
        }
        if (syncToNetwork) {
            SyncManager syncManager = getSyncManager();
            if (syncManager != null) {
                syncManager.scheduleLocalSync(null, /* all accounts */
                callingUserHandle, uid, uri.getAuthority());
            }
        }
    } finally {
        restoreCallingIdentity(identityToken);
    }
}
Also used : InvalidParameterException(java.security.InvalidParameterException) IBinder(android.os.IBinder) ArrayList(java.util.ArrayList) RemoteException(android.os.RemoteException)

Example 22 with IBinder

use of android.os.IBinder in project android_frameworks_base by ParanoidAndroid.

the class InputManagerService method registerInputDevicesChangedListener.

// Binder call
@Override
public void registerInputDevicesChangedListener(IInputDevicesChangedListener listener) {
    if (listener == null) {
        throw new IllegalArgumentException("listener must not be null");
    }
    synchronized (mInputDevicesLock) {
        int callingPid = Binder.getCallingPid();
        if (mInputDevicesChangedListeners.get(callingPid) != null) {
            throw new SecurityException("The calling process has already " + "registered an InputDevicesChangedListener.");
        }
        InputDevicesChangedListenerRecord record = new InputDevicesChangedListenerRecord(callingPid, listener);
        try {
            IBinder binder = listener.asBinder();
            binder.linkToDeath(record, 0);
        } catch (RemoteException ex) {
            // give up
            throw new RuntimeException(ex);
        }
        mInputDevicesChangedListeners.put(callingPid, record);
    }
}
Also used : IBinder(android.os.IBinder) RemoteException(android.os.RemoteException)

Example 23 with IBinder

use of android.os.IBinder in project android_frameworks_base by ParanoidAndroid.

the class DisplayManagerService method registerCallback.

// Binder call
@Override
public void registerCallback(IDisplayManagerCallback callback) {
    if (callback == null) {
        throw new IllegalArgumentException("listener must not be null");
    }
    synchronized (mSyncRoot) {
        int callingPid = Binder.getCallingPid();
        if (mCallbacks.get(callingPid) != null) {
            throw new SecurityException("The calling process has already " + "registered an IDisplayManagerCallback.");
        }
        CallbackRecord record = new CallbackRecord(callingPid, callback);
        try {
            IBinder binder = callback.asBinder();
            binder.linkToDeath(record, 0);
        } catch (RemoteException ex) {
            // give up
            throw new RuntimeException(ex);
        }
        mCallbacks.put(callingPid, record);
    }
}
Also used : IBinder(android.os.IBinder) RemoteException(android.os.RemoteException)

Example 24 with IBinder

use of android.os.IBinder in project android_frameworks_base by ParanoidAndroid.

the class LocalDisplayAdapter method tryConnectDisplayLocked.

private void tryConnectDisplayLocked(int builtInDisplayId) {
    IBinder displayToken = SurfaceControl.getBuiltInDisplay(builtInDisplayId);
    if (displayToken != null && SurfaceControl.getDisplayInfo(displayToken, mTempPhys)) {
        LocalDisplayDevice device = mDevices.get(builtInDisplayId);
        if (device == null) {
            // Display was added.
            device = new LocalDisplayDevice(displayToken, builtInDisplayId, mTempPhys);
            mDevices.put(builtInDisplayId, device);
            sendDisplayDeviceEventLocked(device, DISPLAY_DEVICE_EVENT_ADDED);
        } else if (device.updatePhysicalDisplayInfoLocked(mTempPhys)) {
            // Display properties changed.
            sendDisplayDeviceEventLocked(device, DISPLAY_DEVICE_EVENT_CHANGED);
        }
    } else {
    // The display is no longer available. Ignore the attempt to add it.
    // If it was connected but has already been disconnected, we'll get a
    // disconnect event that will remove it from mDevices.
    }
}
Also used : IBinder(android.os.IBinder)

Example 25 with IBinder

use of android.os.IBinder in project android_frameworks_base by ParanoidAndroid.

the class PackageManagerService method getAssetRedirectionManager.

// NOTE: this method can return null if the SystemServer is still
// initializing
public IAssetRedirectionManager getAssetRedirectionManager() {
    if (mAssetRedirectionManager != null) {
        return mAssetRedirectionManager;
    }
    IBinder b = ServiceManager.getService("assetredirection");
    mAssetRedirectionManager = IAssetRedirectionManager.Stub.asInterface(b);
    return mAssetRedirectionManager;
}
Also used : IBinder(android.os.IBinder)

Aggregations

IBinder (android.os.IBinder)1139 RemoteException (android.os.RemoteException)553 Intent (android.content.Intent)186 ComponentName (android.content.ComponentName)166 ServiceConnection (android.content.ServiceConnection)127 Parcel (android.os.Parcel)112 PendingIntent (android.app.PendingIntent)69 Point (android.graphics.Point)67 Bundle (android.os.Bundle)56 IOException (java.io.IOException)53 UserHandle (android.os.UserHandle)50 Binder (android.os.Binder)47 Message (android.os.Message)37 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)35 Handler (android.os.Handler)33 AndroidRuntimeException (android.util.AndroidRuntimeException)33 ArrayList (java.util.ArrayList)30 IUsbManager (android.hardware.usb.IUsbManager)29 Context (android.content.Context)28 Messenger (android.os.Messenger)26