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

Commit c9e71b88 authored by Tony Wickham's avatar Tony Wickham Committed by Android (Google) Code Review
Browse files

Merge "Use reflection to call LauncherApps.startShortcut()." into ub-launcher3-calgary

parents b900f1cb f25cea45
Loading
Loading
Loading
Loading
+10 −2
Original line number Original line Diff line number Diff line
@@ -25,6 +25,7 @@ import android.content.pm.ShortcutInfo;
import android.graphics.Rect;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Bundle;
import android.os.UserHandle;
import android.util.Log;
import android.util.Log;


import com.android.launcher3.ItemInfo;
import com.android.launcher3.ItemInfo;
@@ -32,6 +33,7 @@ import com.android.launcher3.LauncherSettings;
import com.android.launcher3.Utilities;
import com.android.launcher3.Utilities;
import com.android.launcher3.compat.UserHandleCompat;
import com.android.launcher3.compat.UserHandleCompat;


import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Collections;
import java.util.List;
import java.util.List;
@@ -129,10 +131,16 @@ public class DeepShortcutManager {
          Bundle startActivityOptions, UserHandleCompat user) {
          Bundle startActivityOptions, UserHandleCompat user) {
        if (Utilities.isNycMR1OrAbove()) {
        if (Utilities.isNycMR1OrAbove()) {
            try {
            try {
                mLauncherApps.startShortcut(packageName, id, sourceBounds,
                // TODO: remove reflection once updated SDK is ready.
                        startActivityOptions, user.getUser());
                // mLauncherApps.startShortcut(packageName, id, sourceBounds,
                //        startActivityOptions, user.getUser());
                mLauncherApps.getClass().getMethod("startShortcut", String.class, String.class,
                        Rect.class, Bundle.class, UserHandle.class).invoke(mLauncherApps,
                        packageName, id, sourceBounds, startActivityOptions, user.getUser());
            } catch (SecurityException e) {
            } catch (SecurityException e) {
                Log.e(TAG, Log.getStackTraceString(e));
                Log.e(TAG, Log.getStackTraceString(e));
            } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
                e.printStackTrace();
            }
            }
        }
        }
    }
    }