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);
}
}
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);
}
}
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);
}
}
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.
}
}
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;
}
Aggregations