Fix ActivityManagerAmProfileTests

Before activity profile starts, AMS.clearProfilerLocked() is called
and it calls ProfileData.setProfileProc() with null ProcessRecord. It
causes NPE and activity profile wouldn't start.

Fixes: 119685223
Test: atest CtsActivityManagerDeviceTestCases:ActivityManagerAmProfileTests

Change-Id: Ia1aa4fcec840f32d71e0bb632a7f380d8a943f40
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index c16f1db..40da881 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -1199,8 +1199,8 @@
         void setProfileProc(ProcessRecord profileProc) {
             mProfileProc = profileProc;
             if (mAtmInternal != null) {
-                mAtmInternal.setProfileProc(
-                        profileProc.getWindowProcessController());
+                mAtmInternal.setProfileProc(profileProc == null ? null
+                        : profileProc.getWindowProcessController());
             }
         }