diff options
| author | 2024-02-06 23:58:47 +0000 | |
|---|---|---|
| committer | 2024-03-11 17:09:52 +0000 | |
| commit | 1c1342893fe50394e682c8002ce0381bc07e0242 (patch) | |
| tree | 1ac49423209a1a21a81c8b8d97ecd4b0269106fe | |
| parent | 7d49c500de62d1889d0578a9587a91c025eb0acf (diff) | |
Create an API for systemUI to save all ViewCapture data.
Then use that API in IssueRecordingService.
Bug: 305049544
Flag: ACONFIG record_issue_qs_tile DEVELOPMENT
Test: Manually tested that everything works on device.
Change-Id: I72382da2ed6c451679f9dcc43dc3d4036ba3aabb
4 files changed, 33 insertions, 0 deletions
diff --git a/core/java/android/content/pm/ILauncherApps.aidl b/core/java/android/content/pm/ILauncherApps.aidl index 533fa512dae8..55957bf887f8 100644 --- a/core/java/android/content/pm/ILauncherApps.aidl +++ b/core/java/android/content/pm/ILauncherApps.aidl @@ -133,4 +133,7 @@ interface ILauncherApps { void setArchiveCompatibilityOptions(boolean enableIconOverlay, boolean enableUnarchivalConfirmation); List<UserHandle> getUserProfiles(); + + /** Saves view capture data to the wm trace directory. */ + void saveViewCaptureData(); } diff --git a/core/java/android/content/pm/LauncherApps.java b/core/java/android/content/pm/LauncherApps.java index 41c1f17ce978..3a5383d9537b 100644 --- a/core/java/android/content/pm/LauncherApps.java +++ b/core/java/android/content/pm/LauncherApps.java @@ -1328,6 +1328,19 @@ public class LauncherApps { } /** + * Saves view capture data to the default location. + * @hide + */ + @RequiresPermission(READ_FRAME_BUFFER) + public void saveViewCaptureData() { + try { + mService.saveViewCaptureData(); + } catch (RemoteException e) { + e.rethrowAsRuntimeException(); + } + } + + /** * Unregister a callback, so that it won't be called when LauncherApps dumps. * @hide */ diff --git a/packages/SystemUI/src/com/android/systemui/recordissue/IssueRecordingService.kt b/packages/SystemUI/src/com/android/systemui/recordissue/IssueRecordingService.kt index 55d7f8e0f740..7e564ef3b853 100644 --- a/packages/SystemUI/src/com/android/systemui/recordissue/IssueRecordingService.kt +++ b/packages/SystemUI/src/com/android/systemui/recordissue/IssueRecordingService.kt @@ -19,6 +19,7 @@ package com.android.systemui.recordissue import android.app.NotificationManager import android.content.Context import android.content.Intent +import android.content.pm.LauncherApps import android.content.res.Resources import android.net.Uri import android.os.Handler @@ -86,6 +87,10 @@ constructor( } ACTION_STOP, ACTION_STOP_NOTIF -> { + // ViewCapture needs to save it's data before it is disabled, or else the data will + // be lost. This is expected to change in the near future, and when that happens + // this line should be removed. + getSystemService(LauncherApps::class.java)?.saveViewCaptureData() TraceUtils.traceStop(contentResolver) } ACTION_SHARE -> { diff --git a/services/core/java/com/android/server/pm/LauncherAppsService.java b/services/core/java/com/android/server/pm/LauncherAppsService.java index c7ebb3c2667b..c6bb99eed7ee 100644 --- a/services/core/java/com/android/server/pm/LauncherAppsService.java +++ b/services/core/java/com/android/server/pm/LauncherAppsService.java @@ -2116,6 +2116,18 @@ public class LauncherAppsService extends SystemService { @RequiresPermission(READ_FRAME_BUFFER) @Override + public void saveViewCaptureData() { + int status = checkCallingOrSelfPermissionForPreflight(mContext, READ_FRAME_BUFFER); + if (PERMISSION_GRANTED == status) { + forEachViewCaptureWindow(this::dumpViewCaptureDataToWmTrace); + } else { + Log.w(TAG, "caller lacks permissions to save view capture data"); + } + } + + + @RequiresPermission(READ_FRAME_BUFFER) + @Override public void registerDumpCallback(@NonNull IDumpCallback cb) { int status = checkCallingOrSelfPermissionForPreflight(mContext, READ_FRAME_BUFFER); if (PERMISSION_GRANTED == status) { |