summaryrefslogtreecommitdiff
path: root/core/java/android/app/ActivityThread.java
diff options
context:
space:
mode:
authorRomain Guy <romainguy@google.com>2012-03-23 18:58:36 -0700
committerRomain Guy <romainguy@google.com>2012-03-23 19:04:36 -0700
commita998dff5d49a423aaf7097aa8f96bf5bdc681d25 (patch)
treea76c4185a5c57c4f2e4aa423845b7e42bc59fe83 /core/java/android/app/ActivityThread.java
parent5d6999e1ca457948e06792ea6259ffa947c9fa81 (diff)
Destroy the hardware renderer when ViewRootImpl's die is post-poned
Bug #6109035 ViewRootImpl.die() can be invoked in such a way that doDie() will be executed later. On memory limited device, an eglTerminate() may happen before doDie() is executed which leads to unstable behaviors. This change makes sure the renderer is destroyed as soon as possible. Change-Id: I3322410cdd744b464951e2055aeade6069d1d673
Diffstat (limited to 'core/java/android/app/ActivityThread.java')
-rw-r--r--core/java/android/app/ActivityThread.java54
1 files changed, 19 insertions, 35 deletions
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index 2a3e213c5003..deb711d2660b 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -404,6 +404,7 @@ public final class ActivityThread {
try {
fd.close();
} catch (IOException e) {
+ // Ignore
}
}
return;
@@ -412,6 +413,7 @@ public final class ActivityThread {
try {
profileFd.close();
} catch (IOException e) {
+ // Ignore
}
}
profileFile = file;
@@ -843,14 +845,13 @@ public final class ActivityThread {
FileOutputStream fout = new FileOutputStream(fd);
PrintWriter pw = new PrintWriter(fout);
try {
- return dumpMemInfo(pw, checkin, all, args);
+ return dumpMemInfo(pw, checkin, all);
} finally {
pw.flush();
}
}
- private Debug.MemoryInfo dumpMemInfo(PrintWriter pw, boolean checkin, boolean all,
- String[] args) {
+ private Debug.MemoryInfo dumpMemInfo(PrintWriter pw, boolean checkin, boolean all) {
long nativeMax = Debug.getNativeHeapSize() / 1024;
long nativeAllocated = Debug.getNativeHeapAllocatedSize() / 1024;
long nativeFree = Debug.getNativeHeapFreeSize() / 1024;
@@ -1458,17 +1459,6 @@ public final class ActivityThread {
return dm;
}
- static Configuration applyConfigCompat(Configuration config, CompatibilityInfo compat) {
- if (config == null) {
- return null;
- }
- if (compat != null && !compat.supportsScreen()) {
- config = new Configuration(config);
- compat.applyToConfiguration(config);
- }
- return config;
- }
-
private Configuration mMainThreadConfig = new Configuration();
Configuration applyConfigCompatMainThread(Configuration config, CompatibilityInfo compat) {
if (config == null) {
@@ -2509,7 +2499,7 @@ public final class ActivityThread {
return r;
}
- final void cleanUpPendingRemoveWindows(ActivityClientRecord r) {
+ static final void cleanUpPendingRemoveWindows(ActivityClientRecord r) {
if (r.mPendingRemoveWindow != null) {
r.mPendingRemoveWindowManager.removeViewImmediate(r.mPendingRemoveWindow);
IBinder wtoken = r.mPendingRemoveWindow.getWindowToken();
@@ -3437,15 +3427,12 @@ public final class ActivityThread {
= new ArrayList<ComponentCallbacks2>();
if (mActivities.size() > 0) {
- Iterator<ActivityClientRecord> it = mActivities.values().iterator();
- while (it.hasNext()) {
- ActivityClientRecord ar = it.next();
+ for (ActivityClientRecord ar : mActivities.values()) {
Activity a = ar.activity;
if (a != null) {
Configuration thisConfig = applyConfigCompatMainThread(newConfig,
ar.packageInfo.mCompatibilityInfo.getIfNeeded());
- if (!ar.activity.mFinished && (allActivities ||
- (a != null && !ar.paused))) {
+ if (!ar.activity.mFinished && (allActivities || !ar.paused)) {
// If the activity is currently resumed, its configuration
// needs to change right now.
callbacks.add(a);
@@ -3455,24 +3442,24 @@ public final class ActivityThread {
// the activity manager may, before then, decide the
// activity needs to be destroyed to handle its new
// configuration.
- if (DEBUG_CONFIGURATION) Slog.v(TAG, "Setting activity "
- + ar.activityInfo.name + " newConfig=" + thisConfig);
+ if (DEBUG_CONFIGURATION) {
+ Slog.v(TAG, "Setting activity "
+ + ar.activityInfo.name + " newConfig=" + thisConfig);
+ }
ar.newConfig = thisConfig;
}
}
}
}
if (mServices.size() > 0) {
- Iterator<Service> it = mServices.values().iterator();
- while (it.hasNext()) {
- callbacks.add(it.next());
+ for (Service service : mServices.values()) {
+ callbacks.add(service);
}
}
synchronized (mProviderMap) {
if (mLocalProviders.size() > 0) {
- Iterator<ProviderClientRecord> it = mLocalProviders.values().iterator();
- while (it.hasNext()) {
- callbacks.add(it.next().mLocalProvider);
+ for (ProviderClientRecord providerClientRecord : mLocalProviders.values()) {
+ callbacks.add(providerClientRecord.mLocalProvider);
}
}
}
@@ -3484,8 +3471,7 @@ public final class ActivityThread {
return callbacks;
}
- private final void performConfigurationChanged(
- ComponentCallbacks2 cb, Configuration config) {
+ private static void performConfigurationChanged(ComponentCallbacks2 cb, Configuration config) {
// Only for Activity objects, check that they actually call up to their
// superclass implementation. ComponentCallbacks2 is an interface, so
// we check the runtime type and act accordingly.
@@ -3692,7 +3678,7 @@ public final class ActivityThread {
}
}
- final void handleDumpHeap(boolean managed, DumpHeapData dhd) {
+ static final void handleDumpHeap(boolean managed, DumpHeapData dhd) {
if (managed) {
try {
Debug.dumpHprofData(dhd.path, dhd.fd.getFileDescriptor());
@@ -3769,7 +3755,7 @@ public final class ActivityThread {
}
final int N = callbacks.size();
- for (int i=0; i<N; i++) {
+ for (int i = 0; i < N; i++) {
callbacks.get(i).onTrimMemory(level);
}
WindowManagerImpl.getDefault().terminateEgl();
@@ -4057,9 +4043,7 @@ public final class ActivityThread {
final ArrayList<IActivityManager.ContentProviderHolder> results =
new ArrayList<IActivityManager.ContentProviderHolder>();
- Iterator<ProviderInfo> i = providers.iterator();
- while (i.hasNext()) {
- ProviderInfo cpi = i.next();
+ for (ProviderInfo cpi : providers) {
StringBuilder buf = new StringBuilder(128);
buf.append("Pub ");
buf.append(cpi.authority);