use of android.os.Binder in project android_frameworks_base by ParanoidAndroid.
the class StatusBarManagerService method addNotification.
// ================================================================================
// Callbacks for NotificationManagerService.
// ================================================================================
public IBinder addNotification(StatusBarNotification notification) {
synchronized (mNotifications) {
IBinder key = new Binder();
mNotifications.put(key, notification);
if (mBar != null) {
try {
mBar.addNotification(key, notification);
} catch (RemoteException ex) {
}
}
return key;
}
}
use of android.os.Binder in project android_frameworks_base by ParanoidAndroid.
the class DreamManagerService method startDreamLocked.
private void startDreamLocked(final ComponentName name, final boolean isTest, final int userId) {
if (Objects.equal(mCurrentDreamName, name) && mCurrentDreamIsTest == isTest && mCurrentDreamUserId == userId) {
return;
}
stopDreamLocked();
if (DEBUG)
Slog.i(TAG, "Entering dreamland.");
final Binder newToken = new Binder();
mCurrentDreamToken = newToken;
mCurrentDreamName = name;
mCurrentDreamIsTest = isTest;
mCurrentDreamUserId = userId;
mHandler.post(new Runnable() {
@Override
public void run() {
mController.startDream(newToken, name, isTest, userId);
}
});
}
use of android.os.Binder in project android_frameworks_base by ParanoidAndroid.
the class WindowManagerService method prepareDragSurface.
// -------------------------------------------------------------
// Drag and drop
// -------------------------------------------------------------
IBinder prepareDragSurface(IWindow window, SurfaceSession session, int flags, int width, int height, Surface outSurface) {
if (DEBUG_DRAG) {
Slog.d(TAG, "prepare drag surface: w=" + width + " h=" + height + " flags=" + Integer.toHexString(flags) + " win=" + window + " asbinder=" + window.asBinder());
}
final int callerPid = Binder.getCallingPid();
final long origId = Binder.clearCallingIdentity();
IBinder token = null;
try {
synchronized (mWindowMap) {
try {
if (mDragState == null) {
// TODO(multi-display): support other displays
final DisplayContent displayContent = getDefaultDisplayContentLocked();
final Display display = displayContent.getDisplay();
SurfaceControl surface = new SurfaceControl(session, "drag surface", width, height, PixelFormat.TRANSLUCENT, SurfaceControl.HIDDEN);
surface.setLayerStack(display.getLayerStack());
if (SHOW_TRANSACTIONS)
Slog.i(TAG, " DRAG " + surface + ": CREATE");
outSurface.copyFrom(surface);
final IBinder winBinder = window.asBinder();
token = new Binder();
mDragState = new DragState(this, token, surface, /*flags*/
0, winBinder);
token = mDragState.mToken = new Binder();
// 5 second timeout for this window to actually begin the drag
mH.removeMessages(H.DRAG_START_TIMEOUT, winBinder);
Message msg = mH.obtainMessage(H.DRAG_START_TIMEOUT, winBinder);
mH.sendMessageDelayed(msg, 5000);
} else {
Slog.w(TAG, "Drag already in progress");
}
} catch (SurfaceControl.OutOfResourcesException e) {
Slog.e(TAG, "Can't allocate drag surface w=" + width + " h=" + height, e);
if (mDragState != null) {
mDragState.reset();
mDragState = null;
}
}
}
} finally {
Binder.restoreCallingIdentity(origId);
}
return token;
}
use of android.os.Binder in project android_frameworks_base by ParanoidAndroid.
the class ServiceManagerPermissionTests method testAddService.
@SmallTest
public void testAddService() {
try {
// The security in the service manager is that you can't replace
// a service that is already published.
Binder binder = new Binder();
ServiceManager.addService("activity", binder);
fail("ServiceManager.addService did not throw SecurityException as" + " expected");
} catch (SecurityException e) {
// expected
}
}
use of android.os.Binder in project android_frameworks_base by ParanoidAndroid.
the class VibratorServicePermissionTest method testVibratePattern.
/**
* Test that calling {@link android.os.IVibratorService#vibratePattern(long[],
* int, android.os.IBinder)} requires permissions.
* <p>Tests permission:
* {@link android.Manifest.permission#VIBRATE}
* @throws RemoteException
*/
public void testVibratePattern() throws RemoteException {
try {
mVibratorService.vibratePattern(Process.myUid(), null, new long[] { 0 }, 0, new Binder());
fail("vibratePattern did not throw SecurityException as expected");
} catch (SecurityException e) {
// expected
}
}
Aggregations