use of com.android.server.AttributeCache in project cornerstone by Onskreen.
the class ActivityManagerService method forceConfigurationLocked.
/**
* Author: Onskreen
* Date: 05/01/2012
*
* Overload to act on a specific process to force the config for the given WindowPanel on the
* given ProcessRecord. Assumes using the current mCornerstone state
*/
public void forceConfigurationLocked(ActivityStack stack, ProcessRecord app) {
if (false) {
for (SparseArray<ProcessRecord> procs : mProcessNames.getMap().values()) {
final int NA = procs.size();
for (int ia = 0; ia < NA; ia++) {
ProcessRecord r = procs.valueAt(ia);
Slog.v(TAG, "PackageName: " + r.info.packageName);
Slog.v(TAG, "Process Name: " + r.processName);
Slog.v(TAG, "Activities: ");
for (ActivityRecord ar : r.activities) {
Slog.v(TAG, "\t" + ar);
}
Slog.v(TAG, "PID: " + r.pid);
Slog.v(TAG, "Package List: ");
for (String str : r.pkgList) {
Slog.v(TAG, "\t" + str);
}
Slog.v(TAG, "SystemNoUI: " + r.systemNoUi);
Slog.v(TAG, "ApplicationInfo.Uid: " + r.info.uid);
}
}
}
Configuration newConfig = new Configuration(mConfiguration);
if (DEBUG_SWITCH || DEBUG_CONFIGURATION) {
Slog.i(TAG, "Forcing configuration on: " + stack + " and Process: " + app);
}
mConfigurationSeq++;
if (mConfigurationSeq <= 0) {
mConfigurationSeq = 1;
}
newConfig.seq = mConfigurationSeq;
mConfiguration = newConfig;
Slog.i(TAG, "Config forced to change: " + newConfig);
final Configuration configCopy = new Configuration(mConfiguration);
AttributeCache ac = AttributeCache.instance();
if (ac != null) {
ac.updateConfiguration(configCopy);
}
try {
if (app.thread != null) {
//Default to main panel
WindowManagerService.WP_Panel panel = WindowManagerService.WP_Panel.MAIN_PANEL;
if (stack.mMainStack) {
panel = WindowManagerService.WP_Panel.MAIN_PANEL;
} else if (stack.mCornerstoneStack) {
panel = WindowManagerService.WP_Panel.CORNERSTONE;
} else if (stack.mCornerstonePanelStack) {
if (stack.mCornerstonePanelIndex == 0) {
panel = WindowManagerService.WP_Panel.CS_APP_0;
} else if (stack.mCornerstonePanelIndex == 1) {
panel = WindowManagerService.WP_Panel.CS_APP_1;
}
}
Configuration wpConfig = mWindowManager.computeWindowPanelConfiguration(panel);
mWindowManager.updateNonWindowPanelConfigurationFrom(wpConfig, mConfiguration);
if (DEBUG_CONFIGURATION)
Slog.v(TAG, "Sending to proc " + app.processName + " new config " + wpConfig);
app.thread.scheduleConfigurationChanged(wpConfig);
}
} catch (Exception e) {
}
Intent intent = new Intent(Intent.ACTION_CONFIGURATION_CHANGED);
intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY | Intent.FLAG_RECEIVER_REPLACE_PENDING);
broadcastIntentLocked(null, null, intent, null, null, 0, null, null, null, false, false, MY_PID, Process.SYSTEM_UID, 0);
ActivityRecord starting = stack.topRunningActivityLocked(null);
if (starting != null) {
boolean kept = stack.ensureActivityConfigurationLocked(starting, 0);
if (kept) {
// other activities are made visible.
if (DEBUG_SWITCH)
Slog.i(TAG, "Config didn't destroy " + starting + ", ensuring others are correct.");
//stack.ensureActivitiesVisibleLocked(starting, wpChanges);
stack.ensureActivitiesVisibleLocked(starting, 0);
}
}
if (mWindowManager != null) {
mWindowManager.setNewConfiguration(mConfiguration);
}
}
use of com.android.server.AttributeCache in project cornerstone by Onskreen.
the class ActivityManagerService method forceStopPackageLocked.
private final boolean forceStopPackageLocked(String name, int uid, boolean callerWillRestart, boolean purgeCache, boolean doit, boolean evenPersistent, int userId) {
int i;
int N;
if (uid < 0) {
try {
uid = AppGlobals.getPackageManager().getPackageUid(name, userId);
} catch (RemoteException e) {
}
}
if (doit) {
Slog.i(TAG, "Force stopping package " + name + " uid=" + uid);
Iterator<SparseArray<Long>> badApps = mProcessCrashTimes.getMap().values().iterator();
while (badApps.hasNext()) {
SparseArray<Long> ba = badApps.next();
if (ba.get(uid) != null) {
badApps.remove();
}
}
}
boolean didSomething = killPackageProcessesLocked(name, uid, -100, callerWillRestart, false, doit, evenPersistent, "force stop");
TaskRecord lastTask = null;
for (i = 0; i < mMainStack.mHistory.size(); i++) {
ActivityRecord r = (ActivityRecord) mMainStack.mHistory.get(i);
final boolean samePackage = r.packageName.equals(name);
if (r.userId == userId && (samePackage || r.task == lastTask) && (r.app == null || evenPersistent || !r.app.persistent)) {
if (!doit) {
if (r.finishing) {
// interesting as far as something to stop.
continue;
}
return true;
}
didSomething = true;
Slog.i(TAG, " Force finishing activity " + r);
if (samePackage) {
if (r.app != null) {
r.app.removed = true;
}
r.app = null;
}
lastTask = r.task;
if (r.stack.finishActivityLocked(r, i, Activity.RESULT_CANCELED, null, "force-stop", true)) {
i--;
}
}
}
/**
* Author: Onskreen
* Date: 27/01/2011
*
* Mirroing logic in cornerstone.
*/
for (i = mCornerstoneStack.mHistory.size() - 1; i >= 0; i--) {
ActivityRecord r = (ActivityRecord) mCornerstoneStack.mHistory.get(i);
if (r.packageName.equals(name)) {
if (!doit) {
return true;
}
didSomething = true;
Slog.i(TAG, " Force finishing activity " + r);
if (r.app != null) {
r.app.removed = true;
}
r.app = null;
r.stack.finishActivityLocked(r, i, Activity.RESULT_CANCELED, null, "uninstall");
}
}
ArrayList<ServiceRecord> services = new ArrayList<ServiceRecord>();
for (ServiceRecord service : mServiceMap.getAllServices(userId)) {
if (service.packageName.equals(name) && (service.app == null || evenPersistent || !service.app.persistent)) {
if (!doit) {
return true;
}
didSomething = true;
Slog.i(TAG, " Force stopping service " + service);
if (service.app != null) {
service.app.removed = true;
}
service.app = null;
service.isolatedProc = null;
services.add(service);
}
}
N = services.size();
for (i = 0; i < N; i++) {
bringDownServiceLocked(services.get(i), true);
}
ArrayList<ContentProviderRecord> providers = new ArrayList<ContentProviderRecord>();
for (ContentProviderRecord provider : mProviderMap.getProvidersByClass(userId).values()) {
if (provider.info.packageName.equals(name) && (provider.proc == null || evenPersistent || !provider.proc.persistent)) {
if (!doit) {
return true;
}
didSomething = true;
providers.add(provider);
}
}
N = providers.size();
for (i = 0; i < N; i++) {
removeDyingProviderLocked(null, providers.get(i), true);
}
if (doit) {
if (purgeCache) {
AttributeCache ac = AttributeCache.instance();
if (ac != null) {
ac.removePackage(name);
}
}
if (mBooted) {
mMainStack.resumeTopActivityLocked(null);
mMainStack.scheduleIdleLocked();
/**
* Author: Onskreen
* Date: 27/01/2011
*
* Mirroing logic in cornerstone.
*/
mCornerstoneStack.resumeTopActivityLocked(null);
mCornerstoneStack.scheduleIdleLocked();
}
}
return didSomething;
}
use of com.android.server.AttributeCache in project android_frameworks_base by ParanoidAndroid.
the class ActivityManagerService method updateConfigurationLocked.
/**
* Do either or both things: (1) change the current configuration, and (2)
* make sure the given activity is running with the (now) current
* configuration. Returns true if the activity has been left running, or
* false if <var>starting</var> is being destroyed to match the new
* configuration.
* @param persistent TODO
*/
boolean updateConfigurationLocked(Configuration values, ActivityRecord starting, boolean persistent, boolean initLocale) {
// do nothing if we are headless
if (mHeadless)
return true;
int changes = 0;
boolean kept = true;
if (values != null) {
Configuration newConfig = new Configuration(mConfiguration);
changes = newConfig.updateFrom(values);
if (changes != 0) {
if (DEBUG_SWITCH || DEBUG_CONFIGURATION) {
Slog.i(TAG, "Updating configuration to: " + values);
}
EventLog.writeEvent(EventLogTags.CONFIGURATION_CHANGED, changes);
if (values.locale != null && !initLocale) {
saveLocaleLocked(values.locale, !values.locale.equals(mConfiguration.locale), values.userSetLocale);
}
if (values.customTheme != null) {
saveThemeResourceLocked(values.customTheme, !values.customTheme.equals(mConfiguration.customTheme));
}
mConfigurationSeq++;
if (mConfigurationSeq <= 0) {
mConfigurationSeq = 1;
}
newConfig.seq = mConfigurationSeq;
mConfiguration = newConfig;
Slog.i(TAG, "Config changes=" + Integer.toHexString(changes) + " " + newConfig);
final Configuration configCopy = new Configuration(mConfiguration);
// TODO: If our config changes, should we auto dismiss any currently
// showing dialogs?
mShowDialogs = shouldShowDialogs(newConfig);
AttributeCache ac = AttributeCache.instance();
if (ac != null) {
ac.updateConfiguration(configCopy);
}
// Make sure all resources in our process are updated
// right now, so that anyone who is going to retrieve
// resource values after we return will be sure to get
// the new ones. This is especially important during
// boot, where the first config change needs to guarantee
// all resources have that config before following boot
// code is executed.
mSystemThread.applyConfigurationToResources(configCopy);
if (persistent && Settings.System.hasInterestingConfigurationChanges(changes)) {
Message msg = mHandler.obtainMessage(UPDATE_CONFIGURATION_MSG);
msg.obj = new Configuration(configCopy);
mHandler.sendMessage(msg);
}
for (int i = mLruProcesses.size() - 1; i >= 0; i--) {
ProcessRecord app = mLruProcesses.get(i);
try {
if (app.thread != null) {
if (DEBUG_CONFIGURATION)
Slog.v(TAG, "Sending to proc " + app.processName + " new config " + mConfiguration);
app.thread.scheduleConfigurationChanged(configCopy);
}
} catch (Exception e) {
}
}
Intent intent = new Intent(Intent.ACTION_CONFIGURATION_CHANGED);
intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY | Intent.FLAG_RECEIVER_REPLACE_PENDING | Intent.FLAG_RECEIVER_FOREGROUND);
broadcastIntentLocked(null, null, intent, null, null, 0, null, null, null, AppOpsManager.OP_NONE, false, false, MY_PID, Process.SYSTEM_UID, UserHandle.USER_ALL);
if ((changes & ActivityInfo.CONFIG_LOCALE) != 0) {
intent = new Intent(Intent.ACTION_LOCALE_CHANGED);
intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
broadcastIntentLocked(null, null, intent, null, null, 0, null, null, null, AppOpsManager.OP_NONE, false, false, MY_PID, Process.SYSTEM_UID, UserHandle.USER_ALL);
}
}
}
if (changes != 0 && starting == null) {
// If the configuration changed, and the caller is not already
// in the process of starting an activity, then find the top
// activity to check if its configuration needs to change.
starting = mMainStack.topRunningActivityLocked(null);
}
if (starting != null) {
kept = mMainStack.ensureActivityConfigurationLocked(starting, changes);
// And we need to make sure at this point that all other activities
// are made visible with the correct configuration.
mMainStack.ensureActivitiesVisibleLocked(starting, changes);
}
if (values != null && mWindowManager != null) {
mWindowManager.setNewConfiguration(mConfiguration);
}
return kept;
}
use of com.android.server.AttributeCache in project android_frameworks_base by ParanoidAndroid.
the class ActivityManagerService method forceStopPackageLocked.
private final boolean forceStopPackageLocked(String name, int appId, boolean callerWillRestart, boolean purgeCache, boolean doit, boolean evenPersistent, int userId) {
int i;
int N;
if (userId == UserHandle.USER_ALL && name == null) {
Slog.w(TAG, "Can't force stop all processes of all users, that is insane!");
}
if (appId < 0 && name != null) {
try {
appId = UserHandle.getAppId(AppGlobals.getPackageManager().getPackageUid(name, 0));
} catch (RemoteException e) {
}
}
if (doit) {
if (name != null) {
Slog.i(TAG, "Force stopping package " + name + " appid=" + appId + " user=" + userId);
} else {
Slog.i(TAG, "Force stopping user " + userId);
}
Iterator<SparseArray<Long>> badApps = mProcessCrashTimes.getMap().values().iterator();
while (badApps.hasNext()) {
SparseArray<Long> ba = badApps.next();
for (i = ba.size() - 1; i >= 0; i--) {
boolean remove = false;
final int entUid = ba.keyAt(i);
if (name != null) {
if (userId == UserHandle.USER_ALL) {
if (UserHandle.getAppId(entUid) == appId) {
remove = true;
}
} else {
if (entUid == UserHandle.getUid(userId, appId)) {
remove = true;
}
}
} else if (UserHandle.getUserId(entUid) == userId) {
remove = true;
}
if (remove) {
ba.removeAt(i);
}
}
if (ba.size() == 0) {
badApps.remove();
}
}
}
boolean didSomething = killPackageProcessesLocked(name, appId, userId, -100, callerWillRestart, true, doit, evenPersistent, name == null ? ("force stop user " + userId) : ("force stop " + name));
TaskRecord lastTask = null;
for (i = 0; i < mMainStack.mHistory.size(); i++) {
ActivityRecord r = (ActivityRecord) mMainStack.mHistory.get(i);
final boolean samePackage = r.packageName.equals(name) || (name == null && r.userId == userId);
if ((userId == UserHandle.USER_ALL || r.userId == userId) && (samePackage || r.task == lastTask) && (r.app == null || evenPersistent || !r.app.persistent)) {
if (!doit) {
if (r.finishing) {
// interesting as far as something to stop.
continue;
}
return true;
}
didSomething = true;
Slog.i(TAG, " Force finishing activity " + r);
if (samePackage) {
if (r.app != null) {
r.app.removed = true;
}
r.app = null;
}
lastTask = r.task;
if (r.stack.finishActivityLocked(r, i, Activity.RESULT_CANCELED, null, "force-stop", true)) {
i--;
}
}
}
if (mServices.forceStopLocked(name, userId, evenPersistent, doit)) {
if (!doit) {
return true;
}
didSomething = true;
}
if (name == null) {
// Remove all sticky broadcasts from this user.
mStickyBroadcasts.remove(userId);
}
ArrayList<ContentProviderRecord> providers = new ArrayList<ContentProviderRecord>();
if (mProviderMap.collectForceStopProviders(name, appId, doit, evenPersistent, userId, providers)) {
if (!doit) {
return true;
}
didSomething = true;
}
N = providers.size();
for (i = 0; i < N; i++) {
removeDyingProviderLocked(null, providers.get(i), true);
}
if (name == null) {
// such packages, so they can be left with bad pending intents.
if (mIntentSenderRecords.size() > 0) {
Iterator<WeakReference<PendingIntentRecord>> it = mIntentSenderRecords.values().iterator();
while (it.hasNext()) {
WeakReference<PendingIntentRecord> wpir = it.next();
if (wpir == null) {
it.remove();
continue;
}
PendingIntentRecord pir = wpir.get();
if (pir == null) {
it.remove();
continue;
}
if (name == null) {
// Stopping user, remove all objects for the user.
if (pir.key.userId != userId) {
// Not the same user, skip it.
continue;
}
} else {
if (UserHandle.getAppId(pir.uid) != appId) {
// Different app id, skip it.
continue;
}
if (userId != UserHandle.USER_ALL && pir.key.userId != userId) {
// Different user, skip it.
continue;
}
if (!pir.key.packageName.equals(name)) {
// Different package, skip it.
continue;
}
}
if (!doit) {
return true;
}
didSomething = true;
it.remove();
pir.canceled = true;
if (pir.key.activity != null) {
pir.key.activity.pendingResults.remove(pir.ref);
}
}
}
}
if (doit) {
if (purgeCache && name != null) {
AttributeCache ac = AttributeCache.instance();
if (ac != null) {
ac.removePackage(name);
}
}
if (mBooted) {
mMainStack.resumeTopActivityLocked(null);
mMainStack.scheduleIdleLocked();
}
}
return didSomething;
}
use of com.android.server.AttributeCache in project android_frameworks_base by DirtyUnicorns.
the class ActivityManagerService method forceStopPackageLocked.
final boolean forceStopPackageLocked(String packageName, int appId, boolean callerWillRestart, boolean purgeCache, boolean doit, boolean evenPersistent, boolean uninstalling, int userId, String reason) {
int i;
if (userId == UserHandle.USER_ALL && packageName == null) {
Slog.w(TAG, "Can't force stop all processes of all users, that is insane!");
}
if (appId < 0 && packageName != null) {
try {
appId = UserHandle.getAppId(AppGlobals.getPackageManager().getPackageUid(packageName, MATCH_DEBUG_TRIAGED_MISSING, 0));
} catch (RemoteException e) {
}
}
if (doit) {
if (packageName != null) {
Slog.i(TAG, "Force stopping " + packageName + " appid=" + appId + " user=" + userId + ": " + reason);
} else {
Slog.i(TAG, "Force stopping u" + userId + ": " + reason);
}
mAppErrors.resetProcessCrashTimeLocked(packageName == null, appId, userId);
}
boolean didSomething = killPackageProcessesLocked(packageName, appId, userId, ProcessList.INVALID_ADJ, callerWillRestart, true, doit, evenPersistent, packageName == null ? ("stop user " + userId) : ("stop " + packageName));
didSomething |= mActivityStarter.clearPendingActivityLaunchesLocked(packageName);
if (mStackSupervisor.finishDisabledPackageActivitiesLocked(packageName, null, doit, evenPersistent, userId)) {
if (!doit) {
return true;
}
didSomething = true;
}
if (mServices.bringDownDisabledPackageServicesLocked(packageName, null, userId, evenPersistent, true, doit)) {
if (!doit) {
return true;
}
didSomething = true;
}
if (packageName == null) {
// Remove all sticky broadcasts from this user.
mStickyBroadcasts.remove(userId);
}
ArrayList<ContentProviderRecord> providers = new ArrayList<>();
if (mProviderMap.collectPackageProvidersLocked(packageName, null, doit, evenPersistent, userId, providers)) {
if (!doit) {
return true;
}
didSomething = true;
}
for (i = providers.size() - 1; i >= 0; i--) {
removeDyingProviderLocked(null, providers.get(i), true);
}
// Remove transient permissions granted from/to this package/user
removeUriPermissionsForPackageLocked(packageName, userId, false);
if (doit) {
for (i = mBroadcastQueues.length - 1; i >= 0; i--) {
didSomething |= mBroadcastQueues[i].cleanupDisabledPackageReceiversLocked(packageName, null, userId, doit);
}
}
if (packageName == null || uninstalling) {
// such packages, so they can be left with bad pending intents.
if (mIntentSenderRecords.size() > 0) {
Iterator<WeakReference<PendingIntentRecord>> it = mIntentSenderRecords.values().iterator();
while (it.hasNext()) {
WeakReference<PendingIntentRecord> wpir = it.next();
if (wpir == null) {
it.remove();
continue;
}
PendingIntentRecord pir = wpir.get();
if (pir == null) {
it.remove();
continue;
}
if (packageName == null) {
// Stopping user, remove all objects for the user.
if (pir.key.userId != userId) {
// Not the same user, skip it.
continue;
}
} else {
if (UserHandle.getAppId(pir.uid) != appId) {
// Different app id, skip it.
continue;
}
if (userId != UserHandle.USER_ALL && pir.key.userId != userId) {
// Different user, skip it.
continue;
}
if (!pir.key.packageName.equals(packageName)) {
// Different package, skip it.
continue;
}
}
if (!doit) {
return true;
}
didSomething = true;
it.remove();
pir.canceled = true;
if (pir.key.activity != null && pir.key.activity.pendingResults != null) {
pir.key.activity.pendingResults.remove(pir.ref);
}
}
}
}
if (doit) {
if (purgeCache && packageName != null) {
AttributeCache ac = AttributeCache.instance();
if (ac != null) {
ac.removePackage(packageName);
}
}
if (mBooted) {
mStackSupervisor.resumeFocusedStackTopActivityLocked();
mStackSupervisor.scheduleIdleLocked();
}
}
return didSomething;
}
Aggregations