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

Commit 184b6444 authored by Jon Miranda's avatar Jon Miranda
Browse files

Check for permission before registering remote animations to prevent crash.

Bug: 70220260

Change-Id: I2591fe05991f4d944a199acf82666df2cd7196ff
parent b5772118
Loading
Loading
Loading
Loading
+23 −10
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.launcher3.uioverrides;

import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.PointF;
@@ -34,6 +35,9 @@ import com.android.systemui.shared.recents.view.RecentsTransition;

public class UiFactory {

    private static final String CONTROL_REMOTE_APP_TRANSITION_PERMISSION =
            "android.permission.CONTROL_REMOTE_APP_TRANSITION_ANIMATIONS";

    public static final boolean USE_HARDWARE_BITMAP = false; // FeatureFlags.IS_DOGFOOD_BUILD;

    public static TouchController[] createTouchControllers(Launcher launcher) {
@@ -79,17 +83,25 @@ public class UiFactory {
        recents.reset();
    }

    private static boolean hasControlRemoteAppTransitionPermission(Launcher launcher) {
        return launcher.checkSelfPermission(CONTROL_REMOTE_APP_TRANSITION_PERMISSION)
                == PackageManager.PERMISSION_GRANTED;
    }

    public static Bundle getActivityLaunchOptions(Launcher launcher, View v) {
        if (hasControlRemoteAppTransitionPermission(launcher)) {
            try {
                return new LauncherAppTransitionManager(launcher).getActivityLauncherOptions(v);
            } catch (NoClassDefFoundError e) {
            // Gracefully fall back to default launch options if the user's platform doesn't have
            // the latest changes.
            return launcher.getDefaultActivityLaunchOptions(v);
                // Gracefully fall back to default launch options if the user's platform doesn't
                // have the latest changes.
            }
        }
        return launcher.getDefaultActivityLaunchOptions(v);
    }

    public static void registerRemoteAnimations(Launcher launcher) {
        if (hasControlRemoteAppTransitionPermission(launcher)) {
            try {
                new LauncherAppTransitionManager(launcher).registerRemoteAnimations();
            } catch (NoClassDefFoundError e) {
@@ -97,3 +109,4 @@ public class UiFactory {
            }
        }
    }
}