| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chrome.browser.payments; | 5 package org.chromium.chrome.browser.payments; |
| 6 | 6 |
| 7 import android.annotation.SuppressLint; |
| 7 import android.content.Intent; | 8 import android.content.Intent; |
| 8 import android.content.pm.ApplicationInfo; | 9 import android.content.pm.ApplicationInfo; |
| 9 import android.content.pm.PackageInfo; | 10 import android.content.pm.PackageInfo; |
| 10 import android.content.pm.PackageManager; | 11 import android.content.pm.PackageManager; |
| 11 import android.content.pm.PackageManager.NameNotFoundException; | 12 import android.content.pm.PackageManager.NameNotFoundException; |
| 12 import android.content.pm.ResolveInfo; | 13 import android.content.pm.ResolveInfo; |
| 13 import android.content.res.Resources; | 14 import android.content.res.Resources; |
| 14 import android.graphics.drawable.Drawable; | 15 import android.graphics.drawable.Drawable; |
| 15 import android.os.StrictMode; | 16 import android.os.StrictMode; |
| 16 import android.os.StrictMode.ThreadPolicy; | 17 import android.os.StrictMode.ThreadPolicy; |
| 17 | 18 |
| 18 import org.chromium.base.ContextUtils; | 19 import org.chromium.base.ContextUtils; |
| 19 | 20 |
| 20 import java.util.List; | 21 import java.util.List; |
| 21 | 22 |
| 22 import javax.annotation.Nullable; | 23 import javax.annotation.Nullable; |
| 23 | 24 |
| 24 /** Abstraction of Android's package manager to enable unit testing. */ | 25 /** Abstraction of Android's package manager to enable unit testing. */ |
| 25 public class PackageManagerDelegate { | 26 public class PackageManagerDelegate { |
| 26 /** | 27 /** |
| 27 * Retrieves package information of an installed application. | 28 * Retrieves package information of an installed application. |
| 28 * | 29 * |
| 29 * @param packageName The package name of an installed application. | 30 * @param packageName The package name of an installed application. |
| 30 * @return The package information of the installed application. | 31 * @return The package information of the installed application. |
| 31 */ | 32 */ |
| 33 @SuppressLint("PackageManagerGetSignatures") |
| 32 public PackageInfo getPackageInfoWithSignatures(String packageName) { | 34 public PackageInfo getPackageInfoWithSignatures(String packageName) { |
| 33 try { | 35 try { |
| 34 return ContextUtils.getApplicationContext().getPackageManager().getP
ackageInfo( | 36 return ContextUtils.getApplicationContext().getPackageManager().getP
ackageInfo( |
| 35 packageName, PackageManager.GET_SIGNATURES); | 37 packageName, PackageManager.GET_SIGNATURES); |
| 36 } catch (NameNotFoundException e) { | 38 } catch (NameNotFoundException e) { |
| 37 return null; | 39 return null; |
| 38 } | 40 } |
| 39 } | 41 } |
| 40 | 42 |
| 41 /** | 43 /** |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 try { | 132 try { |
| 131 resources = ContextUtils.getApplicationContext() | 133 resources = ContextUtils.getApplicationContext() |
| 132 .getPackageManager() | 134 .getPackageManager() |
| 133 .getResourcesForApplication(applicationInfo); | 135 .getResourcesForApplication(applicationInfo); |
| 134 } catch (NameNotFoundException e) { | 136 } catch (NameNotFoundException e) { |
| 135 return null; | 137 return null; |
| 136 } | 138 } |
| 137 return resources; | 139 return resources; |
| 138 } | 140 } |
| 139 } | 141 } |
| OLD | NEW |