Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3944)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/payments/PackageManagerDelegate.java

Issue 2793573002: [Payments] Use <meta-data> tag instead of intent filter data to detect supported payment methods. (Closed)
Patch Set: move <meta-data> to pay activity Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;
+ }
}

Powered by Google App Engine
This is Rietveld 408576698