Search in sources :

Example 1 with Binder

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;
    }
}
Also used : IBinder(android.os.IBinder) Binder(android.os.Binder) IBinder(android.os.IBinder) RemoteException(android.os.RemoteException)

Example 2 with Binder

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);
        }
    });
}
Also used : IBinder(android.os.IBinder) Binder(android.os.Binder)

Example 3 with Binder

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;
}
Also used : IBinder(android.os.IBinder) Binder(android.os.Binder) IBinder(android.os.IBinder) Message(android.os.Message) SurfaceControl(android.view.SurfaceControl) Point(android.graphics.Point) Display(android.view.Display)

Example 4 with Binder

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
    }
}
Also used : Binder(android.os.Binder) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 5 with Binder

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
    }
}
Also used : Binder(android.os.Binder)

Aggregations

Binder (android.os.Binder)192 IBinder (android.os.IBinder)105 RemoteException (android.os.RemoteException)50 Intent (android.content.Intent)24 Test (org.junit.Test)23 SmallTest (android.support.test.filters.SmallTest)20 ComponentName (android.content.ComponentName)18 ParcelFileDescriptor (android.os.ParcelFileDescriptor)17 IActivityManager (android.app.IActivityManager)11 ContentProviderHolder (android.app.IActivityManager.ContentProviderHolder)11 IContentProvider (android.content.IContentProvider)11 SmallTest (android.test.suitebuilder.annotation.SmallTest)10 Parcel (android.os.Parcel)9 Point (android.graphics.Point)7 Bundle (android.os.Bundle)7 PendingIntent (android.app.PendingIntent)6 Looper (android.os.Looper)6 Message (android.os.Message)6 Messenger (android.os.Messenger)6 InputMethodInfo (android.view.inputmethod.InputMethodInfo)6