Search in sources :

Example 1 with SuppressFBWarnings

use of org.chromium.base.annotations.SuppressFBWarnings in project AndroidChromium by JackyAndroid.

the class AccountsChangedReceiver method startBrowserIfNeededAndValidateAccounts.

@SuppressFBWarnings("DM_EXIT")
private static void startBrowserIfNeededAndValidateAccounts(final Context context) {
    BrowserParts parts = new EmptyBrowserParts() {

        @Override
        public void finishNativeInitialization() {
            ThreadUtils.runOnUiThread(new Runnable() {

                @Override
                public void run() {
                    SigninHelper.get(context).validateAccountSettings(true);
                }
            });
        }

        @Override
        public void onStartupFailure() {
            // Startup failed. So notify SigninHelper of changed accounts via
            // shared prefs.
            SigninHelper.markAccountsChangedPref(context);
        }
    };
    try {
        ChromeBrowserInitializer.getInstance(context).handlePreNativeStartup(parts);
        ChromeBrowserInitializer.getInstance(context).handlePostNativeStartup(true, parts);
    } catch (ProcessInitException e) {
        Log.e(TAG, "Unable to load native library.", e);
        ChromeApplication.reportStartupErrorAndExit(e);
    }
}
Also used : EmptyBrowserParts(org.chromium.chrome.browser.init.EmptyBrowserParts) ProcessInitException(org.chromium.base.library_loader.ProcessInitException) BrowserParts(org.chromium.chrome.browser.init.BrowserParts) EmptyBrowserParts(org.chromium.chrome.browser.init.EmptyBrowserParts) SuppressFBWarnings(org.chromium.base.annotations.SuppressFBWarnings)

Example 2 with SuppressFBWarnings

use of org.chromium.base.annotations.SuppressFBWarnings in project AndroidChromium by JackyAndroid.

the class ChromeApplication method getDocumentTabModelSelector.

/**
 * Returns the Singleton instance of the DocumentTabModelSelector.
 * TODO(dfalcantara): Find a better place for this once we differentiate between activity and
 *                    application-level TabModelSelectors.
 * @return The DocumentTabModelSelector for the application.
 */
@SuppressFBWarnings("LI_LAZY_INIT_STATIC")
public static DocumentTabModelSelector getDocumentTabModelSelector() {
    ThreadUtils.assertOnUiThread();
    if (sDocumentTabModelSelector == null) {
        ActivityDelegateImpl activityDelegate = new ActivityDelegateImpl(DocumentActivity.class, IncognitoDocumentActivity.class);
        sDocumentTabModelSelector = new DocumentTabModelSelector(activityDelegate, new StorageDelegate(), new TabDelegate(false), new TabDelegate(true));
    }
    return sDocumentTabModelSelector;
}
Also used : StorageDelegate(org.chromium.chrome.browser.tabmodel.document.StorageDelegate) DocumentTabModelSelector(org.chromium.chrome.browser.tabmodel.document.DocumentTabModelSelector) TabDelegate(org.chromium.chrome.browser.tabmodel.document.TabDelegate) ActivityDelegateImpl(org.chromium.chrome.browser.tabmodel.document.ActivityDelegateImpl) SuppressFBWarnings(org.chromium.base.annotations.SuppressFBWarnings)

Example 3 with SuppressFBWarnings

use of org.chromium.base.annotations.SuppressFBWarnings in project AndroidChromium by JackyAndroid.

the class GeolocationTracker method refreshLastKnownLocation.

/**
 * 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);
        }
    }
}
Also used : LocationManager(android.location.LocationManager) Location(android.location.Location) SuppressFBWarnings(org.chromium.base.annotations.SuppressFBWarnings)

Example 4 with SuppressFBWarnings

use of org.chromium.base.annotations.SuppressFBWarnings in project AndroidChromium by JackyAndroid.

the class Preferences method onCreate.

@SuppressFBWarnings("DM_EXIT")
@SuppressLint("InlinedApi")
@Override
protected void onCreate(Bundle savedInstanceState) {
    ensureActivityNotExported();
    // recreate a fragment, and a fragment might depend on the native library.
    try {
        ChromeBrowserInitializer.getInstance(this).handleSynchronousStartup();
    } catch (ProcessInitException e) {
        Log.e(TAG, "Failed to start browser process.", e);
        // This can only ever happen, if at all, when the activity is started from an Android
        // notification (or in tests). As such we don't want to show an error messsage to the
        // user. The application is completely broken at this point, so close it down
        // completely (not just the activity).
        System.exit(-1);
        return;
    }
    super.onCreate(savedInstanceState);
    mIsNewlyCreated = savedInstanceState == null;
    String initialFragment = getIntent().getStringExtra(EXTRA_SHOW_FRAGMENT);
    Bundle initialArguments = getIntent().getBundleExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    // recreated and super.onCreate() has already recreated the fragment.
    if (savedInstanceState == null) {
        if (initialFragment == null)
            initialFragment = MainPreferences.class.getName();
        Fragment fragment = Fragment.instantiate(this, initialFragment, initialArguments);
        getFragmentManager().beginTransaction().replace(android.R.id.content, fragment).commit();
    }
    if (ApiCompatibilityUtils.checkPermission(this, Manifest.permission.NFC, Process.myPid(), Process.myUid()) == PackageManager.PERMISSION_GRANTED) {
        // Disable Android Beam on JB and later devices.
        // In ICS it does nothing - i.e. we will send a Play Store link if NFC is used.
        NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(this);
        if (nfcAdapter != null)
            nfcAdapter.setNdefPushMessage(null, this);
    }
    Resources res = getResources();
    ApiCompatibilityUtils.setTaskDescription(this, res.getString(R.string.app_name), BitmapFactory.decodeResource(res, R.mipmap.app_icon), ApiCompatibilityUtils.getColor(res, R.color.default_primary_color));
}
Also used : Bundle(android.os.Bundle) NfcAdapter(android.nfc.NfcAdapter) ProcessInitException(org.chromium.base.library_loader.ProcessInitException) Resources(android.content.res.Resources) Fragment(android.app.Fragment) PreferenceFragment(android.preference.PreferenceFragment) SuppressFBWarnings(org.chromium.base.annotations.SuppressFBWarnings) SuppressLint(android.annotation.SuppressLint)

Example 5 with SuppressFBWarnings

use of org.chromium.base.annotations.SuppressFBWarnings in project AndroidChromium by JackyAndroid.

the class ChromeBrowserProvider method insert.

@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;
}
Also used : Uri(android.net.Uri) SuppressLint(android.annotation.SuppressLint) SuppressFBWarnings(org.chromium.base.annotations.SuppressFBWarnings)

Aggregations

SuppressFBWarnings (org.chromium.base.annotations.SuppressFBWarnings)10 ProcessInitException (org.chromium.base.library_loader.ProcessInitException)3 ChromeApplication (org.chromium.chrome.browser.ChromeApplication)3 SuppressLint (android.annotation.SuppressLint)2 Bundle (android.os.Bundle)2 Fragment (android.app.Fragment)1 Context (android.content.Context)1 Resources (android.content.res.Resources)1 Location (android.location.Location)1 LocationManager (android.location.LocationManager)1 Uri (android.net.Uri)1 NfcAdapter (android.nfc.NfcAdapter)1 StrictMode (android.os.StrictMode)1 PreferenceFragment (android.preference.PreferenceFragment)1 UiThread (android.support.annotation.UiThread)1 FragmentActivity (android.support.v4.app.FragmentActivity)1 CommandLine (org.chromium.base.CommandLine)1 BrowserParts (org.chromium.chrome.browser.init.BrowserParts)1 EmptyBrowserParts (org.chromium.chrome.browser.init.EmptyBrowserParts)1 ActivityDelegateImpl (org.chromium.chrome.browser.tabmodel.document.ActivityDelegateImpl)1