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);
}
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");
}
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));
}
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;
}
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;
}
Aggregations