Search in sources :

Example 91 with IBinder

use of android.os.IBinder in project XobotOS by xamarin.

the class ActivityThread method acquireExistingProvider.

public final IContentProvider acquireExistingProvider(Context c, String name) {
    IContentProvider provider = getExistingProvider(c, name);
    if (provider == null)
        return null;
    IBinder jBinder = provider.asBinder();
    synchronized (mProviderMap) {
        ProviderRefCount prc = mProviderRefCountMap.get(jBinder);
        if (prc == null) {
            mProviderRefCountMap.put(jBinder, new ProviderRefCount(1));
        } else {
            prc.count++;
        }
    //end else
    }
    //end synchronized
    return provider;
}
Also used : IBinder(android.os.IBinder) IContentProvider(android.content.IContentProvider)

Example 92 with IBinder

use of android.os.IBinder in project XobotOS by xamarin.

the class ActivityThread method handleCreateBackupAgent.

// Instantiate a BackupAgent and tell it that it's alive
private void handleCreateBackupAgent(CreateBackupAgentData data) {
    if (DEBUG_BACKUP)
        Slog.v(TAG, "handleCreateBackupAgent: " + data);
    // no longer idle; we have backup work to do
    unscheduleGcIdler();
    // instantiate the BackupAgent class named in the manifest
    LoadedApk packageInfo = getPackageInfoNoCheck(data.appInfo, data.compatInfo);
    String packageName = packageInfo.mPackageName;
    if (mBackupAgents.get(packageName) != null) {
        Slog.d(TAG, "BackupAgent " + "  for " + packageName + " already exists");
        return;
    }
    BackupAgent agent = null;
    String classname = data.appInfo.backupAgentName;
    // full backup operation but no app-supplied agent?  use the default implementation
    if (classname == null && (data.backupMode == IApplicationThread.BACKUP_MODE_FULL || data.backupMode == IApplicationThread.BACKUP_MODE_RESTORE_FULL)) {
        classname = "android.app.backup.FullBackupAgent";
    }
    try {
        IBinder binder = null;
        try {
            if (DEBUG_BACKUP)
                Slog.v(TAG, "Initializing agent class " + classname);
            java.lang.ClassLoader cl = packageInfo.getClassLoader();
            agent = (BackupAgent) cl.loadClass(classname).newInstance();
            // set up the agent's context
            ContextImpl context = new ContextImpl();
            context.init(packageInfo, null, this);
            context.setOuterContext(agent);
            agent.attach(context);
            agent.onCreate();
            binder = agent.onBind();
            mBackupAgents.put(packageName, agent);
        } catch (Exception e) {
            // If this is during restore, fail silently; otherwise go
            // ahead and let the user see the crash.
            Slog.e(TAG, "Agent threw during creation: " + e);
            if (data.backupMode != IApplicationThread.BACKUP_MODE_RESTORE && data.backupMode != IApplicationThread.BACKUP_MODE_RESTORE_FULL) {
                throw e;
            }
        // falling through with 'binder' still null
        }
        // tell the OS that we're live now
        try {
            ActivityManagerNative.getDefault().backupAgentCreated(packageName, binder);
        } catch (RemoteException e) {
        // nothing to do.
        }
    } catch (Exception e) {
        throw new RuntimeException("Unable to create BackupAgent " + classname + ": " + e.toString(), e);
    }
}
Also used : IBinder(android.os.IBinder) AndroidRuntimeException(android.util.AndroidRuntimeException) BackupAgent(android.app.backup.BackupAgent) RemoteException(android.os.RemoteException) AndroidRuntimeException(android.util.AndroidRuntimeException) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) RemoteException(android.os.RemoteException) IOException(java.io.IOException)

Example 93 with IBinder

use of android.os.IBinder in project XobotOS by xamarin.

the class ActivityThread method releaseProvider.

public final boolean releaseProvider(IContentProvider provider) {
    if (provider == null) {
        return false;
    }
    IBinder jBinder = provider.asBinder();
    synchronized (mProviderMap) {
        ProviderRefCount prc = mProviderRefCountMap.get(jBinder);
        if (prc == null) {
            if (localLOGV)
                Slog.v(TAG, "releaseProvider::Weird shouldn't be here");
            return false;
        } else {
            prc.count--;
            if (prc.count == 0) {
                // Schedule the actual remove asynchronously, since we
                // don't know the context this will be called in.
                // TODO: it would be nice to post a delayed message, so
                // if we come back and need the same provider quickly
                // we will still have it available.
                Message msg = mH.obtainMessage(H.REMOVE_PROVIDER, provider);
                mH.sendMessage(msg);
            }
        //end if
        }
    //end else
    }
    //end synchronized
    return true;
}
Also used : IBinder(android.os.IBinder) Message(android.os.Message)

Example 94 with IBinder

use of android.os.IBinder in project XobotOS by xamarin.

the class WifiP2pService method connectivityServiceReady.

public void connectivityServiceReady() {
    IBinder b = ServiceManager.getService(Context.NETWORKMANAGEMENT_SERVICE);
    mNwService = INetworkManagementService.Stub.asInterface(b);
}
Also used : IBinder(android.os.IBinder)

Example 95 with IBinder

use of android.os.IBinder in project XobotOS by xamarin.

the class AudioService method registerRemoteControlClient.

/**
     * see AudioManager.registerRemoteControlClient(ComponentName eventReceiver, ...)
     * Note: using this method with rcClient == null is a way to "disable" the IRemoteControlClient
     *     without modifying the RC stack, but while still causing the display to refresh (will
     *     become blank as a result of this)
     */
public void registerRemoteControlClient(PendingIntent mediaIntent, IRemoteControlClient rcClient, String callingPackageName) {
    if (DEBUG_RC)
        Log.i(TAG, "Register remote control client rcClient=" + rcClient);
    synchronized (mAudioFocusLock) {
        synchronized (mRCStack) {
            // store the new display information
            Iterator<RemoteControlStackEntry> stackIterator = mRCStack.iterator();
            while (stackIterator.hasNext()) {
                RemoteControlStackEntry rcse = stackIterator.next();
                if (rcse.mMediaIntent.equals(mediaIntent)) {
                    // already had a remote control client?
                    if (rcse.mRcClientDeathHandler != null) {
                        // stop monitoring the old client's death
                        rcse.unlinkToRcClientDeath();
                    }
                    // save the new remote control client
                    rcse.mRcClient = rcClient;
                    rcse.mCallingPackageName = callingPackageName;
                    rcse.mCallingUid = Binder.getCallingUid();
                    if (rcClient == null) {
                        rcse.mRcClientDeathHandler = null;
                        break;
                    }
                    // 1/ give the new client the current display (if any)
                    if (mRcDisplay != null) {
                        try {
                            rcse.mRcClient.plugRemoteControlDisplay(mRcDisplay);
                        } catch (RemoteException e) {
                            Log.e(TAG, "Error connecting remote control display to client: " + e);
                            e.printStackTrace();
                        }
                    }
                    // 2/ monitor the new client's death
                    IBinder b = rcse.mRcClient.asBinder();
                    RcClientDeathHandler rcdh = new RcClientDeathHandler(b, rcse.mMediaIntent);
                    try {
                        b.linkToDeath(rcdh, 0);
                    } catch (RemoteException e) {
                        // remote control client is DOA, disqualify it
                        Log.w(TAG, "registerRemoteControlClient() has a dead client " + b);
                        rcse.mRcClient = null;
                    }
                    rcse.mRcClientDeathHandler = rcdh;
                    break;
                }
            }
            // then check for potential refresh of the remote controls
            if (isCurrentRcController(mediaIntent)) {
                checkUpdateRemoteControlDisplay_syncAfRcs(RC_INFO_ALL);
            }
        }
    }
}
Also used : IBinder(android.os.IBinder) RemoteException(android.os.RemoteException)

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