Java Code Examples for org.chromium.base.BuildInfo#isAtLeastO()
The following examples show how to use
org.chromium.base.BuildInfo#isAtLeastO() .
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: SelectionPopupController.java From 365browser with Apache License 2.0 | 6 votes |
@VisibleForTesting public boolean canPasteAsPlainText() { // String resource "paste_as_plain_text" only exist in O. // Also this is an O feature, we need to make it consistant with TextView. if (!BuildInfo.isAtLeastO()) return false; if (!mCanEditRichlyForPastePopup) return false; ClipboardManager clipMgr = (ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE); if (!clipMgr.hasPrimaryClip()) return false; ClipData clipData = clipMgr.getPrimaryClip(); ClipDescription description = clipData.getDescription(); CharSequence text = clipData.getItemAt(0).getText(); boolean isPlainType = description.hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN); // On Android, Spanned could be copied to Clipboard as plain_text MIME type, but in some // cases, Spanned could have text format, we need to show "paste as plain text" when // that happens. if (isPlainType && (text instanceof Spanned)) { Spanned spanned = (Spanned) text; if (hasStyleSpan(spanned)) return true; } return description.hasMimeType(ClipDescription.MIMETYPE_TEXT_HTML); }
Example 2
Source File: ViewResourceFrameLayout.java From 365browser with Apache License 2.0 | 5 votes |
@Override protected void dispatchDraw(Canvas canvas) { super.dispatchDraw(canvas); // TODO(tedchoc): Switch to a better API when available. crbug.com/681877 if (BuildInfo.isAtLeastO() && isReadyForCapture()) { mResourceAdapter.invalidate(null); } }
Example 3
Source File: InvalidationService.java From 365browser with Apache License 2.0 | 5 votes |
private void startServiceIfPossible(Intent intent) { // The use of background services is restricted when the application is not in foreground // for O. See crbug.com/680812. if (BuildInfo.isAtLeastO()) { try { ContextUtils.getApplicationContext().startService(intent); } catch (IllegalStateException exception) { Log.e(TAG, "Failed to start service from exception: ", exception); } } else { ContextUtils.getApplicationContext().startService(intent); } }
Example 4
Source File: InvalidationClientService.java From 365browser with Apache License 2.0 | 5 votes |
private void startServiceIfPossible(Intent intent) { // The use of background services is restricted when the application is not in foreground // for O. See crbug.com/680812. if (BuildInfo.isAtLeastO()) { try { startService(intent); } catch (IllegalStateException exception) { Log.e(TAG, "Failed to start service from exception: ", exception); } } else { startService(intent); } }
Example 5
Source File: ActivityWindowAndroid.java From 365browser with Apache License 2.0 | 5 votes |
private String getHasRequestedPermissionKey(String permission) { String permissionQueriedKey = permission; // Prior to O, permissions were granted at the group level. Post O, each permission is // granted individually. if (!BuildInfo.isAtLeastO()) { try { // Runtime permissions are controlled at the group level. So when determining // whether we have requested a particular permission before, we should check whether // we have requested any permission in that group as that mimics the logic in the // Android framework. // // e.g. Requesting first the permission ACCESS_FINE_LOCATION will result in Chrome // treating ACCESS_COARSE_LOCATION as if it had already been requested as well. PermissionInfo permissionInfo = getApplicationContext().getPackageManager().getPermissionInfo( permission, PackageManager.GET_META_DATA); if (!TextUtils.isEmpty(permissionInfo.group)) { permissionQueriedKey = permissionInfo.group; } } catch (NameNotFoundException e) { // Unknown permission. Default back to the permission name instead of the group. } } return PERMISSION_QUERIED_KEY_PREFIX + permissionQueriedKey; }
Example 6
Source File: SelectionPopupController.java From 365browser with Apache License 2.0 | 5 votes |
private void updateAssistMenuItem(MenuDescriptor descriptor) { // There is no Assist functionality before Android O. if (!BuildInfo.isAtLeastO() || mAssistMenuItemId == 0) return; // The assist menu item ID has to be equal to android.R.id.textAssist. Until we compile // with Android O SDK where this ID is defined we replace the corresponding inflated // item with an item with the proper ID. // TODO(timav): Use android.R.id.textAssist for the Assist item id once we switch to // Android O SDK and remove |mAssistMenuItemId|. if (mClassificationResult != null && mClassificationResult.hasNamedAction()) { descriptor.addItem(R.id.select_action_menu_assist_items, mAssistMenuItemId, 1, mClassificationResult.label, mClassificationResult.icon); } }
Example 7
Source File: SelectionPopupController.java From 365browser with Apache License 2.0 | 5 votes |
/** * Create {@link SelectionPopupController} instance. * @param context Context for action mode. * @param window WindowAndroid instance. * @param webContents WebContents instance. * @param view Container view. * @param renderCoordinates Coordinates info used to position elements. */ public SelectionPopupController(Context context, WindowAndroid window, WebContents webContents, View view, RenderCoordinates renderCoordinates) { mContext = context; mWindowAndroid = window; mWebContents = webContents; mView = view; mRenderCoordinates = renderCoordinates; // The menu items are allowed by default. mAllowedMenuItems = MENU_ITEM_SHARE | MENU_ITEM_WEB_SEARCH | MENU_ITEM_PROCESS_TEXT; mRepeatingHideRunnable = new Runnable() { @Override public void run() { assert mHidden; final long hideDuration = getDefaultHideDuration(); // Ensure the next hide call occurs before the ActionMode reappears. mView.postDelayed(mRepeatingHideRunnable, hideDuration - 1); hideActionModeTemporarily(hideDuration); } }; mSelectionClient = SmartSelectionClient.create(new SmartSelectionCallback(), window, webContents); // TODO(timav): Use android.R.id.textAssist for the Assist item id once we switch to // Android O SDK and remove |mAssistMenuItemId|. if (BuildInfo.isAtLeastO()) { mAssistMenuItemId = mContext.getResources().getIdentifier("textAssist", "id", "android"); } nativeInit(webContents); }
Example 8
Source File: BrowserAccessibilityManager.java From 365browser with Apache License 2.0 | 5 votes |
/** * Only relevant prior to Android O, see shouldRespectDisplayedPasswordText. */ @CalledByNative boolean shouldExposePasswordText() { ContentResolver contentResolver = mContentViewCore.getContext().getContentResolver(); if (BuildInfo.isAtLeastO()) { return (Settings.System.getInt(contentResolver, Settings.System.TEXT_SHOW_PASSWORD, 1) == 1); } return (Settings.Secure.getInt( contentResolver, Settings.Secure.ACCESSIBILITY_SPEAK_PASSWORD, 0) == 1); }
Example 9
Source File: InvalidationController.java From 365browser with Apache License 2.0 | 5 votes |
private void startServiceIfPossible(Intent intent) { // The use of background services is restricted when the application is not in foreground // for O. See crbug.com/680812. if (BuildInfo.isAtLeastO()) { try { mContext.startService(intent); } catch (IllegalStateException exception) { Log.e(TAG, "Failed to start service from exception: ", exception); } } else { mContext.startService(intent); } }
Example 10
Source File: MediaNotificationManager.java From 365browser with Apache License 2.0 | 5 votes |
@VisibleForTesting void updateNotification(boolean serviceStarting) { if (mService == null) return; if (mMediaNotificationInfo == null) { if (serviceStarting) { finishStartingForegroundService(mService); mService.stopForeground(true /* removeNotification */); } return; } updateMediaSession(); updateNotificationBuilder(); Notification notification = mNotificationBuilder.build(); // On O, finish starting the foreground service nevertheless, or Android will // crash Chrome. boolean foregroundedService = false; if (BuildInfo.isAtLeastO() && serviceStarting) { mService.startForeground(mMediaNotificationInfo.id, notification); foregroundedService = true; } // We keep the service as a foreground service while the media is playing. When it is not, // the service isn't stopped but is no longer in foreground, thus at a lower priority. // While the service is in foreground, the associated notification can't be swipped away. // Moving it back to background allows the user to remove the notification. if (mMediaNotificationInfo.supportsSwipeAway() && mMediaNotificationInfo.isPaused) { mService.stopForeground(false /* removeNotification */); NotificationManagerCompat manager = NotificationManagerCompat.from(getContext()); manager.notify(mMediaNotificationInfo.id, notification); } else if (!foregroundedService) { mService.startForeground(mMediaNotificationInfo.id, notification); } }
Example 11
Source File: MediaNotificationManager.java From 365browser with Apache License 2.0 | 5 votes |
private static void finishStartingForegroundService(ListenerService s) { if (!BuildInfo.isAtLeastO()) return; ChromeNotificationBuilder builder = NotificationBuilderFactory.createChromeNotificationBuilder( true /* preferCompat */, ChannelDefinitions.CHANNEL_ID_MEDIA); s.startForeground(s.getNotificationId(), builder.build()); }
Example 12
Source File: ShortcutHelper.java From 365browser with Apache License 2.0 | 5 votes |
private static boolean isRequestPinShortcutSupported() { if (!sCheckedIfRequestPinShortcutSupported) { if (BuildInfo.isAtLeastO()) { checkIfRequestPinShortcutSupported(); } sCheckedIfRequestPinShortcutSupported = true; } return sIsRequestPinShortcutSupported; }
Example 13
Source File: PackageReplacedBroadcastReceiver.java From 365browser with Apache License 2.0 | 5 votes |
@Override public void onReceive(final Context context, Intent intent) { if (!Intent.ACTION_MY_PACKAGE_REPLACED.equals(intent.getAction())) return; updateChannelsIfNecessary(); if (BuildInfo.isAtLeastO()) return; UpgradeIntentService.startMigrationIfNecessary(context); }
Example 14
Source File: NotificationUmaTracker.java From 365browser with Apache License 2.0 | 5 votes |
/** * Logs {@link android.app.Notification} usage, categorized into {@link SystemNotificationType} * types. Splits the logs by the global enabled state of notifications and also logs the last * notification shown prior to the global notifications state being disabled by the user. * @param type The type of notification that was shown. * @param channelId The id of the notification channel set on the notification. * @see SystemNotificationType */ public void onNotificationShown( @SystemNotificationType int type, @ChannelDefinitions.ChannelId String channelId) { if (!mNotificationManager.areNotificationsEnabled()) { logPotentialBlockedCause(); recordHistogram("Mobile.SystemNotification.Blocked", type); return; } if (BuildInfo.isAtLeastO() && channelId != null && isChannelBlocked(channelId)) { recordHistogram("Mobile.SystemNotification.ChannelBlocked", type); return; } saveLastShownNotification(type); recordHistogram("Mobile.SystemNotification.Shown", type); }
Example 15
Source File: InstantAppsHandler.java From 365browser with Apache License 2.0 | 4 votes |
private boolean handleIncomingIntentInternal( Context context, Intent intent, boolean isCustomTabsIntent, long startTime, boolean isRedirect) { if (!isRedirect && !isCustomTabsIntent && BuildInfo.isAtLeastO()) { Log.i(TAG, "Disabled for Android O+"); return false; } if (isCustomTabsIntent && !IntentUtils.safeGetBooleanExtra( intent, CUSTOM_APPS_INSTANT_APP_EXTRA, false)) { Log.i(TAG, "Not handling with Instant Apps (missing CUSTOM_APPS_INSTANT_APP_EXTRA)"); return false; } if (IntentUtils.safeGetBooleanExtra(intent, DO_NOT_LAUNCH_EXTRA, false) || (BuildInfo.isAtLeastO() && (intent.getFlags() & FLAG_DO_NOT_LAUNCH) != 0)) { maybeRecordFallbackStats(intent); Log.i(TAG, "Not handling with Instant Apps (DO_NOT_LAUNCH_EXTRA)"); return false; } if (IntentUtils.safeGetBooleanExtra( intent, IntentHandler.EXTRA_OPEN_NEW_INCOGNITO_TAB, false) || IntentUtils.safeHasExtra(intent, ShortcutHelper.EXTRA_SOURCE) || isIntentFromChrome(context, intent) || (IntentHandler.getUrlFromIntent(intent) == null)) { Log.i(TAG, "Not handling with Instant Apps (other)"); return false; } // Used to search for the intent handlers. Needs null component to return correct results. Intent intentCopy = new Intent(intent); intentCopy.setComponent(null); Intent selector = intentCopy.getSelector(); if (selector != null) selector.setComponent(null); if (!(isCustomTabsIntent || isChromeDefaultHandler(context)) || ExternalNavigationDelegateImpl.isPackageSpecializedHandler(null, intentCopy)) { // Chrome is not the default browser or a specialized handler exists. Log.i(TAG, "Not handling with Instant Apps because Chrome is not default or " + "there's a specialized handler"); return false; } Intent callbackIntent = new Intent(intent); callbackIntent.putExtra(DO_NOT_LAUNCH_EXTRA, true); callbackIntent.putExtra(INSTANT_APP_START_TIME_EXTRA, startTime); return tryLaunchingInstantApp(context, intent, isCustomTabsIntent, callbackIntent); }
Example 16
Source File: DownloadNotificationService.java From 365browser with Apache License 2.0 | 4 votes |
/** * @return Whether or not this service should be made a foreground service if there are active * downloads. */ @VisibleForTesting static boolean useForegroundService() { return BuildInfo.isAtLeastO(); }
Example 17
Source File: NotificationBuilderFactory.java From 365browser with Apache License 2.0 | 3 votes |
/** * Creates either a Notification.Builder or NotificationCompat.Builder under the hood, wrapped * in our own common interface. * * TODO(crbug.com/704152) Remove this once we've updated to revision 26 of the support library. * Then we can use NotificationCompat.Builder and set the channel directly everywhere. * Although we will still need to ensure the channel is always initialized first. * * @param preferCompat true if a NotificationCompat.Builder is preferred. * A Notification.Builder will be used regardless on Android O. * @param channelId The ID of the channel the notification should be posted to. This channel * will be created if it did not already exist. Must be a known channel within * {@link ChannelsInitializer#ensureInitialized(String)}. */ public static ChromeNotificationBuilder createChromeNotificationBuilder( boolean preferCompat, @ChannelDefinitions.ChannelId String channelId) { Context context = ContextUtils.getApplicationContext(); if (BuildInfo.isAtLeastO()) { return createNotificationBuilderForO(channelId, context); } return preferCompat ? new NotificationCompatBuilder(context) : new NotificationBuilder(context); }
Example 18
Source File: BrowserAccessibilityManager.java From 365browser with Apache License 2.0 | 2 votes |
/** * On Android O and higher, we should respect whatever is displayed * in a password box and report that via accessibility APIs, whether * that's the unobscured password, or all dots. * * Previous to O, shouldExposePasswordText() returns a system setting * that determines whether we should return the unobscured password or all * dots, independent of what was displayed visually. */ @CalledByNative boolean shouldRespectDisplayedPasswordText() { return BuildInfo.isAtLeastO(); }