Search in sources :

Example 6 with SuppressFBWarnings

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

the class CustomTabsConnection method initializeBrowser.

/** 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);
}
Also used : Context(android.content.Context) ChromeApplication(org.chromium.chrome.browser.ChromeApplication) ProcessInitException(org.chromium.base.library_loader.ProcessInitException) SuppressFBWarnings(org.chromium.base.annotations.SuppressFBWarnings)

Example 7 with SuppressFBWarnings

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

the class InvalidStartupDialog method show.

/**
     * Shows the invalid startup dialog for a given error code.
     *
     * @param activity The activity showing the dialog.
     * @param errorCode The error code that triggered the failure.
     */
@SuppressFBWarnings("DM_EXIT")
public static void show(Activity activity, int errorCode) {
    int msg;
    switch(errorCode) {
        case LoaderErrors.LOADER_ERROR_NATIVE_LIBRARY_LOAD_FAILED:
            msg = R.string.os_version_missing_features;
            break;
        case LoaderErrors.LOADER_ERROR_NATIVE_LIBRARY_WRONG_VERSION:
            msg = R.string.incompatible_libraries;
            break;
        default:
            msg = R.string.native_startup_failed;
    }
    final String message = activity.getResources().getString(msg);
    if (!(activity instanceof FragmentActivity)) {
        Log.e(TAG, "Unable to start chrome due to: " + msg);
        System.exit(-1);
        return;
    }
    Bundle dialogArgs = new Bundle();
    dialogArgs.putString(MESSAGE_KEY, message);
    InvalidStartupDialog dialog = new InvalidStartupDialog();
    dialog.setArguments(dialogArgs);
    dialog.show(((FragmentActivity) activity).getSupportFragmentManager(), "InvalidStartupDialog");
}
Also used : FragmentActivity(android.support.v4.app.FragmentActivity) Bundle(android.os.Bundle) SuppressFBWarnings(org.chromium.base.annotations.SuppressFBWarnings)

Example 8 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 9 with SuppressFBWarnings

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

the class LocationSettings method getInstance.

/**
     * Returns the singleton instance of LocationSettings, creating it if needed.
     */
@SuppressFBWarnings("LI_LAZY_INIT_STATIC")
public static LocationSettings getInstance() {
    ThreadUtils.assertOnUiThread();
    if (sInstance == null) {
        ChromeApplication application = (ChromeApplication) ContextUtils.getApplicationContext();
        sInstance = application.createLocationSettings();
    }
    return sInstance;
}
Also used : ChromeApplication(org.chromium.chrome.browser.ChromeApplication) SuppressFBWarnings(org.chromium.base.annotations.SuppressFBWarnings)

Example 10 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