Question Details

No question body available.

Tags

android android-camera2 foreground-service android-background android-16

Answers (1)

March 11, 2026 Score: 3 Rep: 1,011,573 Quality: Medium Completeness: 80%

I am having a bit of difficulty tracking down source code that matches the stack trace, but in the now-current main, that getTaskInfo() call is in here:

@FlaggedApi(com.android.window.flags.Flags.FLAGENABLECAMERACOMPATFORDESKTOPWINDOWING)
@TestApi
public static int getRotationOverrideInternal(@Nullable Context context,
        @Nullable PackageManager packageManager, @Nullable String packageName) {
    if (!CameraManagerGlobal.sLandscapeToPortrait) {
        return ICameraService.ROTATIONOVERRIDENONE;
    }

if (context != null) { final ActivityManager activityManager = context.getSystemService(ActivityManager.class); if (activityManager != null) { for (ActivityManager.AppTask appTask : activityManager.getAppTasks()) { final TaskInfo taskInfo = appTask.getTaskInfo(); final int freeformCameraCompatMode = taskInfo.appCompatTaskInfo .cameraCompatTaskInfo.freeformCameraCompatMode; if (freeformCameraCompatMode != 0 && taskInfo.topActivity != null && taskInfo.topActivity.getPackageName().equals(packageName)) { // WindowManager has requested rotation override. return getRotationOverrideForCompatFreeform(freeformCameraCompatMode); } } } }

if (packageManager != null && packageName != null) { try { return packageManager.getProperty( PackageManager.PROPERTYCOMPATOVERRIDELANDSCAPETOPORTRAIT, packageName).getBoolean() ? ICameraService.ROTATIONOVERRIDEOVERRIDETOPORTRAIT : ICameraService.ROTATIONOVERRIDENONE; } catch (PackageManager.NameNotFoundException e) { // No such property } }

return CompatChanges.isChangeEnabled(OVERRIDECAMERALANDSCAPETOPORTRAIT) ? ICameraService.ROTATIONOVERRIDEOVERRIDETOPORTRAIT : ICameraService.ROTATIONOVERRIDE_NONE; }

It appears as though they are trying to determine if the camera output needs to be rotated in support of freeform multi-window support. I can see why that might be tied to tasks. But getTaskInfo() is a fragile call; IMHO they should be gracefully degrading if they cannot get the task info.

I see that you(?) filed a bug report, and with luck they will address this. In the meantime, you might need to add your own exception handling logic around getCameraCharacteristics() and do something (e.g., use the last-known values that you cache somewhere).