| Index: base/android/java/src/org/chromium/base/PackageUtils.java
|
| diff --git a/base/android/java/src/org/chromium/base/PackageUtils.java b/base/android/java/src/org/chromium/base/PackageUtils.java
|
| index ab554cdc45ad7c7ca1e03bcd17a1d13d756ac102..b1cb29e3f76859ca1fc6526a66b6be74a46c351d 100644
|
| --- a/base/android/java/src/org/chromium/base/PackageUtils.java
|
| +++ b/base/android/java/src/org/chromium/base/PackageUtils.java
|
| @@ -7,12 +7,30 @@ package org.chromium.base;
|
| import android.content.Context;
|
| import android.content.pm.PackageInfo;
|
| import android.content.pm.PackageManager;
|
| +import android.content.pm.PackageManager.NameNotFoundException;
|
|
|
| /**
|
| * This class provides package checking related methods.
|
| */
|
| public class PackageUtils {
|
| /**
|
| + * Retrieves the PackageInfo object for this application.
|
| + *
|
| + * @param context Any context.
|
| + * @return The PackageInfo object for this application.
|
| + */
|
| + public static PackageInfo getOwnPackageInfo(Context context) {
|
| + PackageManager manager = context.getPackageManager();
|
| + try {
|
| + String packageName = context.getApplicationContext().getPackageName();
|
| + return manager.getPackageInfo(packageName, 0);
|
| + } catch (NameNotFoundException e) {
|
| + // Should never happen.
|
| + throw new AssertionError("Failed to retrieve own package info");
|
| + }
|
| + }
|
| +
|
| + /**
|
| * Retrieves the version of the given package installed on the device.
|
| *
|
| * @param context Any context.
|
|
|