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

Unified Diff: base/android/java/src/org/chromium/base/PackageUtils.java

Issue 1647803004: Move base to DEPS (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 11 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: 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
deleted file mode 100644
index b1cb29e3f76859ca1fc6526a66b6be74a46c351d..0000000000000000000000000000000000000000
--- a/base/android/java/src/org/chromium/base/PackageUtils.java
+++ /dev/null
@@ -1,55 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-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.
- * @param packageName Name of the package to find.
- * @return The package's version code if found, -1 otherwise.
- */
- public static int getPackageVersion(Context context, String packageName) {
- int versionCode = -1;
- PackageManager pm = context.getPackageManager();
- try {
- PackageInfo packageInfo = pm.getPackageInfo(packageName, 0);
- if (packageInfo != null) versionCode = packageInfo.versionCode;
- } catch (PackageManager.NameNotFoundException e) {
- // Do nothing, versionCode stays -1
- }
- return versionCode;
- }
-
- private PackageUtils() {
- // Hide constructor
- }
-}
« no previous file with comments | « base/android/java/src/org/chromium/base/ObserverList.java ('k') | base/android/java/src/org/chromium/base/PathService.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698