diff options
| author | 2020-10-21 23:32:42 +0000 | |
|---|---|---|
| committer | 2020-10-21 23:32:42 +0000 | |
| commit | 2df76d603cea1f66f3e2fa1714da5bd91cfe0f90 (patch) | |
| tree | a20e87395ca4ad326ae3817b252285951c3e6ef9 | |
| parent | f0a621237ea6fa705703df5242a2a4a807015268 (diff) | |
| parent | 9fe53e4d26f007a15057e0cb139dd765efbc8f9c (diff) | |
Merge "CachedAppOptimizer: ensure binder is never frozen with app unfrozen"
| -rw-r--r-- | services/core/java/com/android/server/am/CachedAppOptimizer.java | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/services/core/java/com/android/server/am/CachedAppOptimizer.java b/services/core/java/com/android/server/am/CachedAppOptimizer.java index 8112bb854b71..cd0d5b47c238 100644 --- a/services/core/java/com/android/server/am/CachedAppOptimizer.java +++ b/services/core/java/com/android/server/am/CachedAppOptimizer.java @@ -777,27 +777,27 @@ public final class CachedAppOptimizer { long freezeTime = app.freezeUnfreezeTime; try { + freezeBinder(app.pid, false); + } catch (RuntimeException e) { + Slog.e(TAG_AM, "Unable to unfreeze binder for " + app.pid + " " + app.processName + + ". Killing it"); + app.kill("Unable to unfreeze", + ApplicationExitInfo.REASON_OTHER, + ApplicationExitInfo.SUBREASON_INVALID_STATE, true); + return; + } + + try { Process.setProcessFrozen(app.pid, app.uid, false); app.freezeUnfreezeTime = SystemClock.uptimeMillis(); app.frozen = false; } catch (Exception e) { Slog.e(TAG_AM, "Unable to unfreeze " + app.pid + " " + app.processName - + ". Any related user experience might be hanged."); + + ". This might cause inconsistency or UI hangs."); } if (!app.frozen) { - try { - freezeBinder(app.pid, false); - } catch (RuntimeException e) { - Slog.e(TAG_AM, "Unable to unfreeze binder for " + app.pid + " " + app.processName - + ". Killing it"); - app.kill("Unable to unfreeze", - ApplicationExitInfo.REASON_OTHER, - ApplicationExitInfo.SUBREASON_INVALID_STATE, true); - return; - } - if (DEBUG_FREEZER) { Slog.d(TAG_AM, "sync unfroze " + app.pid + " " + app.processName); } @@ -1110,14 +1110,6 @@ public final class CachedAppOptimizer { return; } - try { - freezeBinder(pid, true); - } catch (RuntimeException e) { - // TODO: it might be preferable to kill the target pid in this case - Slog.e(TAG_AM, "Unable to freeze binder for " + pid + " " + name); - return; - } - if (pid == 0 || proc.frozen) { // Already frozen or not a real process, either one being // launched or one being killed @@ -1146,6 +1138,15 @@ public final class CachedAppOptimizer { EventLog.writeEvent(EventLogTags.AM_FREEZE, pid, name); + try { + freezeBinder(pid, true); + } catch (RuntimeException e) { + Slog.e(TAG_AM, "Unable to freeze binder for " + pid + " " + name); + proc.kill("Unable to freeze binder interface", + ApplicationExitInfo.REASON_OTHER, + ApplicationExitInfo.SUBREASON_INVALID_STATE, true); + } + // See above for why we're not taking mPhenotypeFlagLock here if (mRandom.nextFloat() < mFreezerStatsdSampleRate) { FrameworkStatsLog.write(FrameworkStatsLog.APP_FREEZE_CHANGED, |