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