Search in sources :

Example 96 with IBinder

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

the class LocalReceiver method onReceive.

public void onReceive(Context context, Intent intent) {
    String resultString = LaunchpadActivity.RECEIVER_LOCAL;
    if (BroadcastTest.BROADCAST_FAIL_REGISTER.equals(intent.getAction())) {
        resultString = "Successfully registered, but expected it to fail";
        try {
            context.registerReceiver(this, new IntentFilter("foo.bar"));
            context.unregisterReceiver(this);
        } catch (ReceiverCallNotAllowedException e) {
            //resultString = "This is the correct behavior but not yet implemented";
            resultString = LaunchpadActivity.RECEIVER_LOCAL;
        }
    } else if (BroadcastTest.BROADCAST_FAIL_BIND.equals(intent.getAction())) {
        resultString = "Successfully bound to service, but expected it to fail";
        try {
            ServiceConnection sc = new ServiceConnection() {

                public void onServiceConnected(ComponentName name, IBinder service) {
                }

                public void onServiceDisconnected(ComponentName name) {
                }
            };
            context.bindService(new Intent(context, LocalService.class), sc, 0);
            context.unbindService(sc);
        } catch (ReceiverCallNotAllowedException e) {
            //resultString = "This is the correct behavior but not yet implemented";
            resultString = LaunchpadActivity.RECEIVER_LOCAL;
        }
    } else if (LaunchpadActivity.BROADCAST_REPEAT.equals(intent.getAction())) {
        Intent newIntent = new Intent(intent);
        newIntent.setAction(LaunchpadActivity.BROADCAST_LOCAL);
        context.sendOrderedBroadcast(newIntent, null);
    }
    try {
        IBinder caller = intent.getIBinderExtra("caller");
        Parcel data = Parcel.obtain();
        data.writeInterfaceToken(LaunchpadActivity.LAUNCH);
        data.writeString(resultString);
        caller.transact(LaunchpadActivity.GOT_RECEIVE_TRANSACTION, data, null, 0);
        data.recycle();
    } catch (RemoteException ex) {
    }
}
Also used : ReceiverCallNotAllowedException(android.content.ReceiverCallNotAllowedException) IntentFilter(android.content.IntentFilter) ServiceConnection(android.content.ServiceConnection) IBinder(android.os.IBinder) Parcel(android.os.Parcel) ComponentName(android.content.ComponentName) Intent(android.content.Intent) RemoteException(android.os.RemoteException)

Example 97 with IBinder

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

the class AbortReceiver method onReceive.

public void onReceive(Context context, Intent intent) {
    //Log.i("AbortReceiver", "onReceiveIntent!");
    try {
        IBinder caller = intent.getIBinderExtra("caller");
        Parcel data = Parcel.obtain();
        data.writeInterfaceToken(LaunchpadActivity.LAUNCH);
        data.writeString(LaunchpadActivity.RECEIVER_ABORT);
        caller.transact(LaunchpadActivity.GOT_RECEIVE_TRANSACTION, data, null, 0);
        data.recycle();
    } catch (RemoteException ex) {
    }
    // abort the broadcast!!!
    abortBroadcast();
}
Also used : IBinder(android.os.IBinder) Parcel(android.os.Parcel) RemoteException(android.os.RemoteException)

Example 98 with IBinder

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

the class RemoteDeniedReceiver method onReceive.

public void onReceive(Context context, Intent intent) {
    try {
        IBinder caller = intent.getIBinderExtra("caller");
        Parcel data = Parcel.obtain();
        data.writeInterfaceToken(LaunchpadActivity.LAUNCH);
        data.writeString(BroadcastTest.RECEIVER_REMOTE);
        caller.transact(BroadcastTest.GOT_RECEIVE_TRANSACTION, data, null, 0);
        data.recycle();
    } catch (RemoteException ex) {
    }
}
Also used : IBinder(android.os.IBinder) Parcel(android.os.Parcel) RemoteException(android.os.RemoteException)

Example 99 with IBinder

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

the class KeyChain method bindAsUser.

/**
     * @hide
     */
@WorkerThread
public static KeyChainConnection bindAsUser(@NonNull Context context, UserHandle user) throws InterruptedException {
    if (context == null) {
        throw new NullPointerException("context == null");
    }
    ensureNotOnMainThread(context);
    final BlockingQueue<IKeyChainService> q = new LinkedBlockingQueue<IKeyChainService>(1);
    ServiceConnection keyChainServiceConnection = new ServiceConnection() {

        volatile boolean mConnectedAtLeastOnce = false;

        @Override
        public void onServiceConnected(ComponentName name, IBinder service) {
            if (!mConnectedAtLeastOnce) {
                mConnectedAtLeastOnce = true;
                try {
                    q.put(IKeyChainService.Stub.asInterface(service));
                } catch (InterruptedException e) {
                // will never happen, since the queue starts with one available slot
                }
            }
        }

        @Override
        public void onServiceDisconnected(ComponentName name) {
        }
    };
    Intent intent = new Intent(IKeyChainService.class.getName());
    ComponentName comp = intent.resolveSystemService(context.getPackageManager(), 0);
    intent.setComponent(comp);
    if (comp == null || !context.bindServiceAsUser(intent, keyChainServiceConnection, Context.BIND_AUTO_CREATE, user)) {
        throw new AssertionError("could not bind to KeyChainService");
    }
    return new KeyChainConnection(context, keyChainServiceConnection, q.take());
}
Also used : ServiceConnection(android.content.ServiceConnection) IBinder(android.os.IBinder) ComponentName(android.content.ComponentName) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) LinkedBlockingQueue(java.util.concurrent.LinkedBlockingQueue) WorkerThread(android.annotation.WorkerThread)

Example 100 with IBinder

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

the class AndroidKeyStoreHmacSpi method resetWhilePreservingInitState.

private void resetWhilePreservingInitState() {
    IBinder operationToken = mOperationToken;
    if (operationToken != null) {
        mKeyStore.abort(operationToken);
    }
    mOperationToken = null;
    mOperationHandle = 0;
    mChunkedStreamer = null;
}
Also used : IBinder(android.os.IBinder)

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