Chromium Code Reviews| 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 // TODO(crbug.com/635567): Fix this properly. | |
|
Ted C
2017/04/27 19:02:47
+rouslan
Ted C
2017/04/27 22:49:51
Sounds like we can remove this TODO based on Rousl
F
2017/04/28 18:25:15
Done.
| |
| 34 @SuppressLint("PackageManagerGetSignatures") | |
| 32 public PackageInfo getPackageInfoWithSignatures(String packageName) { | 35 public PackageInfo getPackageInfoWithSignatures(String packageName) { |
| 33 try { | 36 try { |
| 34 return ContextUtils.getApplicationContext().getPackageManager().getP ackageInfo( | 37 return ContextUtils.getApplicationContext().getPackageManager().getP ackageInfo( |
| 35 packageName, PackageManager.GET_SIGNATURES); | 38 packageName, PackageManager.GET_SIGNATURES); |
| 36 } catch (NameNotFoundException e) { | 39 } catch (NameNotFoundException e) { |
| 37 return null; | 40 return null; |
| 38 } | 41 } |
| 39 } | 42 } |
| 40 | 43 |
| 41 /** | 44 /** |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 130 try { | 133 try { |
| 131 resources = ContextUtils.getApplicationContext() | 134 resources = ContextUtils.getApplicationContext() |
| 132 .getPackageManager() | 135 .getPackageManager() |
| 133 .getResourcesForApplication(applicationInfo); | 136 .getResourcesForApplication(applicationInfo); |
| 134 } catch (NameNotFoundException e) { | 137 } catch (NameNotFoundException e) { |
| 135 return null; | 138 return null; |
| 136 } | 139 } |
| 137 return resources; | 140 return resources; |
| 138 } | 141 } |
| 139 } | 142 } |
| OLD | NEW |