use of android.os.IBinder in project android_frameworks_base by ParanoidAndroid.
the class ActivityThread method handleRelaunchActivity.
private void handleRelaunchActivity(ActivityClientRecord tmp) {
// If we are getting ready to gc after going to the background, well
// we are back active so skip it.
unscheduleGcIdler();
Configuration changedConfig = null;
int configChanges = 0;
// had taken a more recent version.
synchronized (mPackages) {
int N = mRelaunchingActivities.size();
IBinder token = tmp.token;
tmp = null;
for (int i = 0; i < N; i++) {
ActivityClientRecord r = mRelaunchingActivities.get(i);
if (r.token == token) {
tmp = r;
configChanges |= tmp.pendingConfigChanges;
mRelaunchingActivities.remove(i);
i--;
N--;
}
}
if (tmp == null) {
if (DEBUG_CONFIGURATION)
Slog.v(TAG, "Abort, activity not relaunching!");
return;
}
if (DEBUG_CONFIGURATION)
Slog.v(TAG, "Relaunching activity " + tmp.token + " with configChanges=0x" + Integer.toHexString(configChanges));
if (mPendingConfiguration != null) {
changedConfig = mPendingConfiguration;
mPendingConfiguration = null;
}
}
if (tmp.createdConfig != null) {
// may have pending.
if (mConfiguration == null || (tmp.createdConfig.isOtherSeqNewer(mConfiguration) && mConfiguration.diff(tmp.createdConfig) != 0)) {
if (changedConfig == null || tmp.createdConfig.isOtherSeqNewer(changedConfig)) {
changedConfig = tmp.createdConfig;
}
}
}
if (DEBUG_CONFIGURATION)
Slog.v(TAG, "Relaunching activity " + tmp.token + ": changedConfig=" + changedConfig);
// If there was a pending configuration change, execute it first.
if (changedConfig != null) {
mCurDefaultDisplayDpi = changedConfig.densityDpi;
updateDefaultDensity();
handleConfigurationChanged(changedConfig, null);
}
ActivityClientRecord r = mActivities.get(tmp.token);
if (DEBUG_CONFIGURATION)
Slog.v(TAG, "Handling relaunch of " + r);
if (r == null) {
return;
}
r.activity.mConfigChangeFlags |= configChanges;
r.onlyLocalRequest = tmp.onlyLocalRequest;
Intent currentIntent = r.activity.mIntent;
r.activity.mChangingConfigurations = true;
// Need to ensure state is saved.
if (!r.paused) {
performPauseActivity(r.token, false, r.isPreHoneycomb());
}
if (r.state == null && !r.stopped && !r.isPreHoneycomb()) {
r.state = new Bundle();
r.state.setAllowFds(false);
mInstrumentation.callActivityOnSaveInstanceState(r.activity, r.state);
}
handleDestroyActivity(r.token, false, configChanges, true);
r.activity = null;
r.window = null;
r.hideForNow = false;
r.nextIdle = null;
// Merge any pending results and pending intents; don't just replace them
if (tmp.pendingResults != null) {
if (r.pendingResults == null) {
r.pendingResults = tmp.pendingResults;
} else {
r.pendingResults.addAll(tmp.pendingResults);
}
}
if (tmp.pendingIntents != null) {
if (r.pendingIntents == null) {
r.pendingIntents = tmp.pendingIntents;
} else {
r.pendingIntents.addAll(tmp.pendingIntents);
}
}
r.startsNotResumed = tmp.startsNotResumed;
handleLaunchActivity(r, currentIntent);
}
use of android.os.IBinder 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.IBinder in project android_frameworks_base by ParanoidAndroid.
the class ActivityThread method getPackageManager.
public static IPackageManager getPackageManager() {
if (sPackageManager != null) {
//Slog.v("PackageManager", "returning cur default = " + sPackageManager);
return sPackageManager;
}
IBinder b = ServiceManager.getService("package");
//Slog.v("PackageManager", "default service binder = " + b);
sPackageManager = IPackageManager.Stub.asInterface(b);
//Slog.v("PackageManager", "default service = " + sPackageManager);
return sPackageManager;
}
use of android.os.IBinder 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.IBinder in project android_frameworks_base by ParanoidAndroid.
the class ContextImpl method createDropBoxManager.
/* package */
static DropBoxManager createDropBoxManager() {
IBinder b = ServiceManager.getService(DROPBOX_SERVICE);
IDropBoxManagerService service = IDropBoxManagerService.Stub.asInterface(b);
if (service == null) {
// DROPBOX_SERVICE is registered.
return null;
}
return new DropBoxManager(service);
}
Aggregations