Index: chrome/android/webapk/shell_apk/src/org/chromium/webapk/shell_apk/WebApkUtils.java |
diff --git a/chrome/android/webapk/shell_apk/src/org/chromium/webapk/shell_apk/WebApkUtils.java b/chrome/android/webapk/shell_apk/src/org/chromium/webapk/shell_apk/WebApkUtils.java |
index 8fb7235dfef627999a9c96675e65d204ed59e770..ee8949254000675ee4d9d6b1d3a2bbc1ba43f01b 100644 |
--- a/chrome/android/webapk/shell_apk/src/org/chromium/webapk/shell_apk/WebApkUtils.java |
+++ b/chrome/android/webapk/shell_apk/src/org/chromium/webapk/shell_apk/WebApkUtils.java |
@@ -13,9 +13,11 @@ import android.content.pm.PackageManager.NameNotFoundException; |
import android.content.pm.ResolveInfo; |
import android.net.Uri; |
import android.os.Bundle; |
+import android.os.StrictMode; |
import android.text.TextUtils; |
import org.chromium.webapk.lib.common.WebApkConstants; |
+import org.chromium.webapk.lib.common.WebApkHelper; |
import org.chromium.webapk.lib.common.WebApkMetaDataKeys; |
import java.util.ArrayList; |
@@ -101,24 +103,13 @@ public class WebApkUtils { |
/** Returns the <meta-data> value in the Android Manifest for {@link key}. */ |
public static String readMetaDataFromManifest(Context context, String key) { |
- Bundle metadata = readMetaData(context); |
+ Bundle metadata = |
+ WebApkHelper.readMetaData(context.getPackageManager(), context.getPackageName()); |
if (metadata == null) return null; |
return metadata.getString(key); |
} |
- /** Returns the <meta-data> in the Android Manifest. */ |
- public static Bundle readMetaData(Context context) { |
- ApplicationInfo ai = null; |
- try { |
- ai = context.getPackageManager().getApplicationInfo( |
- context.getPackageName(), PackageManager.GET_META_DATA); |
- } catch (NameNotFoundException e) { |
- return null; |
- } |
- return ai.metaData; |
- } |
- |
/** |
* Returns the package name of the host browser to launch the WebAPK, or null if we did not find |
* one. |
@@ -186,9 +177,14 @@ public class WebApkUtils { |
/** Returns the package name of the host browser cached in the SharedPreferences. */ |
public static String getHostBrowserFromSharedPreference(Context context) { |
- SharedPreferences sharedPref = |
- context.getSharedPreferences(WebApkConstants.PREF_PACKAGE, Context.MODE_PRIVATE); |
- return sharedPref.getString(SHARED_PREF_RUNTIME_HOST, null); |
+ StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites(); |
+ try { |
+ SharedPreferences sharedPref = context.getSharedPreferences( |
+ WebApkConstants.PREF_PACKAGE, Context.MODE_PRIVATE); |
+ return sharedPref.getString(SHARED_PREF_RUNTIME_HOST, null); |
+ } finally { |
+ StrictMode.setThreadPolicy(oldPolicy); |
+ } |
} |
/** Returns a set of package names of all the installed browsers on the device. */ |