| Index: chrome/android/java/src/org/chromium/chrome/browser/payments/PackageManagerDelegate.java
|
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/payments/PackageManagerDelegate.java b/chrome/android/java/src/org/chromium/chrome/browser/payments/PackageManagerDelegate.java
|
| index 8afbbc2a609d5c5c4d9969f9db224309056a953f..b58fefd7dbd1de3995243936691c9f3b65d9eb3d 100644
|
| --- a/chrome/android/java/src/org/chromium/chrome/browser/payments/PackageManagerDelegate.java
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/payments/PackageManagerDelegate.java
|
| @@ -5,10 +5,12 @@
|
| package org.chromium.chrome.browser.payments;
|
|
|
| import android.content.Intent;
|
| +import android.content.pm.ApplicationInfo;
|
| import android.content.pm.PackageInfo;
|
| import android.content.pm.PackageManager;
|
| import android.content.pm.PackageManager.NameNotFoundException;
|
| import android.content.pm.ResolveInfo;
|
| +import android.content.res.Resources;
|
| import android.graphics.drawable.Drawable;
|
| import android.os.StrictMode;
|
| import android.os.StrictMode.ThreadPolicy;
|
| @@ -17,6 +19,8 @@ import org.chromium.base.ContextUtils;
|
|
|
| import java.util.List;
|
|
|
| +import javax.annotation.Nullable;
|
| +
|
| /** Abstraction of Android's package manager to enable unit testing. */
|
| public class PackageManagerDelegate {
|
| /**
|
| @@ -65,6 +69,23 @@ public class PackageManagerDelegate {
|
| }
|
|
|
| /**
|
| + * Retrieves the list of activities that can respond to the given intent. And returns the
|
| + * activites' meta data in ResolveInfo.
|
| + *
|
| + * @param intent The intent to query.
|
| + * @return The list of activities that can respond to the intent.
|
| + */
|
| + public List<ResolveInfo> getActivitiesThatCanRespondToIntentWithMetaData(Intent intent) {
|
| + ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
|
| + try {
|
| + return ContextUtils.getApplicationContext().getPackageManager().queryIntentActivities(
|
| + intent, PackageManager.GET_META_DATA);
|
| + } finally {
|
| + StrictMode.setThreadPolicy(oldPolicy);
|
| + }
|
| + }
|
| +
|
| + /**
|
| * Retrieves the list of services that can respond to the given intent.
|
| * @param intent The intent to query.
|
| * @return The list of services that can respond to the intent.
|
| @@ -96,4 +117,23 @@ public class PackageManagerDelegate {
|
| public Drawable getAppIcon(ResolveInfo resolveInfo) {
|
| return resolveInfo.loadIcon(ContextUtils.getApplicationContext().getPackageManager());
|
| }
|
| +
|
| + /**
|
| + * Gets the resources of the given application.
|
| + *
|
| + * @param applicationInfo The given application info.
|
| + * @return The resources.
|
| + */
|
| + @Nullable
|
| + public Resources getResourcesForApplication(ApplicationInfo applicationInfo) {
|
| + Resources resources;
|
| + try {
|
| + resources = ContextUtils.getApplicationContext()
|
| + .getPackageManager()
|
| + .getResourcesForApplication(applicationInfo);
|
| + } catch (NameNotFoundException e) {
|
| + return null;
|
| + }
|
| + return resources;
|
| + }
|
| }
|
|
|