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) {
}
}
}
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);
}
}
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
}
}
}
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);
}
}
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) {
}
}
Aggregations