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

Commit ce2b013d authored by Himanshu Gupta's avatar Himanshu Gupta Committed by Android (Google) Code Review
Browse files

Merge "Adding methods to access LauncherApps APIs." into main

parents 102e54ba 6c25654e
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -13,3 +13,17 @@ flag {
    description: "This flag enables the animation of the Private Space container"
    bug: "299294792"
}

flag {
    name: "private_space_sys_apps_separation"
    namespace: "launcher_search"
    description: "This flag enables showing system apps separate in Private Space container."
    bug: "308054233"
}

flag {
    name: "private_space_app_installer_button"
    namespace: "launcher_search"
    description: "This flag enables addition of App Installer button in Private Space container."
    bug: "308064949"
}
 No newline at end of file
+3 −3
Original line number Diff line number Diff line
@@ -107,6 +107,7 @@ import com.android.launcher3.testing.TestLogging;
import com.android.launcher3.testing.shared.TestProtocol;
import com.android.launcher3.touch.ItemClickHandler;
import com.android.launcher3.touch.ItemClickHandler.ItemClickProxy;
import com.android.launcher3.uioverrides.ApiWrapper;
import com.android.launcher3.util.ActivityOptionsWrapper;
import com.android.launcher3.util.ComponentKey;
import com.android.launcher3.util.DisplayController;
@@ -1056,9 +1057,8 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
                        } else if (info.isPromise()) {
                            TestLogging.recordEvent(
                                    TestProtocol.SEQUENCE_MAIN, "start: taskbarPromiseIcon");
                            intent = new PackageManagerHelper(this)
                                    .getMarketIntent(info.getTargetPackage())
                                    .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                            intent = ApiWrapper.getAppMarketActivityIntent(this,
                                    info.getTargetPackage(), Process.myUserHandle());
                            startActivity(intent);

                        } else if (info.itemType == Favorites.ITEM_TYPE_DEEP_SHORTCUT) {
+44 −0
Original line number Diff line number Diff line
@@ -17,13 +17,16 @@
package com.android.launcher3.uioverrides;

import android.app.ActivityOptions;
import android.app.PendingIntent;
import android.app.Person;
import android.content.Context;
import android.content.Intent;
import android.content.pm.LauncherActivityInfo;
import android.content.pm.LauncherApps;
import android.content.pm.LauncherUserInfo;
import android.content.pm.ShortcutInfo;
import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
import android.os.UserHandle;
import android.os.UserManager;
import android.util.ArrayMap;
@@ -31,9 +34,12 @@ import android.window.RemoteTransition;

import com.android.launcher3.Flags;
import com.android.launcher3.Utilities;
import com.android.launcher3.proxy.ProxyActivityStarter;
import com.android.launcher3.util.StartActivityParams;
import com.android.launcher3.util.UserIconInfo;
import com.android.quickstep.util.FadeOutRemoteTransition;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@@ -102,6 +108,44 @@ public class ApiWrapper {
        return users;
    }

    /**
     * Returns the list of the system packages that are installed at user creation.
     * An empty list denotes that all system packages are installed for that user at creation.
     */
    public static List<String> getPreInstalledSystemPackages(Context context, UserHandle user) {
        LauncherApps launcherApps = context.getSystemService(LauncherApps.class);
        if (android.os.Flags.allowPrivateProfile() && Flags.enablePrivateSpace()
                && Flags.privateSpaceSysAppsSeparation()) {
            return launcherApps.getPreInstalledSystemPackages(user);
        } else {
            return new ArrayList<>();
        }
    }

    /**
     * Returns an intent which can be used to start the App Market activity (Installer
     * Activity).
     */
    public static Intent getAppMarketActivityIntent(Context context, String packageName,
            UserHandle user) {
        LauncherApps launcherApps = context.getSystemService(LauncherApps.class);
        if (android.os.Flags.allowPrivateProfile() && Flags.enablePrivateSpace()
                && Flags.privateSpaceAppInstallerButton()) {
            StartActivityParams params = new StartActivityParams((PendingIntent) null, 0);
            params.intentSender = launcherApps.getAppMarketActivityIntent(packageName, user);
            return ProxyActivityStarter.getLaunchIntent(context, params);
        } else {
            return new Intent(Intent.ACTION_VIEW)
                    .setData(new Uri.Builder()
                            .scheme("market")
                            .authority("details")
                            .appendQueryParameter("id", packageName)
                            .build())
                    .putExtra(Intent.EXTRA_REFERRER, new Uri.Builder().scheme("android-app")
                            .authority(context.getPackageName()).build());
        }
    }

    private static class NoopDrawable extends ColorDrawable {
        @Override
        public int getIntrinsicHeight() {
+4 −2
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.launcher3.model.data;

import android.content.Context;
import android.content.Intent;
import android.os.Process;

import androidx.annotation.Nullable;

@@ -26,7 +27,7 @@ import com.android.launcher3.icons.BitmapInfo.DrawableCreationFlags;
import com.android.launcher3.icons.FastBitmapDrawable;
import com.android.launcher3.logging.FileLog;
import com.android.launcher3.pm.PackageInstallInfo;
import com.android.launcher3.util.PackageManagerHelper;
import com.android.launcher3.uioverrides.ApiWrapper;

/**
 * Represents an ItemInfo which also holds an icon.
@@ -216,7 +217,8 @@ public abstract class ItemInfoWithIcon extends ItemInfo {
        String targetPackage = getTargetPackage();

        return targetPackage != null
                ? new PackageManagerHelper(context).getMarketIntent(targetPackage)
                ? ApiWrapper.getAppMarketActivityIntent(
                        context, targetPackage, Process.myUserHandle())
                : null;
    }

+5 −2
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@ import android.app.ActivityOptions;
import android.content.Context;
import android.content.Intent;
import android.graphics.Rect;
import android.os.Process;
import android.view.View;
import android.view.accessibility.AccessibilityNodeInfo;
import android.widget.ImageView;
@@ -22,6 +23,7 @@ import com.android.launcher3.Utilities;
import com.android.launcher3.model.WidgetItem;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.model.data.WorkspaceItemInfo;
import com.android.launcher3.uioverrides.ApiWrapper;
import com.android.launcher3.util.InstantAppResolver;
import com.android.launcher3.util.PackageManagerHelper;
import com.android.launcher3.util.PackageUserKey;
@@ -237,8 +239,9 @@ public abstract class SystemShortcut<T extends Context & ActivityContext> extend

        @Override
        public void onClick(View view) {
            Intent intent = new PackageManagerHelper(view.getContext()).getMarketIntent(
                    mItemInfo.getTargetComponent().getPackageName());
            Intent intent = ApiWrapper.getAppMarketActivityIntent(view.getContext(),
                    mItemInfo.getTargetComponent().getPackageName(),
                    Process.myUserHandle());
            mTarget.startActivitySafely(view, intent, mItemInfo);
            AbstractFloatingView.closeAllOpenViews(mTarget);
        }
Loading