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

Commit aa6b1117 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Check for permission before registering remote animations to prevent...

Merge "Check for permission before registering remote animations to prevent crash." into ub-launcher3-master
parents 285c190b 184b6444
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) {
@@ -81,17 +85,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) {
@@ -99,3 +111,4 @@ public class UiFactory {
            }
        }
    }
}