Merge "Refactor notifyScreenshotListeners method in WMS" into udc-dev
This commit is contained in:
@@ -9383,30 +9383,6 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
mSurfaceSyncGroupController.markSyncGroupReady(syncGroupToken);
|
||||
}
|
||||
|
||||
private ArraySet<ActivityRecord> getVisibleActivityRecords(int displayId) {
|
||||
ArraySet<ActivityRecord> result = new ArraySet<>();
|
||||
synchronized (mGlobalLock) {
|
||||
ArraySet<ComponentName> addedActivities = new ArraySet<>();
|
||||
DisplayContent displayContent = mRoot.getDisplayContent(displayId);
|
||||
if (displayContent != null) {
|
||||
displayContent.forAllWindows(
|
||||
(w) -> {
|
||||
if (w.isVisible()
|
||||
&& w.isDisplayed()
|
||||
&& w.mActivityRecord != null
|
||||
&& !addedActivities.contains(
|
||||
w.mActivityRecord.mActivityComponent)
|
||||
&& w.mActivityRecord.isVisible()
|
||||
&& w.isVisibleNow()) {
|
||||
addedActivities.add(w.mActivityRecord.mActivityComponent);
|
||||
result.add(w.mActivityRecord);
|
||||
}
|
||||
},
|
||||
true /* traverseTopToBottom */);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Must be called when a screenshot is taken via hardware chord.
|
||||
@@ -9422,14 +9398,20 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
throw new SecurityException("Requires STATUS_BAR_SERVICE permission");
|
||||
}
|
||||
synchronized (mGlobalLock) {
|
||||
ArraySet<ComponentName> notifiedApps = new ArraySet<>();
|
||||
ArraySet<ActivityRecord> visibleApps = getVisibleActivityRecords(displayId);
|
||||
for (ActivityRecord ar : visibleApps) {
|
||||
if (ar.isRegisteredForScreenCaptureCallback()) {
|
||||
ar.reportScreenCaptured();
|
||||
notifiedApps.add(ar.mActivityComponent);
|
||||
}
|
||||
final DisplayContent displayContent = mRoot.getDisplayContent(displayId);
|
||||
if (displayContent == null) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
ArraySet<ComponentName> notifiedApps = new ArraySet<>();
|
||||
displayContent.forAllActivities(
|
||||
(ar) -> {
|
||||
if (!notifiedApps.contains(ar.mActivityComponent) && ar.isVisible()
|
||||
&& ar.isRegisteredForScreenCaptureCallback()) {
|
||||
ar.reportScreenCaptured();
|
||||
notifiedApps.add(ar.mActivityComponent);
|
||||
}
|
||||
},
|
||||
true /* traverseTopToBottom */);
|
||||
return List.copyOf(notifiedApps);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user