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

Commit 381436a1 authored by Mina Granic's avatar Mina Granic
Browse files

Fix possible NPE for isolated apps and tests.

Some tests do not have the ActivityTaskManager service, and might fail with NPE.

Flag: EXEMPT simple nullness check
Test: VisualQueryDetectionServiceBasicTest
Fixes: 382334207
Change-Id: Idac15cfc57a197b151e8df34235261c7c4decbc1
parent f4e1b7f1
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -67,6 +67,7 @@ import android.os.Handler;
import android.os.HandlerExecutor;
import android.os.HandlerThread;
import android.os.IBinder;
import android.os.Process;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.ServiceSpecificException;
@@ -1705,7 +1706,9 @@ public final class CameraManager {
            return ICameraService.ROTATION_OVERRIDE_NONE;
        }

        if (context != null) {
        // Isolated process does not have access to ActivityTaskManager service, which is used
        // indirectly in `ActivityManager.getAppTasks()`.
        if (context != null && !Process.isIsolated()) {
            final ActivityManager activityManager = context.getSystemService(ActivityManager.class);
            if (activityManager != null) {
                for (ActivityManager.AppTask appTask : activityManager.getAppTasks()) {