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

Unified Diff: chrome/android/webapk/libs/common/src/org/chromium/webapk/lib/common/WebApkUtils.java

Issue 2149873002: Move most of WebApkUtils' methods from webapk.lib.common to webapk.shell_apk (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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/webapk/libs/common/src/org/chromium/webapk/lib/common/WebApkUtils.java
diff --git a/chrome/android/webapk/libs/common/src/org/chromium/webapk/lib/common/WebApkUtils.java b/chrome/android/webapk/libs/common/src/org/chromium/webapk/lib/common/WebApkUtils.java
deleted file mode 100644
index f1a05bc7a9697af53562e00c8f25b6e58def7a9b..0000000000000000000000000000000000000000
--- a/chrome/android/webapk/libs/common/src/org/chromium/webapk/lib/common/WebApkUtils.java
+++ /dev/null
@@ -1,91 +0,0 @@
-// Copyright 2016 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.webapk.lib.common;
-
-import android.content.Context;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.PackageManager;
-import android.content.pm.PackageManager.NameNotFoundException;
-import android.os.Bundle;
-
-/**
- * Contains utility methods for interacting with WebAPKs.
- */
-public class WebApkUtils {
-
- /**
- * Caches the value read from Application Metadata which specifies the host browser's package
- * name.
- */
- private static String sHostPackage;
-
- /**
- * Returns a Context for the host browser that was specified when building the WebAPK.
- * @param context A context.
- * @return The remote context. Returns null on an error.
- */
- public static Context getHostBrowserContext(Context context) {
- try {
- String hostPackage = getHostBrowserPackageName(context);
- return context.getApplicationContext().createPackageContext(
- hostPackage,
- Context.CONTEXT_IGNORE_SECURITY | Context.CONTEXT_INCLUDE_CODE);
- } catch (NameNotFoundException e) {
- e.printStackTrace();
- }
- return null;
- }
-
- /**
- * Returns the package name for the host browser that was specified when building the WebAPK.
- * @param context A context.
- * @return The package name. Returns null on an error.
- */
- public static String getHostBrowserPackageName(Context context) {
- if (sHostPackage != null) return sHostPackage;
- String hostPackage = null;
- try {
- ApplicationInfo ai = context.getPackageManager().getApplicationInfo(
- context.getPackageName(), PackageManager.GET_META_DATA);
- Bundle bundle = ai.metaData;
- hostPackage = bundle.getString("runtimeHost");
- } catch (NameNotFoundException e) {
- e.printStackTrace();
- }
- // Set {@link sHostPackage} to a non-null value so that the value is computed only once.
- sHostPackage = hostPackage != null ? hostPackage : "";
- return sHostPackage;
- }
-
- /**
- * Returns the uid for the host browser that was specified when building the WebAPK.
- * @param context A context.
- * @return The application uid. Returns -1 on an error.
- */
- public static int getHostBrowserUid(Context context) {
- String hostPackageName = getHostBrowserPackageName(context);
- if (hostPackageName == null) {
- return -1;
- }
- try {
- PackageManager packageManager = context.getPackageManager();
- ApplicationInfo appInfo = packageManager.getApplicationInfo(
- hostPackageName, PackageManager.GET_META_DATA);
- return appInfo.uid;
- } catch (NameNotFoundException e) {
- e.printStackTrace();
- }
- return -1;
- }
-
- /**
- * Returns name of "Runtime Dex" asset in Chrome APK based on version.
- * @param version
- * @return Dex asset name.
- */
- public static String getRuntimeDexName(int version) {
- return "webapk" + version + ".dex";
- }
-}

Powered by Google App Engine
This is Rietveld 408576698