Removed references to ActivityRecord and TaskRecord in AM (24/n)

Once ActivityRecord and TaskRecord are moved to the WM package they
can no longer be accessed by classes in the AM package. This CL fixes
up some of the access before the move.
- Moved activity relaunch reasons to ActivityTaskManagerService and made
them public to allow access from the AM side in the future.
- Use task id to reference task in AppErrorDialog and AppErrors vs. the
TaskRecord object.
- Also, removed out-of-date code that tries to re-start a task if it
can't start in through recents. The reent start also looks for the task
in the stacks now so if the task exists it will be started through that
channel and we no longer need this fallback.

Test: Existing test pass
Bug: 80414790
Change-Id: I8df76a4f107fa526d726d7522eb5fcee6958b45d
diff --git a/services/core/java/com/android/server/am/ActivityTaskManagerService.java b/services/core/java/com/android/server/am/ActivityTaskManagerService.java
index cb729a8..2d27017 100644
--- a/services/core/java/com/android/server/am/ActivityTaskManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityTaskManagerService.java
@@ -277,7 +277,6 @@
 import java.util.Locale;
 import java.util.Map;
 import java.util.Set;
-import java.util.function.Predicate;
 
 /**
  * System service for managing activities and their containers (task, stacks, displays,... ).
@@ -314,7 +313,15 @@
     public static final String DUMP_RECENTS_CMD = "recents" ;
     public static final String DUMP_RECENTS_SHORT_CMD = "r" ;
 
+    /** This activity is not being relaunched, or being relaunched for a non-resize reason. */
+    public static final int RELAUNCH_REASON_NONE = 0;
+    /** This activity is being relaunched due to windowing mode change. */
+    public static final int RELAUNCH_REASON_WINDOWING_MODE_RESIZE = 1;
+    /** This activity is being relaunched due to a free-resize operation. */
+    public static final int RELAUNCH_REASON_FREE_RESIZE = 2;
+
     Context mContext;
+
     /**
      * This Context is themable and meant for UI display (AlertDialogs, etc.). The theme can
      * change at runtime. Use mContext for non-UI purposes.
@@ -1362,7 +1369,7 @@
                         Slog.i(TAG, "Removing task failed to finish activity");
                     }
                     // Explicitly dismissing the activity so reset its relaunch flag.
-                    r.mRelaunchReason = ActivityRecord.RELAUNCH_REASON_NONE;
+                    r.mRelaunchReason = RELAUNCH_REASON_NONE;
                 } else {
                     res = tr.getStack().requestFinishActivityLocked(token, resultCode,
                             resultData, "app-request", true);
@@ -4325,6 +4332,17 @@
         }
     }
 
+    public static String relaunchReasonToString(int relaunchReason) {
+        switch (relaunchReason) {
+            case RELAUNCH_REASON_WINDOWING_MODE_RESIZE:
+                return "window_resize";
+            case RELAUNCH_REASON_FREE_RESIZE:
+                return "free_resize";
+            default:
+                return null;
+        }
+    }
+
     ActivityStack getTopDisplayFocusedStack() {
         return mStackSupervisor.getTopDisplayFocusedStack();
     }
@@ -6642,5 +6660,12 @@
                 mStackSupervisor.handleAppCrashLocked(wpc);
             }
         }
+
+        @Override
+        public int finishTopCrashedActivities(WindowProcessController crashedApp, String reason) {
+            synchronized (mGlobalLock) {
+                return mStackSupervisor.finishTopCrashedActivitiesLocked(crashedApp, reason);
+            }
+        }
     }
 }