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

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

Merge "Removing config shortcut activities for managed profiles for apps build...

Merge "Removing config shortcut activities for managed profiles for apps build with older sdk" into ub-launcher3-dorval
parents 3dc60c6e b57645fc
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -1451,9 +1451,14 @@ public class Launcher extends BaseActivity
        }

        if (info == null) {
            info = InstallShortcutReceiver.fromShortcutIntent(this, data);
            // Legacy shortcuts are only supported for primary profile.
            info = Process.myUserHandle().equals(args.user)
                    ? InstallShortcutReceiver.fromShortcutIntent(this, data) : null;

            if (info == null || !new PackageManagerHelper(this).hasPermissionForActivity(
            if (info == null) {
                Log.e(TAG, "Unable to parse a valid custom shortcut result");
                return;
            } else if (!new PackageManagerHelper(this).hasPermissionForActivity(
                    info.intent, args.getPendingIntent().getComponent().getPackageName())) {
                // The app is trying to add a shortcut without sufficient permissions
                Log.e(TAG, "Ignoring malicious intent " + info.intent.toUri(0));
+8 −1
Original line number Diff line number Diff line
@@ -20,6 +20,8 @@ import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.LauncherActivityInfo;
import android.content.pm.LauncherApps;
import android.os.Build;
import android.os.Process;
import android.os.UserHandle;
import android.util.Log;

@@ -44,17 +46,22 @@ public class LauncherAppsCompatVO extends LauncherAppsCompatVL {
    @Override
    public List<ShortcutConfigActivityInfo> getCustomShortcutActivityList() {
        List<ShortcutConfigActivityInfo> result = new ArrayList<>();
        UserHandle myUser = Process.myUserHandle();

        try {
            Method m = LauncherApps.class.getDeclaredMethod("getShortcutConfigActivityList",
                    String.class, UserHandle.class);
            for (UserHandle user : UserManagerCompat.getInstance(mContext).getUserProfiles()) {
                boolean ignoreTargetSdk = myUser.equals(user);
                List<LauncherActivityInfo> activities =
                        (List<LauncherActivityInfo>) m.invoke(mLauncherApps, null, user);
                for (LauncherActivityInfo activityInfo : activities) {
                    if (ignoreTargetSdk || activityInfo.getApplicationInfo().targetSdkVersion >=
                            Build.VERSION_CODES.O) {
                        result.add(new ShortcutConfigActivityInfoVO(activityInfo));
                    }
                }
            }
        } catch (Exception e) {
            Log.e("LauncherAppsCompatVO", "Error calling new API", e);
        }
+5 −0
Original line number Diff line number Diff line
@@ -24,6 +24,8 @@ import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;

import com.android.launcher3.Utilities;

/**
 * A wrapper around platform implementation of PinItemRequestCompat until the
 * updated SDK is available.
@@ -115,6 +117,9 @@ public class PinItemRequestCompat implements Parcelable {
            };

    public static PinItemRequestCompat getPinItemRequest(Intent intent) {
        if (!Utilities.isAtLeastO()) {
            return null;
        }
        Parcelable extra = intent.getParcelableExtra(EXTRA_PIN_ITEM_REQUEST);
        return extra == null ? null : new PinItemRequestCompat(extra);
    }
+2 −0
Original line number Diff line number Diff line
@@ -53,6 +53,7 @@ public class PendingRequestArgs extends ItemInfo implements Parcelable {

    public PendingRequestArgs(Parcel parcel) {
        readFromValues(ContentValues.CREATOR.createFromParcel(parcel));
        user = parcel.readParcelable(null);

        mArg1 = parcel.readInt();
        mObjectType = parcel.readInt();
@@ -69,6 +70,7 @@ public class PendingRequestArgs extends ItemInfo implements Parcelable {
        ContentValues itemValues = new ContentValues();
        writeToValues(new ContentWriter(itemValues, null));
        itemValues.writeToParcel(dest, flags);
        dest.writeParcelable(user, flags);

        dest.writeInt(mArg1);
        dest.writeInt(mObjectType);