Add AppInstallerInfoPreference for Spa

This is used in new App Info page.

To try:
1. adb shell am start -n com.android.settings/.spa.SpaActivity
2. Go to Apps -> All apps -> [One App] -> App details

Bug: 236346018
Test: Unit test
Change-Id: Ibd1ae27c60a096b7f12ca6640a58b099dcfb0b6b
This commit is contained in:
Chaohui Wang
2022-10-27 18:38:39 +08:00
parent 93b0b686bd
commit 601124517a
6 changed files with 374 additions and 8 deletions

View File

@@ -24,7 +24,9 @@ import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ResolveInfo;
import android.util.Log;
// This class provides methods that help dealing with app stores.
import androidx.annotation.Nullable;
/** This class provides methods that help dealing with app stores. */
public class AppStoreUtil {
private static final String LOG_TAG = "AppStoreUtil";
@@ -34,8 +36,11 @@ public class AppStoreUtil {
.setClassName(result.activityInfo.packageName, result.activityInfo.name) : null;
}
// Returns the package name of the app that we consider to be the user-visible 'installer'
// of given packageName, if one is available.
/**
* Returns the package name of the app that we consider to be the user-visible 'installer'
* of given packageName, if one is available.
*/
@Nullable
public static String getInstallerPackageName(Context context, String packageName) {
String installerPackageName;
try {
@@ -62,7 +67,8 @@ public class AppStoreUtil {
return installerPackageName;
}
// Returns a link to the installer app store for a given package name.
/** Returns a link to the installer app store for a given package name. */
@Nullable
public static Intent getAppStoreLink(Context context, String installerPackageName,
String packageName) {
Intent intent = new Intent(Intent.ACTION_SHOW_APP_INFO)
@@ -75,7 +81,7 @@ public class AppStoreUtil {
return null;
}
// Convenience method that looks up the installerPackageName for you.
/** Convenience method that looks up the installerPackageName for you. */
public static Intent getAppStoreLink(Context context, String packageName) {
String installerPackageName = getInstallerPackageName(context, packageName);
return getAppStoreLink(context, installerPackageName, packageName);