Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f452138f authored by Emilian Peev's avatar Emilian Peev
Browse files

CameraServiceProxy: Extend the recent app resizeable query

The camera rotate & crop heuristics depend on the package resizeability
flag which is queried from the task manager recent list. In split screen
mode the list can include several packages and the camera app may not be
the first entry in that list.

Bug: 222350953
Test: Manual using camera application
Change-Id: Iad7a974e09830fab533202cde149a880821cd13a
parent e31ec794
Loading
Loading
Loading
Loading
+23 −18
Original line number Diff line number Diff line
@@ -467,7 +467,8 @@ public class CameraServiceProxy extends SystemService
            ParceledListSlice<ActivityManager.RecentTaskInfo> recentTasks = null;

            try {
                recentTasks = ActivityTaskManager.getService().getRecentTasks(/*maxNum*/1,
                // Get 2 recent tasks in case we are running in split mode
                recentTasks = ActivityTaskManager.getService().getRecentTasks(/*maxNum*/2,
                        /*flags*/ 0, userId);
            } catch (RemoteException e) {
                Log.e(TAG, "Failed to query recent tasks!");
@@ -475,7 +476,7 @@ public class CameraServiceProxy extends SystemService
            }

            if ((recentTasks != null) && (!recentTasks.getList().isEmpty())) {
                ActivityManager.RecentTaskInfo task = recentTasks.getList().get(0);
                for (ActivityManager.RecentTaskInfo task : recentTasks.getList()) {
                    if (packageName.equals(task.topActivityInfo.packageName)) {
                        taskInfo = new TaskInfo();
                        taskInfo.frontTaskId = task.taskId;
@@ -489,9 +490,13 @@ public class CameraServiceProxy extends SystemService
                        taskInfo.isFixedOrientationPortrait =
                                ActivityInfo.isFixedOrientationPortrait(
                                        task.topActivityInfo.screenOrientation);
                } else {
                    Log.e(TAG, "Recent task package name: " + task.topActivityInfo.packageName
                            + " doesn't match with camera client package name: " + packageName);
                        break;
                    }
                }

                if (taskInfo == null) {
                    Log.e(TAG, "Recent tasks don't include camera client package name: " +
                            packageName);
                    return CaptureRequest.SCALER_ROTATE_AND_CROP_NONE;
                }
            } else {