Search in sources :

Example 26 with RemoteException

use of android.os.RemoteException in project android_frameworks_base by ParanoidAndroid.

the class AppOpsManager method startWatchingMode.

public void startWatchingMode(int op, String packageName, final Callback callback) {
    synchronized (mModeWatchers) {
        IAppOpsCallback cb = mModeWatchers.get(callback);
        if (cb == null) {
            cb = new IAppOpsCallback.Stub() {

                public void opChanged(int op, String packageName) {
                    callback.opChanged(op, packageName);
                }
            };
            mModeWatchers.put(callback, cb);
        }
        try {
            mService.startWatchingMode(op, packageName, cb);
        } catch (RemoteException e) {
        }
    }
}
Also used : IAppOpsCallback(com.android.internal.app.IAppOpsCallback) RemoteException(android.os.RemoteException)

Example 27 with RemoteException

use of android.os.RemoteException in project android_frameworks_base by ParanoidAndroid.

the class ApplicationPackageManager method queryIntentActivityOptions.

@Override
public List<ResolveInfo> queryIntentActivityOptions(ComponentName caller, Intent[] specifics, Intent intent, int flags) {
    final ContentResolver resolver = mContext.getContentResolver();
    String[] specificTypes = null;
    if (specifics != null) {
        final int N = specifics.length;
        for (int i = 0; i < N; i++) {
            Intent sp = specifics[i];
            if (sp != null) {
                String t = sp.resolveTypeIfNeeded(resolver);
                if (t != null) {
                    if (specificTypes == null) {
                        specificTypes = new String[N];
                    }
                    specificTypes[i] = t;
                }
            }
        }
    }
    try {
        return mPM.queryIntentActivityOptions(caller, specifics, specificTypes, intent, intent.resolveTypeIfNeeded(resolver), flags, mContext.getUserId());
    } catch (RemoteException e) {
        throw new RuntimeException("Package manager has died", e);
    }
}
Also used : Intent(android.content.Intent) RemoteException(android.os.RemoteException) ContentResolver(android.content.ContentResolver)

Example 28 with RemoteException

use of android.os.RemoteException in project android_frameworks_base by ParanoidAndroid.

the class ActivityThread method completeRemoveProvider.

final void completeRemoveProvider(ProviderRefCount prc) {
    synchronized (mProviderMap) {
        if (!prc.removePending) {
            // Abort the removal.  We will do it later.
            if (DEBUG_PROVIDER)
                Slog.v(TAG, "completeRemoveProvider: lost the race, " + "provider still in use");
            return;
        }
        // More complicated race!! Some client managed to acquire the
        // provider and release it before the removal was completed.
        // Continue the removal, and abort the next remove message.
        prc.removePending = false;
        final IBinder jBinder = prc.holder.provider.asBinder();
        ProviderRefCount existingPrc = mProviderRefCountMap.get(jBinder);
        if (existingPrc == prc) {
            mProviderRefCountMap.remove(jBinder);
        }
        Iterator<ProviderClientRecord> iter = mProviderMap.values().iterator();
        while (iter.hasNext()) {
            ProviderClientRecord pr = iter.next();
            IBinder myBinder = pr.mProvider.asBinder();
            if (myBinder == jBinder) {
                iter.remove();
            }
        }
        try {
            if (DEBUG_PROVIDER) {
                Slog.v(TAG, "removeProvider: Invoking ActivityManagerNative." + "removeContentProvider(" + prc.holder.info.name + ")");
            }
            ActivityManagerNative.getDefault().removeContentProvider(prc.holder.connection, false);
        } catch (RemoteException e) {
        //do nothing content provider object is dead any way
        }
    }
}
Also used : IBinder(android.os.IBinder) RemoteException(android.os.RemoteException)

Example 29 with RemoteException

use of android.os.RemoteException in project android_frameworks_base by ParanoidAndroid.

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);
    // Sanity check the requested target package's uid against ours
    try {
        PackageInfo requestedPackage = getPackageManager().getPackageInfo(data.appInfo.packageName, 0, UserHandle.myUserId());
        if (requestedPackage.applicationInfo.uid != Process.myUid()) {
            Slog.w(TAG, "Asked to instantiate non-matching package " + data.appInfo.packageName);
            return;
        }
    } catch (RemoteException e) {
        Slog.e(TAG, "Can't reach package manager", e);
        return;
    }
    // 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 (packageName == null) {
        Slog.d(TAG, "Asked to create backup agent for nonexistent package");
        return;
    }
    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) PackageInfo(android.content.pm.PackageInfo) BackupAgent(android.app.backup.BackupAgent) RemoteException(android.os.RemoteException) java.lang(java.lang) InflateException(android.view.InflateException) RemoteException(android.os.RemoteException) IOException(java.io.IOException) AndroidRuntimeException(android.util.AndroidRuntimeException) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException)

Example 30 with RemoteException

use of android.os.RemoteException in project android_frameworks_base by ParanoidAndroid.

the class ContextImpl method removeStickyBroadcastAsUser.

@Override
public void removeStickyBroadcastAsUser(Intent intent, UserHandle user) {
    String resolvedType = intent.resolveTypeIfNeeded(getContentResolver());
    if (resolvedType != null) {
        intent = new Intent(intent);
        intent.setDataAndType(intent.getData(), resolvedType);
    }
    try {
        intent.prepareToLeaveProcess();
        ActivityManagerNative.getDefault().unbroadcastIntent(mMainThread.getApplicationThread(), intent, user.getIdentifier());
    } catch (RemoteException e) {
    }
}
Also used : Intent(android.content.Intent) RemoteException(android.os.RemoteException)

Aggregations

RemoteException (android.os.RemoteException)4527 Intent (android.content.Intent)595 IBinder (android.os.IBinder)480 Bundle (android.os.Bundle)461 Point (android.graphics.Point)423 IOException (java.io.IOException)381 PendingIntent (android.app.PendingIntent)274 ComponentName (android.content.ComponentName)265 ArrayList (java.util.ArrayList)248 ApplicationInfo (android.content.pm.ApplicationInfo)190 IPackageManager (android.content.pm.IPackageManager)190 Message (android.os.Message)184 Uri (android.net.Uri)157 UserHandle (android.os.UserHandle)154 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)151 Cursor (android.database.Cursor)150 Configuration (android.content.res.Configuration)133 UserInfo (android.content.pm.UserInfo)129 AndroidRuntimeException (android.util.AndroidRuntimeException)128 ParcelFileDescriptor (android.os.ParcelFileDescriptor)126