本文整理汇总了Java中org.chromium.webapk.lib.common.WebApkMetaDataKeys类的典型用法代码示例。如果您正苦于以下问题:Java WebApkMetaDataKeys类的具体用法?Java WebApkMetaDataKeys怎么用?Java WebApkMetaDataKeys使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
WebApkMetaDataKeys类属于org.chromium.webapk.lib.common包,在下文中一共展示了WebApkMetaDataKeys类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getIconMurmur2HashFromMetaData
import org.chromium.webapk.lib.common.WebApkMetaDataKeys; //导入依赖的package包/类
/**
* Extracts icon murmur2 hash from the WebAPK's meta data. Return value is a string because the
* hash can take values up to 2^64-1 which is greater than {@link Long#MAX_VALUE}.
* @param metaData WebAPK meta data to extract the hash from.
* @return The hash. An empty string if the hash could not be extracted.
*/
public static String getIconMurmur2HashFromMetaData(Bundle metaData) {
String value = metaData.getString(WebApkMetaDataKeys.ICON_MURMUR2_HASH);
// The value should be terminated with 'L' to force the value to be a string.
if (value == null || !value.endsWith("L")) {
return "";
}
return value.substring(0, value.length() - 1);
}
示例2: getIconUrlAndIconMurmur2HashMap
import org.chromium.webapk.lib.common.WebApkMetaDataKeys; //导入依赖的package包/类
/**
* Extract the icon URLs and icon hashes from the WebAPK's meta data, and returns a map of these
* {URL, hash} pairs. The icon URLs/icon hashes are stored in a single meta data tag in the
* WebAPK's AndroidManifest.xml as following:
* "URL1 hash1 URL2 hash2 URL3 hash3..."
*/
private static Map<String, String> getIconUrlAndIconMurmur2HashMap(Bundle metaData) {
Map<String, String> iconUrlAndIconMurmur2HashMap = new HashMap<String, String>();
String iconUrlsAndIconMurmur2Hashes = metaData.getString(
WebApkMetaDataKeys.ICON_URLS_AND_ICON_MURMUR2_HASHES);
if (TextUtils.isEmpty(iconUrlsAndIconMurmur2Hashes)) {
// Open old WebAPKs which support single icon only.
// TODO(hanxi): crbug.com/665549. Clean up the following code after all the old WebAPKs
// are updated.
String iconUrl = metaData.getString(WebApkMetaDataKeys.ICON_URL);
if (TextUtils.isEmpty(iconUrl)) {
return iconUrlAndIconMurmur2HashMap;
}
iconUrlAndIconMurmur2HashMap.put(iconUrl, getIconMurmur2HashFromMetaData(metaData));
return iconUrlAndIconMurmur2HashMap;
}
// Parse the metadata tag which contains "URL1 hash1 URL2 hash2 URL3 hash3..." pairs and
// create a hash map.
// TODO(hanxi): crbug.com/666349. Add a test to verify that the icon URLs in WebAPKs'
// AndroidManifest.xml don't contain space.
String[] urlsAndHashes = iconUrlsAndIconMurmur2Hashes.split("[ ]+");
if (urlsAndHashes.length % 2 != 0) {
Log.e(TAG, "The icon URLs and icon murmur2 hashes don't come in pairs.");
return iconUrlAndIconMurmur2HashMap;
}
for (int i = 0; i < urlsAndHashes.length; i += 2) {
iconUrlAndIconMurmur2HashMap.put(urlsAndHashes[i], urlsAndHashes[i + 1]);
}
return iconUrlAndIconMurmur2HashMap;
}
示例3: getIconMurmur2HashFromMetaData
import org.chromium.webapk.lib.common.WebApkMetaDataKeys; //导入依赖的package包/类
/**
* Extracts icon murmur2 hash from the WebAPK's meta data. Return value is a string because the
* hash can take values up to 2^64-1 which is greater than {@link Long#MAX_VALUE}.
* Note: keep this function for supporting old WebAPKs which have single icon only.
* @param metaData WebAPK meta data to extract the hash from.
* @return The hash. An empty string if the hash could not be extracted.
*/
private static String getIconMurmur2HashFromMetaData(Bundle metaData) {
String value = metaData.getString(WebApkMetaDataKeys.ICON_MURMUR2_HASH);
// The value should be terminated with 'L' to force the value to be a string.
if (value == null || !value.endsWith("L")) {
return "";
}
return value.substring(0, value.length() - 1);
}
示例4: create
import org.chromium.webapk.lib.common.WebApkMetaDataKeys; //导入依赖的package包/类
/**
* Constructs a WebApkInfo from the passed in parameters and <meta-data> in the WebAPK's Android
* manifest.
*
* @param webApkPackageName The package name of the WebAPK.
* @param url Url that the WebAPK should navigate to when launched.
* @param source Source that the WebAPK was launched from.
* @param forceNavigation Whether the WebAPK should navigate to {@link url} if it is already
* running.
*/
public static WebApkInfo create(
String webApkPackageName, String url, int source, boolean forceNavigation) {
// Unlike non-WebAPK web apps, WebAPK ids are predictable. A malicious actor may send an
// intent with a valid start URL and arbitrary other data. Only use the start URL, the
// package name and the ShortcutSource from the launch intent and extract the remaining data
// from the <meta-data> in the WebAPK's Android manifest.
Bundle bundle = extractWebApkMetaData(webApkPackageName);
if (bundle == null) {
return null;
}
String name = IntentUtils.safeGetString(bundle, WebApkMetaDataKeys.NAME);
String shortName = IntentUtils.safeGetString(bundle, WebApkMetaDataKeys.SHORT_NAME);
String scope = IntentUtils.safeGetString(bundle, WebApkMetaDataKeys.SCOPE);
int displayMode = displayModeFromString(
IntentUtils.safeGetString(bundle, WebApkMetaDataKeys.DISPLAY_MODE));
int orientation = orientationFromString(
IntentUtils.safeGetString(bundle, WebApkMetaDataKeys.ORIENTATION));
long themeColor = getLongFromMetaData(bundle, WebApkMetaDataKeys.THEME_COLOR,
ShortcutHelper.MANIFEST_COLOR_INVALID_OR_MISSING);
long backgroundColor = getLongFromMetaData(bundle, WebApkMetaDataKeys.BACKGROUND_COLOR,
ShortcutHelper.MANIFEST_COLOR_INVALID_OR_MISSING);
int shellApkVersion =
IntentUtils.safeGetInt(bundle, WebApkMetaDataKeys.SHELL_APK_VERSION, 0);
String manifestUrl = IntentUtils.safeGetString(bundle, WebApkMetaDataKeys.WEB_MANIFEST_URL);
String manifestStartUrl = IntentUtils.safeGetString(bundle, WebApkMetaDataKeys.START_URL);
Map<String, String> iconUrlToMurmur2HashMap = getIconUrlAndIconMurmur2HashMap(bundle);
int iconId = IntentUtils.safeGetInt(bundle, WebApkMetaDataKeys.ICON_ID, 0);
Bitmap icon = decodeImageResource(webApkPackageName, iconId);
return create(WebApkConstants.WEBAPK_ID_PREFIX + webApkPackageName, url, forceNavigation,
scope, new Icon(icon), name, shortName, displayMode, orientation, source,
themeColor, backgroundColor, webApkPackageName, shellApkVersion, manifestUrl,
manifestStartUrl, iconUrlToMurmur2HashMap);
}