Loading services/java/com/android/server/am/ActivityRecord.java +1 −0 Original line number Diff line number Diff line Loading @@ -143,6 +143,7 @@ final class ActivityRecord { private boolean inHistory; // are we in the history stack? final ActivityStackSupervisor mStackSupervisor; boolean mStartingWindowShown = false; void dump(PrintWriter pw, String prefix) { final long now = SystemClock.uptimeMillis(); Loading services/java/com/android/server/am/ActivityStack.java +33 −24 Original line number Diff line number Diff line Loading @@ -61,7 +61,6 @@ import android.content.pm.PackageManager; import android.content.res.Configuration; import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.Bitmap.Config; import android.net.Uri; import android.os.Binder; import android.os.Bundle; Loading Loading @@ -121,8 +120,7 @@ final class ActivityStack { // convertToTranslucent(). static final long TRANSLUCENT_CONVERSION_TIMEOUT = 2000; static final boolean SCREENSHOT_FORCE_565 = ActivityManager .isLowRamDeviceStatic() ? true : false; static final boolean SCREENSHOT_FORCE_565 = ActivityManager.isLowRamDeviceStatic(); enum ActivityState { INITIALIZING, Loading Loading @@ -398,8 +396,9 @@ final class ActivityStack { // be simplified once we stop storing tasks with empty mActivities lists. for (int taskNdx = mTaskHistory.size() - 1; taskNdx >= 0; --taskNdx) { ArrayList<ActivityRecord> activities = mTaskHistory.get(taskNdx).mActivities; for (int activityNdx = activities.size() - 1; activityNdx >= 0; --activityNdx) { return activities.get(activityNdx); final int topActivityNdx = activities.size() - 1; if (topActivityNdx >= 0) { return activities.get(topActivityNdx); } } return null; Loading Loading @@ -436,25 +435,6 @@ final class ActivityStack { return null; } boolean containsApp(ProcessRecord app) { if (app == null) { return false; } for (int taskNdx = mTaskHistory.size() - 1; taskNdx >= 0; --taskNdx) { final ArrayList<ActivityRecord> activities = mTaskHistory.get(taskNdx).mActivities; for (int activityNdx = activities.size() - 1; activityNdx >= 0; --activityNdx) { final ActivityRecord r = activities.get(activityNdx); if (r.finishing) { continue; } if (r.app == app) { return true; } } } return false; } final boolean updateLRUListLocked(ActivityRecord r) { final boolean hadit = mLRUActivities.remove(r); mLRUActivities.add(r); Loading Loading @@ -1231,6 +1211,32 @@ final class ActivityStack { } } /** If any activities below the top running one are in the INITIALIZING state and they have a * starting window displayed then remove that starting window. It is possible that the activity * in this state will never resumed in which case that starting window will be orphaned. */ void cancelInitializingActivities() { final ActivityRecord topActivity = topRunningActivityLocked(null); boolean aboveTop = true; for (int taskNdx = mTaskHistory.size() - 1; taskNdx >= 0; --taskNdx) { final ArrayList<ActivityRecord> activities = mTaskHistory.get(taskNdx).mActivities; for (int activityNdx = activities.size() - 1; activityNdx >= 0; --activityNdx) { final ActivityRecord r = activities.get(activityNdx); if (aboveTop) { if (r == topActivity) { aboveTop = false; } continue; } if (r.state == ActivityState.INITIALIZING && r.mStartingWindowShown) { if (DEBUG_VISBILITY) Slog.w(TAG, "Found orphaned starting window " + r); r.mStartingWindowShown = false; mWindowManager.removeAppStartingWindow(r.appToken); } } } } /** * Ensure that the top activity in the stack is resumed. * Loading @@ -1247,6 +1253,8 @@ final class ActivityStack { final boolean resumeTopActivityLocked(ActivityRecord prev, Bundle options) { if (ActivityManagerService.DEBUG_LOCKSCREEN) mService.logLockScreen(""); cancelInitializingActivities(); // Find the first activity that is not finishing. ActivityRecord next = topRunningActivityLocked(null); Loading Loading @@ -1811,6 +1819,7 @@ final class ActivityStack { r.info.applicationInfo), r.nonLocalizedLabel, r.labelRes, r.icon, r.logo, r.windowFlags, prev != null ? prev.appToken : null, showStartingIcon); r.mStartingWindowShown = true; } } else { // If this is the first activity, don't do any fancy animations, Loading services/java/com/android/server/wm/WindowManagerService.java +9 −26 Original line number Diff line number Diff line Loading @@ -256,9 +256,6 @@ public class WindowManagerService extends IWindowManager.Stub /** Amount of time (in milliseconds) to delay before declaring a window freeze timeout. */ static final int WINDOW_FREEZE_TIMEOUT_DURATION = 2000; /** Amount of time (in milliseconds) to delay before declaring a starting window leaked. */ static final int STARTING_WINDOW_TIMEOUT_DURATION = 10000; /** * If true, the window manager will do its own custom freezing and general * management of the screen during rotation. Loading Loading @@ -2268,8 +2265,6 @@ public class WindowManagerService extends IWindowManager.Stub token.appWindowToken.startingWindow = win; if (DEBUG_STARTING_WINDOW) Slog.v (TAG, "addWindow: " + token.appWindowToken + " startingWindow=" + win); Message m = mH.obtainMessage(H.REMOVE_STARTING_TIMEOUT, token.appWindowToken); mH.sendMessageDelayed(m, STARTING_WINDOW_TIMEOUT_DURATION); } boolean imMayMove = true; Loading Loading @@ -2372,7 +2367,6 @@ public class WindowManagerService extends IWindowManager.Stub public void removeWindowLocked(Session session, WindowState win) { if (win.mAttrs.type == TYPE_APPLICATION_STARTING) { if (DEBUG_STARTING_WINDOW) Slog.d(TAG, "Starting window removed " + win); removeStartingWindowTimeout(win.mAppToken); } if (localLOGV || DEBUG_FOCUS || DEBUG_FOCUS_LIGHT && win==mCurrentFocus) Slog.v( Loading Loading @@ -2516,7 +2510,6 @@ public class WindowManagerService extends IWindowManager.Stub if (atoken != null) { if (atoken.startingWindow == win) { if (DEBUG_STARTING_WINDOW) Slog.v(TAG, "Nulling startingWindow " + win); removeStartingWindowTimeout(atoken); atoken.startingWindow = null; } else if (atoken.allAppWindows.size() == 0 && atoken.startingData != null) { // If this is the last window and we had requested a starting Loading Loading @@ -3983,7 +3976,6 @@ public class WindowManagerService extends IWindowManager.Stub if (DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE || DEBUG_STARTING_WINDOW) { Slog.v(TAG, "Removing starting window: " + startingWindow); } removeStartingWindowTimeout(ttoken); startingWindow.getWindowList().remove(startingWindow); mWindowsChanged = true; if (DEBUG_ADD_REMOVE) Slog.v(TAG, Loading Loading @@ -4130,6 +4122,15 @@ public class WindowManagerService extends IWindowManager.Stub } } public void removeAppStartingWindow(IBinder token) { synchronized (mWindowMap) { AppWindowToken wtoken = mTokenMap.get(token).appWindowToken; if (wtoken.startingWindow != null) { scheduleRemoveStartingWindow(wtoken); } } } @Override public void setAppWillBeHidden(IBinder token) { if (!checkCallingPermission(android.Manifest.permission.MANAGE_APP_TOKENS, Loading Loading @@ -4551,21 +4552,11 @@ public class WindowManagerService extends IWindowManager.Stub scheduleRemoveStartingWindow(startingToken); } void removeStartingWindowTimeout(AppWindowToken wtoken) { if (wtoken != null) { if (DEBUG_STARTING_WINDOW) Slog.v(TAG, Debug.getCallers(1) + ": Remove starting window timeout " + wtoken + (wtoken != null ? " startingWindow=" + wtoken.startingWindow : "")); mH.removeMessages(H.REMOVE_STARTING_TIMEOUT, wtoken); } } void scheduleRemoveStartingWindow(AppWindowToken wtoken) { if (wtoken != null && wtoken.startingWindow != null) { if (DEBUG_STARTING_WINDOW) Slog.v(TAG, Debug.getCallers(1) + ": Schedule remove starting " + wtoken + (wtoken != null ? " startingWindow=" + wtoken.startingWindow : "")); removeStartingWindowTimeout(wtoken); Message m = mH.obtainMessage(H.REMOVE_STARTING, wtoken); mH.sendMessage(m); } Loading Loading @@ -7072,8 +7063,6 @@ public class WindowManagerService extends IWindowManager.Stub public static final int TAP_OUTSIDE_STACK = 31; public static final int NOTIFY_ACTIVITY_DRAWN = 32; public static final int REMOVE_STARTING_TIMEOUT = 33; @Override public void handleMessage(Message msg) { if (DEBUG_WINDOW_TRACE) { Loading Loading @@ -7172,7 +7161,6 @@ public class WindowManagerService extends IWindowManager.Stub "Aborted starting " + wtoken + ": removed=" + wtoken.removed + " startingData=" + wtoken.startingData); removeStartingWindowTimeout(wtoken); wtoken.startingWindow = null; wtoken.startingData = null; abort = true; Loading @@ -7197,11 +7185,6 @@ public class WindowManagerService extends IWindowManager.Stub } } break; case REMOVE_STARTING_TIMEOUT: { final AppWindowToken wtoken = (AppWindowToken)msg.obj; Slog.e(TAG, "Starting window " + wtoken + " timed out"); // Fall through. } case REMOVE_STARTING: { final AppWindowToken wtoken = (AppWindowToken)msg.obj; IBinder token = null; Loading Loading
services/java/com/android/server/am/ActivityRecord.java +1 −0 Original line number Diff line number Diff line Loading @@ -143,6 +143,7 @@ final class ActivityRecord { private boolean inHistory; // are we in the history stack? final ActivityStackSupervisor mStackSupervisor; boolean mStartingWindowShown = false; void dump(PrintWriter pw, String prefix) { final long now = SystemClock.uptimeMillis(); Loading
services/java/com/android/server/am/ActivityStack.java +33 −24 Original line number Diff line number Diff line Loading @@ -61,7 +61,6 @@ import android.content.pm.PackageManager; import android.content.res.Configuration; import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.Bitmap.Config; import android.net.Uri; import android.os.Binder; import android.os.Bundle; Loading Loading @@ -121,8 +120,7 @@ final class ActivityStack { // convertToTranslucent(). static final long TRANSLUCENT_CONVERSION_TIMEOUT = 2000; static final boolean SCREENSHOT_FORCE_565 = ActivityManager .isLowRamDeviceStatic() ? true : false; static final boolean SCREENSHOT_FORCE_565 = ActivityManager.isLowRamDeviceStatic(); enum ActivityState { INITIALIZING, Loading Loading @@ -398,8 +396,9 @@ final class ActivityStack { // be simplified once we stop storing tasks with empty mActivities lists. for (int taskNdx = mTaskHistory.size() - 1; taskNdx >= 0; --taskNdx) { ArrayList<ActivityRecord> activities = mTaskHistory.get(taskNdx).mActivities; for (int activityNdx = activities.size() - 1; activityNdx >= 0; --activityNdx) { return activities.get(activityNdx); final int topActivityNdx = activities.size() - 1; if (topActivityNdx >= 0) { return activities.get(topActivityNdx); } } return null; Loading Loading @@ -436,25 +435,6 @@ final class ActivityStack { return null; } boolean containsApp(ProcessRecord app) { if (app == null) { return false; } for (int taskNdx = mTaskHistory.size() - 1; taskNdx >= 0; --taskNdx) { final ArrayList<ActivityRecord> activities = mTaskHistory.get(taskNdx).mActivities; for (int activityNdx = activities.size() - 1; activityNdx >= 0; --activityNdx) { final ActivityRecord r = activities.get(activityNdx); if (r.finishing) { continue; } if (r.app == app) { return true; } } } return false; } final boolean updateLRUListLocked(ActivityRecord r) { final boolean hadit = mLRUActivities.remove(r); mLRUActivities.add(r); Loading Loading @@ -1231,6 +1211,32 @@ final class ActivityStack { } } /** If any activities below the top running one are in the INITIALIZING state and they have a * starting window displayed then remove that starting window. It is possible that the activity * in this state will never resumed in which case that starting window will be orphaned. */ void cancelInitializingActivities() { final ActivityRecord topActivity = topRunningActivityLocked(null); boolean aboveTop = true; for (int taskNdx = mTaskHistory.size() - 1; taskNdx >= 0; --taskNdx) { final ArrayList<ActivityRecord> activities = mTaskHistory.get(taskNdx).mActivities; for (int activityNdx = activities.size() - 1; activityNdx >= 0; --activityNdx) { final ActivityRecord r = activities.get(activityNdx); if (aboveTop) { if (r == topActivity) { aboveTop = false; } continue; } if (r.state == ActivityState.INITIALIZING && r.mStartingWindowShown) { if (DEBUG_VISBILITY) Slog.w(TAG, "Found orphaned starting window " + r); r.mStartingWindowShown = false; mWindowManager.removeAppStartingWindow(r.appToken); } } } } /** * Ensure that the top activity in the stack is resumed. * Loading @@ -1247,6 +1253,8 @@ final class ActivityStack { final boolean resumeTopActivityLocked(ActivityRecord prev, Bundle options) { if (ActivityManagerService.DEBUG_LOCKSCREEN) mService.logLockScreen(""); cancelInitializingActivities(); // Find the first activity that is not finishing. ActivityRecord next = topRunningActivityLocked(null); Loading Loading @@ -1811,6 +1819,7 @@ final class ActivityStack { r.info.applicationInfo), r.nonLocalizedLabel, r.labelRes, r.icon, r.logo, r.windowFlags, prev != null ? prev.appToken : null, showStartingIcon); r.mStartingWindowShown = true; } } else { // If this is the first activity, don't do any fancy animations, Loading
services/java/com/android/server/wm/WindowManagerService.java +9 −26 Original line number Diff line number Diff line Loading @@ -256,9 +256,6 @@ public class WindowManagerService extends IWindowManager.Stub /** Amount of time (in milliseconds) to delay before declaring a window freeze timeout. */ static final int WINDOW_FREEZE_TIMEOUT_DURATION = 2000; /** Amount of time (in milliseconds) to delay before declaring a starting window leaked. */ static final int STARTING_WINDOW_TIMEOUT_DURATION = 10000; /** * If true, the window manager will do its own custom freezing and general * management of the screen during rotation. Loading Loading @@ -2268,8 +2265,6 @@ public class WindowManagerService extends IWindowManager.Stub token.appWindowToken.startingWindow = win; if (DEBUG_STARTING_WINDOW) Slog.v (TAG, "addWindow: " + token.appWindowToken + " startingWindow=" + win); Message m = mH.obtainMessage(H.REMOVE_STARTING_TIMEOUT, token.appWindowToken); mH.sendMessageDelayed(m, STARTING_WINDOW_TIMEOUT_DURATION); } boolean imMayMove = true; Loading Loading @@ -2372,7 +2367,6 @@ public class WindowManagerService extends IWindowManager.Stub public void removeWindowLocked(Session session, WindowState win) { if (win.mAttrs.type == TYPE_APPLICATION_STARTING) { if (DEBUG_STARTING_WINDOW) Slog.d(TAG, "Starting window removed " + win); removeStartingWindowTimeout(win.mAppToken); } if (localLOGV || DEBUG_FOCUS || DEBUG_FOCUS_LIGHT && win==mCurrentFocus) Slog.v( Loading Loading @@ -2516,7 +2510,6 @@ public class WindowManagerService extends IWindowManager.Stub if (atoken != null) { if (atoken.startingWindow == win) { if (DEBUG_STARTING_WINDOW) Slog.v(TAG, "Nulling startingWindow " + win); removeStartingWindowTimeout(atoken); atoken.startingWindow = null; } else if (atoken.allAppWindows.size() == 0 && atoken.startingData != null) { // If this is the last window and we had requested a starting Loading Loading @@ -3983,7 +3976,6 @@ public class WindowManagerService extends IWindowManager.Stub if (DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE || DEBUG_STARTING_WINDOW) { Slog.v(TAG, "Removing starting window: " + startingWindow); } removeStartingWindowTimeout(ttoken); startingWindow.getWindowList().remove(startingWindow); mWindowsChanged = true; if (DEBUG_ADD_REMOVE) Slog.v(TAG, Loading Loading @@ -4130,6 +4122,15 @@ public class WindowManagerService extends IWindowManager.Stub } } public void removeAppStartingWindow(IBinder token) { synchronized (mWindowMap) { AppWindowToken wtoken = mTokenMap.get(token).appWindowToken; if (wtoken.startingWindow != null) { scheduleRemoveStartingWindow(wtoken); } } } @Override public void setAppWillBeHidden(IBinder token) { if (!checkCallingPermission(android.Manifest.permission.MANAGE_APP_TOKENS, Loading Loading @@ -4551,21 +4552,11 @@ public class WindowManagerService extends IWindowManager.Stub scheduleRemoveStartingWindow(startingToken); } void removeStartingWindowTimeout(AppWindowToken wtoken) { if (wtoken != null) { if (DEBUG_STARTING_WINDOW) Slog.v(TAG, Debug.getCallers(1) + ": Remove starting window timeout " + wtoken + (wtoken != null ? " startingWindow=" + wtoken.startingWindow : "")); mH.removeMessages(H.REMOVE_STARTING_TIMEOUT, wtoken); } } void scheduleRemoveStartingWindow(AppWindowToken wtoken) { if (wtoken != null && wtoken.startingWindow != null) { if (DEBUG_STARTING_WINDOW) Slog.v(TAG, Debug.getCallers(1) + ": Schedule remove starting " + wtoken + (wtoken != null ? " startingWindow=" + wtoken.startingWindow : "")); removeStartingWindowTimeout(wtoken); Message m = mH.obtainMessage(H.REMOVE_STARTING, wtoken); mH.sendMessage(m); } Loading Loading @@ -7072,8 +7063,6 @@ public class WindowManagerService extends IWindowManager.Stub public static final int TAP_OUTSIDE_STACK = 31; public static final int NOTIFY_ACTIVITY_DRAWN = 32; public static final int REMOVE_STARTING_TIMEOUT = 33; @Override public void handleMessage(Message msg) { if (DEBUG_WINDOW_TRACE) { Loading Loading @@ -7172,7 +7161,6 @@ public class WindowManagerService extends IWindowManager.Stub "Aborted starting " + wtoken + ": removed=" + wtoken.removed + " startingData=" + wtoken.startingData); removeStartingWindowTimeout(wtoken); wtoken.startingWindow = null; wtoken.startingData = null; abort = true; Loading @@ -7197,11 +7185,6 @@ public class WindowManagerService extends IWindowManager.Stub } } break; case REMOVE_STARTING_TIMEOUT: { final AppWindowToken wtoken = (AppWindowToken)msg.obj; Slog.e(TAG, "Starting window " + wtoken + " timed out"); // Fall through. } case REMOVE_STARTING: { final AppWindowToken wtoken = (AppWindowToken)msg.obj; IBinder token = null; Loading