Java Code Examples for org.chromium.chrome.browser.util.IntentUtils#safeGetStringExtra()
The following examples show how to use
org.chromium.chrome.browser.util.IntentUtils#safeGetStringExtra() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WebappInfo.java From 365browser with Apache License 2.0 | 6 votes |
/** * Construct a WebappInfo. * @param intent Intent containing info about the app. */ public static WebappInfo create(Intent intent) { String id = IntentUtils.safeGetStringExtra(intent, ShortcutHelper.EXTRA_ID); String icon = IntentUtils.safeGetStringExtra(intent, ShortcutHelper.EXTRA_ICON); String url = urlFromIntent(intent); String scope = IntentUtils.safeGetStringExtra(intent, ShortcutHelper.EXTRA_SCOPE); int displayMode = IntentUtils.safeGetIntExtra( intent, ShortcutHelper.EXTRA_DISPLAY_MODE, WebDisplayMode.STANDALONE); int orientation = IntentUtils.safeGetIntExtra( intent, ShortcutHelper.EXTRA_ORIENTATION, ScreenOrientationValues.DEFAULT); int source = sourceFromIntent(intent); long themeColor = IntentUtils.safeGetLongExtra(intent, ShortcutHelper.EXTRA_THEME_COLOR, ShortcutHelper.MANIFEST_COLOR_INVALID_OR_MISSING); long backgroundColor = IntentUtils.safeGetLongExtra(intent, ShortcutHelper.EXTRA_BACKGROUND_COLOR, ShortcutHelper.MANIFEST_COLOR_INVALID_OR_MISSING); boolean isIconGenerated = IntentUtils.safeGetBooleanExtra(intent, ShortcutHelper.EXTRA_IS_ICON_GENERATED, false); String name = nameFromIntent(intent); String shortName = shortNameFromIntent(intent); return create(id, url, scope, new Icon(icon), name, shortName, displayMode, orientation, source, themeColor, backgroundColor, isIconGenerated); }
Example 2
Source File: DownloadNotificationService.java From delion with Apache License 2.0 | 6 votes |
/** * Checks if an intent requires operations on a download. * @param intent An intent to validate. * @return true if the intent requires actions, or false otherwise. */ static boolean isDownloadOperationIntent(Intent intent) { if (intent == null) return false; if (ACTION_DOWNLOAD_RESUME_ALL.equals(intent.getAction())) return true; if (!ACTION_DOWNLOAD_CANCEL.equals(intent.getAction()) && !ACTION_DOWNLOAD_RESUME.equals(intent.getAction()) && !ACTION_DOWNLOAD_PAUSE.equals(intent.getAction())) { return false; } if (!intent.hasExtra(EXTRA_DOWNLOAD_NOTIFICATION_ID) || !intent.hasExtra(EXTRA_DOWNLOAD_FILE_NAME) || !intent.hasExtra(EXTRA_DOWNLOAD_GUID)) { return false; } final int notificationId = IntentUtils.safeGetIntExtra(intent, EXTRA_DOWNLOAD_NOTIFICATION_ID, -1); if (notificationId == -1) return false; final String fileName = IntentUtils.safeGetStringExtra(intent, EXTRA_DOWNLOAD_FILE_NAME); if (fileName == null) return false; final String guid = IntentUtils.safeGetStringExtra(intent, EXTRA_DOWNLOAD_GUID); if (!DownloadSharedPreferenceEntry.isValidGUID(guid)) return false; return true; }
Example 3
Source File: WebApkInfo.java From AndroidChromium with Apache License 2.0 | 6 votes |
/** * Constructs a WebApkInfo from the passed in Intent and <meta-data> in the WebAPK's Android * manifest. * @param intent Intent containing info about the app. */ public static WebApkInfo create(Intent intent) { String webApkPackageName = IntentUtils.safeGetStringExtra(intent, ShortcutHelper.EXTRA_WEBAPK_PACKAGE_NAME); if (TextUtils.isEmpty(webApkPackageName)) { return null; } String url = urlFromIntent(intent); int source = sourceFromIntent(intent); // 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. return WebApkMetaDataUtils.extractWebappInfoFromWebApk(webApkPackageName, url, source); }
Example 4
Source File: WebApkInfo.java From 365browser with Apache License 2.0 | 6 votes |
/** * Constructs a WebApkInfo from the passed in Intent and <meta-data> in the WebAPK's Android * manifest. * @param intent Intent containing info about the app. */ public static WebApkInfo create(Intent intent) { String webApkPackageName = IntentUtils.safeGetStringExtra(intent, WebApkConstants.EXTRA_WEBAPK_PACKAGE_NAME); if (TextUtils.isEmpty(webApkPackageName)) { return null; } String url = urlFromIntent(intent); int source = sourceFromIntent(intent); // Force navigation if the extra is not specified to avoid breaking deep linking for old // WebAPKs which don't specify the {@link WebApkConstants#EXTRA_WEBAPK_FORCE_NAVIGATION} // intent extra. boolean forceNavigation = IntentUtils.safeGetBooleanExtra( intent, WebApkConstants.EXTRA_WEBAPK_FORCE_NAVIGATION, true); return create(webApkPackageName, url, source, forceNavigation); }
Example 5
Source File: WebappInfo.java From AndroidChromium with Apache License 2.0 | 6 votes |
/** * Construct a WebappInfo. * @param intent Intent containing info about the app. */ public static WebappInfo create(Intent intent) { String id = IntentUtils.safeGetStringExtra(intent, ShortcutHelper.EXTRA_ID); String icon = IntentUtils.safeGetStringExtra(intent, ShortcutHelper.EXTRA_ICON); String url = urlFromIntent(intent); String scope = IntentUtils.safeGetStringExtra(intent, ShortcutHelper.EXTRA_SCOPE); int displayMode = IntentUtils.safeGetIntExtra( intent, ShortcutHelper.EXTRA_DISPLAY_MODE, WebDisplayMode.Standalone); int orientation = IntentUtils.safeGetIntExtra( intent, ShortcutHelper.EXTRA_ORIENTATION, ScreenOrientationValues.DEFAULT); int source = sourceFromIntent(intent); long themeColor = IntentUtils.safeGetLongExtra(intent, ShortcutHelper.EXTRA_THEME_COLOR, ShortcutHelper.MANIFEST_COLOR_INVALID_OR_MISSING); long backgroundColor = IntentUtils.safeGetLongExtra(intent, ShortcutHelper.EXTRA_BACKGROUND_COLOR, ShortcutHelper.MANIFEST_COLOR_INVALID_OR_MISSING); boolean isIconGenerated = IntentUtils.safeGetBooleanExtra(intent, ShortcutHelper.EXTRA_IS_ICON_GENERATED, false); String name = nameFromIntent(intent); String shortName = shortNameFromIntent(intent); return create(id, url, scope, icon, name, shortName, displayMode, orientation, source, themeColor, backgroundColor, isIconGenerated); }
Example 6
Source File: IntentHandler.java From delion with Apache License 2.0 | 5 votes |
/** * Determines what App was used to fire this Intent. * @param packageName Package name of this application. * @param intent Intent that was used to launch Chrome. * @return ExternalAppId representing the app. */ public static ExternalAppId determineExternalIntentSource(String packageName, Intent intent) { String appId = IntentUtils.safeGetStringExtra(intent, Browser.EXTRA_APPLICATION_ID); ExternalAppId externalId = ExternalAppId.OTHER; if (appId == null) { String url = getUrlFromIntent(intent); if (url != null && url.startsWith(TWITTER_LINK_PREFIX)) { externalId = ExternalAppId.TWITTER; } else if (url != null && url.startsWith(FACEBOOK_LINK_PREFIX)) { externalId = ExternalAppId.FACEBOOK; } else if (url != null && url.startsWith(NEWS_LINK_PREFIX)) { externalId = ExternalAppId.NEWS; } } else { if (appId.equals(PACKAGE_PLUS)) { externalId = ExternalAppId.PLUS; } else if (appId.equals(PACKAGE_GMAIL)) { externalId = ExternalAppId.GMAIL; } else if (appId.equals(PACKAGE_HANGOUTS)) { externalId = ExternalAppId.HANGOUTS; } else if (appId.equals(PACKAGE_MESSENGER)) { externalId = ExternalAppId.MESSENGER; } else if (appId.equals(PACKAGE_LINE)) { externalId = ExternalAppId.LINE; } else if (appId.equals(PACKAGE_WHATSAPP)) { externalId = ExternalAppId.WHATSAPP; } else if (appId.equals(PACKAGE_GSA)) { externalId = ExternalAppId.GSA; } else if (appId.equals(packageName)) { externalId = ExternalAppId.CHROME; } } return externalId; }
Example 7
Source File: DownloadNotificationService.java From 365browser with Apache License 2.0 | 5 votes |
/** * @param intent The {@link Intent} to pull from and build a {@link ContentId}. * @return A {@link ContentId} built by pulling extras from {@code intent}. This will be * {@code null} if {@code intent} is missing any required extras. */ public static ContentId getContentIdFromIntent(Intent intent) { if (!intent.hasExtra(EXTRA_DOWNLOAD_CONTENTID_ID) || !intent.hasExtra(EXTRA_DOWNLOAD_CONTENTID_NAMESPACE)) { return null; } return new ContentId( IntentUtils.safeGetStringExtra(intent, EXTRA_DOWNLOAD_CONTENTID_NAMESPACE), IntentUtils.safeGetStringExtra(intent, EXTRA_DOWNLOAD_CONTENTID_ID)); }
Example 8
Source File: DownloadBroadcastReceiver.java From 365browser with Apache License 2.0 | 5 votes |
/** * Called to open a particular download item. Falls back to opening Download Home. * @param context Context of the receiver. * @param intent Intent from the android DownloadManager. */ private void openDownload(final Context context, Intent intent) { int notificationId = IntentUtils.safeGetIntExtra( intent, NotificationConstants.EXTRA_NOTIFICATION_ID, -1); DownloadNotificationService.hideDanglingSummaryNotification(context, notificationId); long ids[] = intent.getLongArrayExtra(DownloadManager.EXTRA_NOTIFICATION_CLICK_DOWNLOAD_IDS); if (ids == null || ids.length == 0) { DownloadManagerService.openDownloadsPage(context); return; } long id = ids[0]; Uri uri = DownloadManagerDelegate.getContentUriFromDownloadManager(context, id); if (uri == null) { DownloadManagerService.openDownloadsPage(context); return; } String downloadFilename = IntentUtils.safeGetStringExtra( intent, DownloadNotificationService.EXTRA_DOWNLOAD_FILE_PATH); boolean isSupportedMimeType = IntentUtils.safeGetBooleanExtra( intent, DownloadNotificationService.EXTRA_IS_SUPPORTED_MIME_TYPE, false); boolean isOffTheRecord = IntentUtils.safeGetBooleanExtra( intent, DownloadNotificationService.EXTRA_IS_OFF_THE_RECORD, false); ContentId contentId = DownloadNotificationService.getContentIdFromIntent(intent); DownloadManagerService.openDownloadedContent( context, downloadFilename, isSupportedMimeType, isOffTheRecord, contentId.id, id); }
Example 9
Source File: ExternalNavigationHandler.java From delion with Apache License 2.0 | 5 votes |
/** * Determines whether the URL needs to be sent as an intent to the system, * and sends it, if appropriate. * @return Whether the URL generated an intent, caused a navigation in * current tab, or wasn't handled at all. */ public OverrideUrlLoadingResult shouldOverrideUrlLoading(ExternalNavigationParams params) { Intent intent; // Perform generic parsing of the URI to turn it into an Intent. try { intent = Intent.parseUri(params.getUrl(), Intent.URI_INTENT_SCHEME); } catch (Exception ex) { Log.w(TAG, "Bad URI %s", params.getUrl(), ex); return OverrideUrlLoadingResult.NO_OVERRIDE; } boolean hasBrowserFallbackUrl = false; String browserFallbackUrl = IntentUtils.safeGetStringExtra(intent, EXTRA_BROWSER_FALLBACK_URL); if (browserFallbackUrl != null && UrlUtilities.isValidForIntentFallbackNavigation(browserFallbackUrl)) { hasBrowserFallbackUrl = true; } else { browserFallbackUrl = null; } long time = SystemClock.elapsedRealtime(); OverrideUrlLoadingResult result = shouldOverrideUrlLoadingInternal( params, intent, hasBrowserFallbackUrl, browserFallbackUrl); RecordHistogram.recordTimesHistogram("Android.StrictMode.OverrideUrlLoadingTime", SystemClock.elapsedRealtime() - time, TimeUnit.MILLISECONDS); if (result == OverrideUrlLoadingResult.NO_OVERRIDE && hasBrowserFallbackUrl && (params.getRedirectHandler() == null // For instance, if this is a chained fallback URL, we ignore it. || !params.getRedirectHandler().shouldNotOverrideUrlLoading())) { return clobberCurrentTabWithFallbackUrl(browserFallbackUrl, params); } return result; }
Example 10
Source File: IntentHandler.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * Extracts referrer Uri from intent, if supplied. * @param intent The intent to use. * @return The referrer Uri. */ private static Uri getReferrer(Intent intent) { Uri referrer = IntentUtils.safeGetParcelableExtra(intent, Intent.EXTRA_REFERRER); if (referrer != null) { return referrer; } String referrerName = IntentUtils.safeGetStringExtra(intent, Intent.EXTRA_REFERRER_NAME); if (referrerName != null) { return Uri.parse(referrerName); } return null; }
Example 11
Source File: IntentHandler.java From delion with Apache License 2.0 | 5 votes |
public boolean handleWebSearchIntent(Intent intent) { if (intent == null) return false; String query = null; final String action = intent.getAction(); if (Intent.ACTION_SEARCH.equals(action) || MediaStore.INTENT_ACTION_MEDIA_SEARCH.equals(action)) { query = IntentUtils.safeGetStringExtra(intent, SearchManager.QUERY); } if (query == null || TextUtils.isEmpty(query)) return false; mDelegate.processWebSearchIntent(query); return true; }
Example 12
Source File: IntentHandler.java From delion with Apache License 2.0 | 5 votes |
/** * Extracts the URL from voice search result intent. * @return URL if it was found, null otherwise. */ static String getUrlFromVoiceSearchResult(Intent intent) { if (!RecognizerResultsIntent.ACTION_VOICE_SEARCH_RESULTS.equals(intent.getAction())) { return null; } ArrayList<String> results = IntentUtils.safeGetStringArrayListExtra( intent, RecognizerResultsIntent.EXTRA_VOICE_SEARCH_RESULT_STRINGS); // Allow specifying a single voice result via the command line during testing (as the // 'am' command does not allow specifying an array of strings). if (results == null && sTestIntentsEnabled) { String testResult = IntentUtils.safeGetStringExtra( intent, RecognizerResultsIntent.EXTRA_VOICE_SEARCH_RESULT_STRINGS); if (testResult != null) { results = new ArrayList<String>(); results.add(testResult); } } if (results == null || results.size() == 0) return null; String query = results.get(0); String url = AutocompleteController.nativeQualifyPartialURLQuery(query); if (url == null) { List<String> urls = IntentUtils.safeGetStringArrayListExtra( intent, RecognizerResultsIntent.EXTRA_VOICE_SEARCH_RESULT_URLS); if (urls != null && urls.size() > 0) { url = urls.get(0); } else { url = TemplateUrlService.getInstance().getUrlForVoiceSearchQuery(query); } } return url; }
Example 13
Source File: IntentHandler.java From AndroidChromium with Apache License 2.0 | 5 votes |
public boolean handleWebSearchIntent(Intent intent) { if (intent == null) return false; String query = null; final String action = intent.getAction(); if (Intent.ACTION_SEARCH.equals(action) || MediaStore.INTENT_ACTION_MEDIA_SEARCH.equals(action)) { query = IntentUtils.safeGetStringExtra(intent, SearchManager.QUERY); } if (query == null || TextUtils.isEmpty(query)) return false; mDelegate.processWebSearchIntent(query); return true; }
Example 14
Source File: WebappInfo.java From delion with Apache License 2.0 | 5 votes |
public static int orientationFromIntent(Intent intent) { String orientation = IntentUtils.safeGetStringExtra(intent, WebApkConstants.EXTRA_WEBAPK_ORIENTATION); if (orientation == null) { return IntentUtils.safeGetIntExtra( intent, ShortcutHelper.EXTRA_ORIENTATION, ScreenOrientationValues.DEFAULT); } // {@link orientation} should be one of // w3c.github.io/screen-orientation/#orientationlocktype-enum if (orientation.equals("any")) { return ScreenOrientationValues.ANY; } else if (orientation.equals("natural")) { return ScreenOrientationValues.NATURAL; } else if (orientation.equals("landscape")) { return ScreenOrientationValues.LANDSCAPE; } else if (orientation.equals("landscape-primary")) { return ScreenOrientationValues.LANDSCAPE_PRIMARY; } else if (orientation.equals("landscape-secondary")) { return ScreenOrientationValues.LANDSCAPE_SECONDARY; } else if (orientation.equals("portrait")) { return ScreenOrientationValues.PORTRAIT; } else if (orientation.equals("portrait-primary")) { return ScreenOrientationValues.PORTRAIT_PRIMARY; } else if (orientation.equals("portrait-secondary")) { return ScreenOrientationValues.PORTRAIT_SECONDARY; } else { return ScreenOrientationValues.DEFAULT; } }
Example 15
Source File: IntentHandler.java From 365browser with Apache License 2.0 | 5 votes |
private void recordExternalIntentSourceUMA(Intent intent) { ExternalAppId externalId = determineExternalIntentSource(mPackageName, intent); RecordHistogram.recordEnumeratedHistogram("MobileIntent.PageLoadDueToExternalApp", externalId.ordinal(), ExternalAppId.INDEX_BOUNDARY.ordinal()); if (externalId == ExternalAppId.OTHER) { String appId = IntentUtils.safeGetStringExtra(intent, Browser.EXTRA_APPLICATION_ID); if (!TextUtils.isEmpty(appId)) { RapporServiceBridge.sampleString("Android.PageLoadDueToExternalApp", appId); } } }
Example 16
Source File: DownloadNotificationService.java From delion with Apache License 2.0 | 5 votes |
/** * Retrives DownloadSharedPreferenceEntry from a download action intent. * @param intent Intent that contains the download action. */ private DownloadSharedPreferenceEntry getDownloadEntryFromIntent(Intent intent) { if (intent.getAction() == ACTION_DOWNLOAD_RESUME_ALL) return null; String guid = IntentUtils.safeGetStringExtra( intent, DownloadNotificationService.EXTRA_DOWNLOAD_GUID); DownloadSharedPreferenceEntry entry = getDownloadSharedPreferenceEntry(guid); if (entry != null) return entry; int notificationId = IntentUtils.safeGetIntExtra( intent, DownloadNotificationService.EXTRA_DOWNLOAD_NOTIFICATION_ID, -1); String fileName = IntentUtils.safeGetStringExtra( intent, DownloadNotificationService.EXTRA_DOWNLOAD_FILE_NAME); boolean metered = DownloadManagerService.isActiveNetworkMetered(mContext); return new DownloadSharedPreferenceEntry(notificationId, true, metered, guid, fileName); }
Example 17
Source File: WebappInfo.java From delion with Apache License 2.0 | 4 votes |
public static String shortNameFromIntent(Intent intent) { String shortName = IntentUtils.safeGetStringExtra(intent, ShortcutHelper.EXTRA_SHORT_NAME); return shortName == null ? titleFromIntent(intent) : shortName; }
Example 18
Source File: WebappInfo.java From delion with Apache License 2.0 | 4 votes |
public static String nameFromIntent(Intent intent) { String name = IntentUtils.safeGetStringExtra(intent, ShortcutHelper.EXTRA_NAME); return name == null ? titleFromIntent(intent) : name; }
Example 19
Source File: WebappDataStorage.java From 365browser with Apache License 2.0 | 4 votes |
/** * Updates the data stored in this object to match that in the supplied intent. * @param shortcutIntent The intent to pull web app data from. */ public void updateFromShortcutIntent(Intent shortcutIntent) { if (shortcutIntent == null) return; SharedPreferences.Editor editor = mPreferences.edit(); boolean updated = false; // The URL and scope may have been deleted by the user clearing their history. Check whether // they are present, and update if necessary. String url = mPreferences.getString(KEY_URL, URL_INVALID); if (url.equals(URL_INVALID)) { url = IntentUtils.safeGetStringExtra(shortcutIntent, ShortcutHelper.EXTRA_URL); editor.putString(KEY_URL, url); updated = true; } if (mPreferences.getString(KEY_SCOPE, URL_INVALID).equals(URL_INVALID)) { String scope = IntentUtils.safeGetStringExtra( shortcutIntent, ShortcutHelper.EXTRA_SCOPE); if (scope == null) { scope = ShortcutHelper.getScopeFromUrl(url); } editor.putString(KEY_SCOPE, scope); updated = true; } // For all other fields, assume that if the version key is present and equal to // ShortcutHelper.WEBAPP_SHORTCUT_VERSION, then all fields are present and do not need to be // updated. All fields except for the last used time, scope, and URL are either set or // cleared together. if (mPreferences.getInt(KEY_VERSION, VERSION_INVALID) != ShortcutHelper.WEBAPP_SHORTCUT_VERSION) { editor.putString(KEY_NAME, IntentUtils.safeGetStringExtra( shortcutIntent, ShortcutHelper.EXTRA_NAME)); editor.putString(KEY_SHORT_NAME, IntentUtils.safeGetStringExtra( shortcutIntent, ShortcutHelper.EXTRA_SHORT_NAME)); editor.putString(KEY_ICON, IntentUtils.safeGetStringExtra( shortcutIntent, ShortcutHelper.EXTRA_ICON)); editor.putInt(KEY_VERSION, ShortcutHelper.WEBAPP_SHORTCUT_VERSION); // "Standalone" was the original assumed default for all web apps. editor.putInt(KEY_DISPLAY_MODE, IntentUtils.safeGetIntExtra(shortcutIntent, ShortcutHelper.EXTRA_DISPLAY_MODE, WebDisplayMode.STANDALONE)); editor.putInt(KEY_ORIENTATION, IntentUtils.safeGetIntExtra( shortcutIntent, ShortcutHelper.EXTRA_ORIENTATION, ScreenOrientationValues.DEFAULT)); editor.putLong(KEY_THEME_COLOR, IntentUtils.safeGetLongExtra( shortcutIntent, ShortcutHelper.EXTRA_THEME_COLOR, ShortcutHelper.MANIFEST_COLOR_INVALID_OR_MISSING)); editor.putLong(KEY_BACKGROUND_COLOR, IntentUtils.safeGetLongExtra( shortcutIntent, ShortcutHelper.EXTRA_BACKGROUND_COLOR, ShortcutHelper.MANIFEST_COLOR_INVALID_OR_MISSING)); editor.putBoolean(KEY_IS_ICON_GENERATED, IntentUtils.safeGetBooleanExtra( shortcutIntent, ShortcutHelper.EXTRA_IS_ICON_GENERATED, false)); editor.putString(KEY_ACTION, shortcutIntent.getAction()); String webApkPackageName = IntentUtils.safeGetStringExtra( shortcutIntent, WebApkConstants.EXTRA_WEBAPK_PACKAGE_NAME); editor.putString(KEY_WEBAPK_PACKAGE_NAME, webApkPackageName); if (TextUtils.isEmpty(webApkPackageName)) { editor.putInt(KEY_SOURCE, IntentUtils.safeGetIntExtra(shortcutIntent, ShortcutHelper.EXTRA_SOURCE, ShortcutSource.UNKNOWN)); } updated = true; } if (updated) editor.apply(); }
Example 20
Source File: WebappDataStorage.java From delion with Apache License 2.0 | 4 votes |
/** * Updates the data stored in this object to match that in the supplied intent. * @param shortcutIntent The intent to pull web app data from. */ public void updateFromShortcutIntent(Intent shortcutIntent) { if (shortcutIntent == null) return; SharedPreferences.Editor editor = mPreferences.edit(); boolean updated = false; // The URL and scope may have been deleted by the user clearing their history. Check whether // they are present, and update if necessary. String url = mPreferences.getString(KEY_URL, URL_INVALID); if (url.equals(URL_INVALID)) { url = IntentUtils.safeGetStringExtra(shortcutIntent, ShortcutHelper.EXTRA_URL); editor.putString(KEY_URL, url); updated = true; } if (mPreferences.getString(KEY_SCOPE, URL_INVALID).equals(URL_INVALID)) { String scope = IntentUtils.safeGetStringExtra( shortcutIntent, ShortcutHelper.EXTRA_SCOPE); if (scope == null) { scope = ShortcutHelper.getScopeFromUrl(url); } editor.putString(KEY_SCOPE, scope); updated = true; } // For all other fields, assume that if the version key is present and equal to // ShortcutHelper.WEBAPP_SHORTCUT_VERSION, then all fields are present and do not need to be // updated. All fields except for the last used time, scope, and URL are either set or // cleared together. if (mPreferences.getInt(KEY_VERSION, VERSION_INVALID) != ShortcutHelper.WEBAPP_SHORTCUT_VERSION) { editor.putString(KEY_NAME, IntentUtils.safeGetStringExtra( shortcutIntent, ShortcutHelper.EXTRA_NAME)); editor.putString(KEY_SHORT_NAME, IntentUtils.safeGetStringExtra( shortcutIntent, ShortcutHelper.EXTRA_SHORT_NAME)); editor.putString(KEY_ICON, IntentUtils.safeGetStringExtra( shortcutIntent, ShortcutHelper.EXTRA_ICON)); editor.putInt(KEY_VERSION, ShortcutHelper.WEBAPP_SHORTCUT_VERSION); // "Standalone" was the original assumed default for all web apps. editor.putInt(KEY_DISPLAY_MODE, IntentUtils.safeGetIntExtra( shortcutIntent, ShortcutHelper.EXTRA_DISPLAY_MODE, WebDisplayMode.Standalone)); editor.putInt(KEY_ORIENTATION, IntentUtils.safeGetIntExtra( shortcutIntent, ShortcutHelper.EXTRA_ORIENTATION, ScreenOrientationValues.DEFAULT)); editor.putLong(KEY_THEME_COLOR, IntentUtils.safeGetLongExtra( shortcutIntent, ShortcutHelper.EXTRA_THEME_COLOR, ShortcutHelper.MANIFEST_COLOR_INVALID_OR_MISSING)); editor.putLong(KEY_BACKGROUND_COLOR, IntentUtils.safeGetLongExtra( shortcutIntent, ShortcutHelper.EXTRA_BACKGROUND_COLOR, ShortcutHelper.MANIFEST_COLOR_INVALID_OR_MISSING)); editor.putBoolean(KEY_IS_ICON_GENERATED, IntentUtils.safeGetBooleanExtra( shortcutIntent, ShortcutHelper.EXTRA_IS_ICON_GENERATED, false)); editor.putString(KEY_ACTION, shortcutIntent.getAction()); editor.putInt(KEY_SOURCE, IntentUtils.safeGetIntExtra( shortcutIntent, ShortcutHelper.EXTRA_SOURCE, ShortcutSource.UNKNOWN)); updated = true; } if (updated) editor.apply(); }