org.chromium.base.annotations.SuppressFBWarnings Java Examples
The following examples show how to use
org.chromium.base.annotations.SuppressFBWarnings.
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: ChromeBrowserProvider.java From delion with Apache License 2.0 | 6 votes |
/** * Checks whether Chrome is sufficiently initialized to handle a call to the * ChromeBrowserProvider. */ private boolean canHandleContentProviderApiCall() { if (isInUiThread()) return false; ensureUriMatcherInitialized(); if (mNativeChromeBrowserProvider != 0) return true; synchronized (mLoadNativeLock) { ThreadUtils.runOnUiThreadBlocking(new Runnable() { @Override @SuppressFBWarnings("DM_EXIT") public void run() { if (mNativeChromeBrowserProvider != 0) return; try { ChromeBrowserInitializer.getInstance(getContext()) .handleSynchronousStartup(); } catch (ProcessInitException e) { // Chrome browser runs in the background, so exit silently; but do exit, // since otherwise the next attempt to use Chrome will find a broken JNI. System.exit(-1); } ensureNativeSideInitialized(); } }); } return true; }
Example #2
Source File: BookmarkItemsAdapter.java From AndroidChromium with Apache License 2.0 | 6 votes |
@SuppressFBWarnings("BC_UNCONFIRMED_CAST") @Override public void onBindViewHolder(ViewHolder holder, int position) { BookmarkId id = getItem(position); switch (getItemViewType(position)) { case PROMO_HEADER_VIEW: case DIVIDER_VIEW: break; case FOLDER_VIEW: ((BookmarkRow) holder.itemView).setBookmarkId(id); break; case BOOKMARK_VIEW: ((BookmarkRow) holder.itemView).setBookmarkId(id); break; default: assert false : "View type not supported!"; } }
Example #3
Source File: ChromeGcmListenerService.java From delion with Apache License 2.0 | 6 votes |
private void pushMessageReceived(final String from, final Bundle data) { final String bundleSubtype = "subtype"; if (!data.containsKey(bundleSubtype)) { Log.w(TAG, "Received push message with no subtype"); return; } final String appId = data.getString(bundleSubtype); ThreadUtils.runOnUiThread(new Runnable() { @Override @SuppressFBWarnings("DM_EXIT") public void run() { try { ChromeBrowserInitializer.getInstance(getApplicationContext()) .handleSynchronousStartup(); GCMDriver.onMessageReceived(appId, from, data); } catch (ProcessInitException e) { Log.e(TAG, "ProcessInitException while starting the browser process"); // Since the library failed to initialize nothing in the application // can work, so kill the whole application not just the activity. System.exit(-1); } } }); }
Example #4
Source File: GeolocationTracker.java From delion with Apache License 2.0 | 6 votes |
/** * Requests an updated location if the last known location is older than maxAge milliseconds. * * Note: this must be called only on the UI thread. */ @SuppressFBWarnings("LI_LAZY_INIT_UPDATE_STATIC") static void refreshLastKnownLocation(Context context, long maxAge) { ThreadUtils.assertOnUiThread(); // We're still waiting for a location update. if (sListener != null) return; LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); Location location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); if (location == null || getLocationAge(location) > maxAge) { String provider = LocationManager.NETWORK_PROVIDER; if (locationManager.isProviderEnabled(provider)) { sListener = new SelfCancelingListener(locationManager); locationManager.requestSingleUpdate(provider, sListener, null); } } }
Example #5
Source File: CustomTabsConnection.java From delion with Apache License 2.0 | 6 votes |
/** Warmup activities that should only happen once. */ @SuppressFBWarnings("DM_EXIT") private static void initializeBrowser(final Application app) { ThreadUtils.assertOnUiThread(); try { ChromeBrowserInitializer.getInstance(app).handleSynchronousStartup(); } catch (ProcessInitException e) { Log.e(TAG, "ProcessInitException while starting the browser process."); // Cannot do anything without the native library, and cannot show a // dialog to the user. System.exit(-1); } final Context context = app.getApplicationContext(); final ChromeApplication chrome = (ChromeApplication) context; ChildProcessCreationParams.set(chrome.getChildProcessCreationParams()); new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(Void... params) { ChildProcessLauncher.warmUp(context); return null; } }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); ChromeBrowserInitializer.initNetworkChangeNotifier(context); WarmupManager.getInstance().initializeViewHierarchy( context, R.layout.custom_tabs_control_container); }
Example #6
Source File: ChromeBackgroundService.java From delion with Apache License 2.0 | 6 votes |
@VisibleForTesting @SuppressFBWarnings("DM_EXIT") protected void launchBrowser(Context context, String tag) { Log.i(TAG, "Launching browser"); try { ChromeBrowserInitializer.getInstance(this).handleSynchronousStartup(); } catch (ProcessInitException e) { Log.e(TAG, "ProcessInitException while starting the browser process"); switch (tag) { case PrecacheController.PERIODIC_TASK_TAG: case PrecacheController.CONTINUATION_TASK_TAG: // Record the failure persistently, and upload to UMA when the library // successfully loads next time. PrecacheUMA.record(PrecacheUMA.Event.PRECACHE_TASK_LOAD_LIBRARY_FAIL); break; default: break; } // Since the library failed to initialize nothing in the application // can work, so kill the whole application not just the activity. System.exit(-1); } }
Example #7
Source File: ChromeBackgroundService.java From AndroidChromium with Apache License 2.0 | 6 votes |
@VisibleForTesting @SuppressFBWarnings("DM_EXIT") protected void launchBrowser(Context context, String tag) { Log.i(TAG, "Launching browser"); try { ChromeBrowserInitializer.getInstance(this).handleSynchronousStartup(); } catch (ProcessInitException e) { Log.e(TAG, "ProcessInitException while starting the browser process"); switch (tag) { case PrecacheController.PERIODIC_TASK_TAG: case PrecacheController.CONTINUATION_TASK_TAG: // Record the failure persistently, and upload to UMA when the library // successfully loads next time. PrecacheUMA.record(PrecacheUMA.Event.PRECACHE_TASK_LOAD_LIBRARY_FAIL); break; default: break; } // Since the library failed to initialize nothing in the application // can work, so kill the whole application not just the activity. System.exit(-1); } }
Example #8
Source File: CustomTabsConnection.java From AndroidChromium with Apache License 2.0 | 6 votes |
/** Warmup activities that should only happen once. */ @SuppressFBWarnings("DM_EXIT") private static void initializeBrowser(final Application app) { ThreadUtils.assertOnUiThread(); try { ChromeBrowserInitializer.getInstance(app).handleSynchronousStartup(); } catch (ProcessInitException e) { Log.e(TAG, "ProcessInitException while starting the browser process."); // Cannot do anything without the native library, and cannot show a // dialog to the user. System.exit(-1); } final Context context = app.getApplicationContext(); final ChromeApplication chrome = (ChromeApplication) context; ChildProcessCreationParams.set(chrome.getChildProcessCreationParams()); new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(Void... params) { ChildProcessLauncher.warmUp(context); return null; } }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); ChromeBrowserInitializer.initNetworkChangeNotifier(context); WarmupManager.getInstance().initializeViewHierarchy( context, R.layout.custom_tabs_control_container, R.layout.custom_tabs_toolbar); }
Example #9
Source File: ChromeBrowserProvider.java From AndroidChromium with Apache License 2.0 | 6 votes |
/** * Checks whether Chrome is sufficiently initialized to handle a call to the * ChromeBrowserProvider. */ private boolean canHandleContentProviderApiCall() { if (isInUiThread()) return false; ensureUriMatcherInitialized(); if (mNativeChromeBrowserProvider != 0) return true; synchronized (mLoadNativeLock) { ThreadUtils.runOnUiThreadBlocking(new Runnable() { @Override @SuppressFBWarnings("DM_EXIT") public void run() { if (mNativeChromeBrowserProvider != 0) return; try { ChromeBrowserInitializer.getInstance(getContext()) .handleSynchronousStartup(); } catch (ProcessInitException e) { // Chrome browser runs in the background, so exit silently; but do exit, // since otherwise the next attempt to use Chrome will find a broken JNI. System.exit(-1); } ensureNativeSideInitialized(); } }); } return true; }
Example #10
Source File: BookmarkItemsAdapter.java From delion with Apache License 2.0 | 6 votes |
@SuppressFBWarnings("BC_UNCONFIRMED_CAST") @Override public void onBindViewHolder(ViewHolder holder, int position) { BookmarkId id = getItem(position); switch (getItemViewType(position)) { case PROMO_HEADER_VIEW: case DIVIDER_VIEW: break; case FOLDER_VIEW: ((BookmarkRow) holder.itemView).setBookmarkId(id); break; case BOOKMARK_VIEW: ((BookmarkRow) holder.itemView).setBookmarkId(id); break; default: assert false : "View type not supported!"; } }
Example #11
Source File: ChromeGcmListenerService.java From AndroidChromium with Apache License 2.0 | 6 votes |
private void pushMessageReceived(final String from, final Bundle data) { final String bundleSubtype = "subtype"; if (!data.containsKey(bundleSubtype)) { Log.w(TAG, "Received push message with no subtype"); return; } final String appId = data.getString(bundleSubtype); ThreadUtils.runOnUiThread(new Runnable() { @Override @SuppressFBWarnings("DM_EXIT") public void run() { try { ChromeBrowserInitializer.getInstance(getApplicationContext()) .handleSynchronousStartup(); GCMDriver.onMessageReceived(appId, from, data); } catch (ProcessInitException e) { Log.e(TAG, "ProcessInitException while starting the browser process"); // Since the library failed to initialize nothing in the application // can work, so kill the whole application not just the activity. System.exit(-1); } } }); }
Example #12
Source File: GeolocationTracker.java From AndroidChromium with Apache License 2.0 | 6 votes |
/** * Requests an updated location if the last known location is older than maxAge milliseconds. * * Note: this must be called only on the UI thread. */ @SuppressFBWarnings("LI_LAZY_INIT_UPDATE_STATIC") static void refreshLastKnownLocation(Context context, long maxAge) { ThreadUtils.assertOnUiThread(); // We're still waiting for a location update. if (sListener != null) return; LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); Location location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); if (location == null || getLocationAge(location) > maxAge) { String provider = LocationManager.NETWORK_PROVIDER; if (locationManager.isProviderEnabled(provider)) { sListener = new SelfCancelingListener(locationManager); locationManager.requestSingleUpdate(provider, sListener, null); } } }
Example #13
Source File: ShareHelper.java From AndroidChromium with Apache License 2.0 | 5 votes |
@SuppressFBWarnings("NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE") private static void deleteShareImageFiles(File file) { if (!file.exists()) return; if (file.isDirectory()) { for (File f : file.listFiles()) deleteShareImageFiles(f); } if (!file.delete()) { Log.w(TAG, "Failed to delete share image file: %s", file.getAbsolutePath()); } }
Example #14
Source File: BookmarkWidgetService.java From AndroidChromium with Apache License 2.0 | 5 votes |
@UiThread @SuppressFBWarnings("DM_EXIT") @Override public void onCreate() { // Required to be applied here redundantly to prevent crashes in the cases where the // package data is deleted or the Chrome application forced to stop. try { ChromeBrowserInitializer.getInstance(mContext).handleSynchronousStartup(); } catch (ProcessInitException e) { Log.e(TAG, "Failed to start browser process.", e); // Since the library failed to initialize nothing in the application // can work, so kill the whole application not just the activity System.exit(-1); } if (isWidgetNewlyCreated()) { RecordUserAction.record("BookmarkNavigatorWidgetAdded"); } // Partner bookmarks need to be loaded explicitly. PartnerBookmarksShim.kickOffReading(mContext); mBookmarkModel = new BookmarkModel(); mBookmarkModel.addObserver(new BookmarkModelObserver() { @Override public void bookmarkModelLoaded() { // Do nothing. No need to refresh. } @Override public void bookmarkModelChanged() { refreshWidget(); } }); }
Example #15
Source File: DownloadResumptionScheduler.java From AndroidChromium with Apache License 2.0 | 5 votes |
@SuppressFBWarnings("LI_LAZY_INIT") public static DownloadResumptionScheduler getDownloadResumptionScheduler(Context context) { assert context == context.getApplicationContext(); if (sDownloadResumptionScheduler == null) { sDownloadResumptionScheduler = new DownloadResumptionScheduler(context); } return sDownloadResumptionScheduler; }
Example #16
Source File: ProfileDownloader.java From AndroidChromium with Apache License 2.0 | 5 votes |
@SuppressFBWarnings("LI_LAZY_INIT_UPDATE_STATIC") public static PendingProfileDownloads get(Context context) { ThreadUtils.assertOnUiThread(); if (sPendingProfileDownloads == null) { sPendingProfileDownloads = new PendingProfileDownloads(); AccountTrackerService.get(context).addSystemAccountsSeededListener( sPendingProfileDownloads); } return sPendingProfileDownloads; }
Example #17
Source File: RequestThrottler.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** @return the {@link Throttler} for a given UID. */ @SuppressFBWarnings("LI_LAZY_INIT_STATIC") public static RequestThrottler getForUid(Context context, int uid) { if (sUidToThrottler == null) { sUidToThrottler = new SparseArray<>(); purgeOldEntries(context); } RequestThrottler throttler = sUidToThrottler.get(uid); if (throttler == null) { throttler = new RequestThrottler(context, uid); sUidToThrottler.put(uid, throttler); } return throttler; }
Example #18
Source File: CustomTabsConnection.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * @return The unique instance of ChromeCustomTabsConnection. */ @SuppressFBWarnings("BC_UNCONFIRMED_CAST") public static CustomTabsConnection getInstance(Application application) { if (sInstance.get() == null) { ChromeApplication chromeApplication = (ChromeApplication) application; chromeApplication.initCommandLine(); sInstance.compareAndSet(null, chromeApplication.createCustomTabsConnection()); } return sInstance.get(); }
Example #19
Source File: AccountSigninActivity.java From AndroidChromium with Apache License 2.0 | 5 votes |
@Override @SuppressFBWarnings("DM_EXIT") protected void onCreate(Bundle savedInstanceState) { // The browser process must be started here because this activity may be started from the // recent apps list and it relies on other activities and the native library to be loaded. try { ChromeBrowserInitializer.getInstance(this).handleSynchronousStartup(); } catch (ProcessInitException e) { Log.e(TAG, "Failed to start browser process.", e); // Since the library failed to initialize nothing in the application // can work, so kill the whole application not just the activity System.exit(-1); } // We don't trust android to restore the saved state correctly, so pass null. super.onCreate(null); mAccessPoint = getIntent().getIntExtra(INTENT_SIGNIN_ACCESS_POINT, -1); assert mAccessPoint == SigninAccessPoint.BOOKMARK_MANAGER || mAccessPoint == SigninAccessPoint.RECENT_TABS || mAccessPoint == SigninAccessPoint.SETTINGS || mAccessPoint == SigninAccessPoint.SIGNIN_PROMO || mAccessPoint == SigninAccessPoint.NTP_CONTENT_SUGGESTIONS || mAccessPoint == SigninAccessPoint.AUTOFILL_DROPDOWN : "invalid access point: " + mAccessPoint; mView = (AccountSigninView) LayoutInflater.from(this).inflate( R.layout.account_signin_view, null); mView.init(getProfileDataCache(), this, this); if (getAccessPoint() == SigninAccessPoint.BOOKMARK_MANAGER || getAccessPoint() == SigninAccessPoint.RECENT_TABS) { mView.configureForRecentTabsOrBookmarksPage(); } setContentView(mView); SigninManager.logSigninStartAccessPoint(getAccessPoint()); recordSigninStartedUserAction(); }
Example #20
Source File: SnippetsLauncher.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * Called when the C++ counterpart is deleted. */ @VisibleForTesting @SuppressFBWarnings("ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD") @CalledByNative public void destroy() { assert sInstance == this; sInstance = null; }
Example #21
Source File: LayoutManager.java From AndroidChromium with Apache License 2.0 | 5 votes |
@SuppressFBWarnings("RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE") @Override public void doneHiding() { // TODO: If next layout is default layout clear caches (should this be a sub layout thing?) assert mNextActiveLayout != null : "Need to have a next active layout."; if (mNextActiveLayout != null) { startShowing(mNextActiveLayout, true); } }
Example #22
Source File: CompositorViewHolder.java From AndroidChromium with Apache License 2.0 | 5 votes |
@SuppressFBWarnings("NP_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD") @Override protected void onDraw(Canvas canvas) { for (int i = 0; i < mRectangles.size(); i++) { mPaint.setColor(mRectangles.get(i).second); canvas.drawRect(mRectangles.get(i).first, mPaint); } mFirstPush = true; }
Example #23
Source File: HelpAndFeedback.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * Returns the singleton instance of HelpAndFeedback, creating it if needed. */ @SuppressFBWarnings("LI_LAZY_INIT_STATIC") public static HelpAndFeedback getInstance(Context context) { ThreadUtils.assertOnUiThread(); if (sInstance == null) { sInstance = ((ChromeApplication) context.getApplicationContext()) .createHelpAndFeedback(); } return sInstance; }
Example #24
Source File: NotificationService.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * Initializes Chrome and starts the browser process if it's not running as of yet, and * dispatch |intent| to the NotificationPlatformBridge once this is done. * * @param intent The intent containing the notification's information. */ @SuppressFBWarnings("DM_EXIT") private void dispatchIntentOnUIThread(Intent intent) { try { ChromeBrowserInitializer.getInstance(this).handleSynchronousStartup(); // Warm up the WebappRegistry, as we need to check if this notification should launch a // standalone web app. This no-ops if the registry is already initialized and warmed, // but triggers a strict mode violation otherwise (i.e. the browser isn't running). // Temporarily disable strict mode to work around the violation. StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads(); try { WebappRegistry.getInstance(); WebappRegistry.warmUpSharedPrefs(); } finally { StrictMode.setThreadPolicy(oldPolicy); } // Now that the browser process is initialized, we pass forward the call to the // NotificationPlatformBridge which will take care of delivering the appropriate events. if (!NotificationPlatformBridge.dispatchNotificationEvent(intent)) { Log.w(TAG, "Unable to dispatch the notification event to Chrome."); } // TODO(peter): Verify that the lifetime of the NotificationService is sufficient // when a notification event could be dispatched successfully. } catch (ProcessInitException e) { Log.e(TAG, "Unable to start the browser process.", e); System.exit(-1); } }
Example #25
Source File: HelpAndFeedback.java From delion with Apache License 2.0 | 5 votes |
/** * Returns the singleton instance of HelpAndFeedback, creating it if needed. */ @SuppressFBWarnings("LI_LAZY_INIT_STATIC") public static HelpAndFeedback getInstance(Context context) { ThreadUtils.assertOnUiThread(); if (sInstance == null) { sInstance = ((ChromeApplication) context.getApplicationContext()) .createHelpAndFeedback(); } return sInstance; }
Example #26
Source File: ChromeBackupAgent.java From AndroidChromium with Apache License 2.0 | 5 votes |
@SuppressFBWarnings(value = {"OS_OPEN_STREAM"}, justification = "Closed by backup system") @SuppressWarnings("unchecked") public BackupState(ParcelFileDescriptor parceledState) throws IOException { if (parceledState == null) return; try { FileInputStream instream = new FileInputStream(parceledState.getFileDescriptor()); ObjectInputStream in = new ObjectInputStream(instream); mNames = (ArrayList<String>) in.readObject(); mValues = (ArrayList<byte[]>) in.readObject(); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } }
Example #27
Source File: SlowedProgressBar.java From delion with Apache License 2.0 | 5 votes |
/** * Ensure invalidations always occurs in the scope of animation. * @param progress The progress value to set the visuals to. */ @SuppressFBWarnings("CHROMIUM_SYNCHRONIZED_METHOD") @Override public synchronized void setProgress(int progress) { if (mTargetProgress == progress) return; mTargetProgress = progress; removeCallbacks(mUpdateProgressRunnable); postOnAnimation(mUpdateProgressRunnable); }
Example #28
Source File: MinidumpUploadRetry.java From delion with Apache License 2.0 | 5 votes |
@SuppressFBWarnings("ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD") @Override public void onConnectionTypeChanged(int connectionType) { // Look for "favorable" connections. Note that we never // know what the user's crash upload preference is until // the time when we are actually uploading. if (connectionType == ConnectionType.CONNECTION_NONE) { return; } MinidumpUploadService.tryUploadAllCrashDumps(mContext); NetworkChangeNotifier.removeConnectionTypeObserver(this); sSingleton = null; }
Example #29
Source File: ProfileSyncService.java From delion with Apache License 2.0 | 5 votes |
/** * Retrieves or creates the ProfileSyncService singleton instance. Returns null if sync is * disabled (via flag or variation). * * Can only be accessed on the main thread. */ @Nullable @SuppressFBWarnings("LI_LAZY_INIT") public static ProfileSyncService get() { ThreadUtils.assertOnUiThread(); if (!sInitialized) { sProfileSyncService = new ProfileSyncService(); if (sProfileSyncService.mNativeProfileSyncServiceAndroid == 0) { sProfileSyncService = null; } sInitialized = true; } return sProfileSyncService; }
Example #30
Source File: ChromeBrowserProvider.java From AndroidChromium with Apache License 2.0 | 5 votes |
@Override @SuppressFBWarnings("SF_SWITCH_FALLTHROUGH") public Uri insert(Uri uri, ContentValues values) { if (!canHandleContentProviderApiCall() || !hasWriteAccess()) return null; int match = mUriMatcher.match(uri); Uri res = null; long id; switch (match) { case URI_MATCH_BOOKMARKS: id = addBookmark(values); if (id == INVALID_BOOKMARK_ID) return null; break; case URL_MATCH_API_BOOKMARK_CONTENT: values.put(BookmarkColumns.BOOKMARK, 1); //$FALL-THROUGH$ case URL_MATCH_API_BOOKMARK: case URL_MATCH_API_HISTORY_CONTENT: id = addBookmarkFromAPI(values); if (id == INVALID_CONTENT_PROVIDER_ID) return null; break; case URL_MATCH_API_SEARCHES: id = addSearchTermFromAPI(values); if (id == INVALID_CONTENT_PROVIDER_ID) return null; break; default: throw new IllegalArgumentException(TAG + ": insert - unknown URL " + uri); } res = ContentUris.withAppendedId(uri, id); notifyChange(res); return res; }