use of org.chromium.base.library_loader.ProcessInitException 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.library_loader.ProcessInitException in project AndroidChromium by JackyAndroid.
the class DownloadNotificationService method handleDownloadOperation.
/**
* Helper method to launch the browser process and handle a download operation that is included
* in the given intent.
* @param intent Intent with the download operation.
*/
private void handleDownloadOperation(final Intent intent) {
final DownloadSharedPreferenceEntry entry = getDownloadEntryFromIntent(intent);
if (intent.getAction() == ACTION_DOWNLOAD_PAUSE) {
// nothing in that case.
if (!DownloadManagerService.hasDownloadManagerService()) {
notifyDownloadPaused(entry.downloadGuid, !entry.isOffTheRecord, false);
return;
}
} else if (intent.getAction() == ACTION_DOWNLOAD_RESUME) {
boolean metered = DownloadManagerService.isActiveNetworkMetered(mContext);
if (!entry.canDownloadWhileMetered) {
// If user manually resumes a download, update the network type if it
// is not metered previously.
entry.canDownloadWhileMetered = metered;
}
// Update the SharedPreference entry.
addOrReplaceSharedPreferenceEntry(entry);
} else if (intent.getAction() == ACTION_DOWNLOAD_RESUME_ALL && (mDownloadSharedPreferenceEntries.isEmpty() || DownloadManagerService.hasDownloadManagerService())) {
return;
} else if (intent.getAction() == ACTION_DOWNLOAD_OPEN) {
// TODO(fgorski): Do we even need to do anything special here, before we launch Chrome?
}
BrowserParts parts = new EmptyBrowserParts() {
@Override
public boolean shouldStartGpuProcess() {
return false;
}
@Override
public void finishNativeInitialization() {
int itemType = entry != null ? entry.itemType : (intent.getAction() == ACTION_DOWNLOAD_OPEN ? DownloadSharedPreferenceEntry.ITEM_TYPE_OFFLINE_PAGE : DownloadSharedPreferenceEntry.ITEM_TYPE_DOWNLOAD);
DownloadServiceDelegate downloadServiceDelegate = intent.getAction() == ACTION_DOWNLOAD_OPEN ? null : getServiceDelegate(itemType);
switch(intent.getAction()) {
case ACTION_DOWNLOAD_CANCEL:
// TODO(qinmin): Alternatively, we can delete the downloaded content on
// SD card, and remove the download ID from the SharedPreferences so we
// don't need to restart the browser process. http://crbug.com/579643.
cancelNotification(entry.notificationId, entry.downloadGuid);
downloadServiceDelegate.cancelDownload(entry.downloadGuid, entry.isOffTheRecord, IntentUtils.safeGetBooleanExtra(intent, EXTRA_NOTIFICATION_DISMISSED, false));
break;
case ACTION_DOWNLOAD_PAUSE:
downloadServiceDelegate.pauseDownload(entry.downloadGuid, entry.isOffTheRecord);
break;
case ACTION_DOWNLOAD_RESUME:
notifyDownloadProgress(entry.downloadGuid, entry.fileName, INVALID_DOWNLOAD_PERCENTAGE, 0, 0, entry.isOffTheRecord, entry.canDownloadWhileMetered, entry.isOfflinePage());
downloadServiceDelegate.resumeDownload(entry.buildDownloadItem(), true);
break;
case ACTION_DOWNLOAD_RESUME_ALL:
assert entry == null;
resumeAllPendingDownloads();
break;
case ACTION_DOWNLOAD_OPEN:
OfflinePageDownloadBridge.openDownloadedPage(IntentUtils.safeGetStringExtra(intent, EXTRA_DOWNLOAD_GUID));
break;
default:
Log.e(TAG, "Unrecognized intent action.", intent);
break;
}
if (intent.getAction() != ACTION_DOWNLOAD_OPEN) {
downloadServiceDelegate.destroyServiceDelegate();
}
}
};
try {
ChromeBrowserInitializer.getInstance(mContext).handlePreNativeStartup(parts);
ChromeBrowserInitializer.getInstance(mContext).handlePostNativeStartup(true, parts);
} catch (ProcessInitException e) {
Log.e(TAG, "Unable to load native library.", e);
ChromeApplication.reportStartupErrorAndExit(e);
}
}
use of org.chromium.base.library_loader.ProcessInitException in project AndroidChromium by JackyAndroid.
the class AsyncInitializationActivity method onStartupFailure.
@Override
public void onStartupFailure() {
ProcessInitException e = new ProcessInitException(LoaderErrors.LOADER_ERROR_NATIVE_STARTUP_FAILED);
ChromeApplication.reportStartupErrorAndExit(e);
}
use of org.chromium.base.library_loader.ProcessInitException 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.library_loader.ProcessInitException in project AndroidChromium by JackyAndroid.
the class NotificationPlatformBridge method launchNotificationPreferences.
/**
* Launches the notifications preferences screen. If the received intent indicates it came
* from the gear button on a flipped notification, this launches the site specific preferences
* screen.
*
* @param context The context that received the intent.
* @param incomingIntent The received intent.
*/
public static void launchNotificationPreferences(Context context, Intent incomingIntent) {
// UrlFormatter.formatUrlForSecurityDisplay.
try {
ChromeBrowserInitializer.getInstance(context).handleSynchronousStartup();
} catch (ProcessInitException e) {
Log.e(TAG, "Failed to start browser process.", e);
// The library failed to initialize and nothing in the application can work, so kill
// the whole application.
System.exit(-1);
return;
}
// Use the application context because it lives longer. When using the given context, it
// may be stopped before the preferences intent is handled.
Context applicationContext = context.getApplicationContext();
// If we can read an origin from the intent, use it to open the settings screen for that
// origin.
String origin = getOriginFromTag(incomingIntent.getStringExtra(NotificationConstants.EXTRA_NOTIFICATION_TAG));
boolean launchSingleWebsitePreferences = origin != null;
String fragmentName = launchSingleWebsitePreferences ? SingleWebsitePreferences.class.getName() : SingleCategoryPreferences.class.getName();
Intent preferencesIntent = PreferencesLauncher.createIntentForSettingsPage(applicationContext, fragmentName);
Bundle fragmentArguments;
if (launchSingleWebsitePreferences) {
// Record that the user has clicked on the [Site Settings] button.
RecordUserAction.record("Notifications.ShowSiteSettings");
// All preferences for a specific origin.
fragmentArguments = SingleWebsitePreferences.createFragmentArgsForSite(origin);
} else {
// Notification preferences for all origins.
fragmentArguments = new Bundle();
fragmentArguments.putString(SingleCategoryPreferences.EXTRA_CATEGORY, SiteSettingsCategory.CATEGORY_NOTIFICATIONS);
fragmentArguments.putString(SingleCategoryPreferences.EXTRA_TITLE, applicationContext.getResources().getString(R.string.push_notifications_permission_title));
}
preferencesIntent.putExtra(Preferences.EXTRA_SHOW_FRAGMENT_ARGUMENTS, fragmentArguments);
// We need to ensure that no existing preference tasks are being re-used in order for the
// new activity to appear on top.
preferencesIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
applicationContext.startActivity(preferencesIntent);
}
Aggregations