Java Code Examples for org.chromium.base.Log#e()
The following examples show how to use
org.chromium.base.Log#e() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DownloadResumptionScheduler.java From AndroidChromium with Apache License 2.0 | 6 votes |
/** * Schedules a future task to start download resumption. * @param allowMeteredConnection Whether download resumption can start if connection is metered. */ public void schedule(boolean allowMeteredConnection) { GcmNetworkManager gcmNetworkManager = GcmNetworkManager.getInstance(mContext); int networkType = allowMeteredConnection ? Task.NETWORK_STATE_CONNECTED : Task.NETWORK_STATE_UNMETERED; OneoffTask task = new OneoffTask.Builder() .setService(ChromeBackgroundService.class) .setExecutionWindow(0, ONE_DAY_IN_SECONDS) .setTag(TASK_TAG) .setUpdateCurrent(true) .setRequiredNetwork(networkType) .setRequiresCharging(false) .build(); try { gcmNetworkManager.schedule(task); } catch (IllegalArgumentException e) { Log.e(TAG, "unable to schedule resumption task.", e); } }
Example 2
Source File: MediaCodecUtil.java From 365browser with Apache License 2.0 | 6 votes |
/** * Returns true if the given codec supports adaptive playback (dynamic resolution change). * @param mediaCodec the codec. * @param mime MIME type that corresponds to the codec creation. * @return true if this codec and mime type combination supports adaptive playback. */ @TargetApi(Build.VERSION_CODES.KITKAT) private static boolean codecSupportsAdaptivePlayback(MediaCodec mediaCodec, String mime) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT || mediaCodec == null) { return false; } try { MediaCodecInfo info = mediaCodec.getCodecInfo(); if (info.isEncoder()) { return false; } if (isAdaptivePlaybackBlacklisted(mime)) { return false; } MediaCodecInfo.CodecCapabilities capabilities = info.getCapabilitiesForType(mime); return (capabilities != null) && capabilities.isFeatureSupported( MediaCodecInfo.CodecCapabilities.FEATURE_AdaptivePlayback); } catch (IllegalArgumentException e) { Log.e(TAG, "Cannot retrieve codec information", e); } return false; }
Example 3
Source File: VideoCaptureCamera2.java From 365browser with Apache License 2.0 | 6 votes |
private static Size findClosestSizeInArray(Size[] sizes, int width, int height) { if (sizes == null) return null; Size closestSize = null; int minDiff = Integer.MAX_VALUE; for (Size size : sizes) { final int diff = ((width > 0) ? Math.abs(size.getWidth() - width) : 0) + ((height > 0) ? Math.abs(size.getHeight() - height) : 0); if (diff < minDiff) { minDiff = diff; closestSize = size; } } if (minDiff == Integer.MAX_VALUE) { Log.e(TAG, "Couldn't find resolution close to (%dx%d)", width, height); return null; } return closestSize; }
Example 4
Source File: OfflinePageUtils.java From AndroidChromium with Apache License 2.0 | 6 votes |
/** * Saves the web page loaded into web contents. If page saved successfully, get the offline * page item with the save page result and use it to invoke |prepareForSharing|. Otherwise, * invokes |prepareForSharing| with null. * @param prepareForSharing Callback of a single OfflinePageItem that is used to call * prepareForSharing * @param offlinePageBridge A static copy of the offlinePageBridge. * @return a call back of a list of OfflinePageItem */ private static OfflinePageBridge.SavePageCallback savePageCallback( final Callback<OfflinePageItem> prepareForSharing, final OfflinePageBridge offlinePageBridge) { return new OfflinePageBridge.SavePageCallback() { @Override public void onSavePageDone(int savePageResult, String url, long offlineId) { if (savePageResult != SavePageResult.SUCCESS) { Log.e(TAG, "Unable to save the page."); prepareForSharing.onResult(null); return; } offlinePageBridge.getPageByOfflineId(offlineId, prepareForSharing); } }; }
Example 5
Source File: PrefetchBackgroundTask.java From 365browser with Apache License 2.0 | 6 votes |
@VisibleForTesting @SuppressFBWarnings("DM_EXIT") void launchBrowserIfNecessary(Context context) { if (BrowserStartupController.get(LibraryProcessType.PROCESS_BROWSER) .isStartupSuccessfullyCompleted()) { return; } // TODO(https://crbug.com/717251): Remove when BackgroundTaskScheduler supports loading the // native library. try { ChromeBrowserInitializer.getInstance(context).handleSynchronousStartup(); } catch (ProcessInitException e) { Log.e(TAG, "ProcessInitException while starting the browser process."); // Since the library failed to initialize nothing in the application can work, so kill // the whole application not just the activity. System.exit(-1); } }
Example 6
Source File: BackgroundTaskSchedulerGcmNetworkManager.java From 365browser with Apache License 2.0 | 5 votes |
@Override public void cancel(Context context, int taskId) { ThreadUtils.assertOnUiThread(); GcmNetworkManager gcmNetworkManager = getGcmNetworkManager(context); if (gcmNetworkManager == null) { Log.e(TAG, "GcmNetworkManager is not available."); return; } gcmNetworkManager.cancelTask(taskIdToTaskTag(taskId), BackgroundTaskGcmTaskService.class); }
Example 7
Source File: IntentUtils.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * Just like {@link Intent#getLongExtra(String, long)} but doesn't throw exceptions. */ public static long safeGetLongExtra(Intent intent, String name, long defaultValue) { try { return intent.getLongExtra(name, defaultValue); } catch (Throwable t) { // Catches un-parceling exceptions. Log.e(TAG, "getLongExtra failed on intent " + intent); return defaultValue; } }
Example 8
Source File: ConnectedTask.java From 365browser with Apache License 2.0 | 5 votes |
@Override @VisibleForTesting public final void run() { TraceEvent.begin("GCore:" + mLogPrefix + ":run"); try { Log.d(TAG, "%s:%s started", mLogPrefix, getName()); if (mClient.connectWithTimeout(CONNECTION_TIMEOUT_MS)) { try { Log.d(TAG, "%s:%s connected", mLogPrefix, getName()); doWhenConnected(mClient); Log.d(TAG, "%s:%s finished", mLogPrefix, getName()); } finally { mClient.disconnect(); Log.d(TAG, "%s:%s disconnected", mLogPrefix, getName()); cleanUp(); Log.d(TAG, "%s:%s cleaned up", mLogPrefix, getName()); } } else { mRetryNumber++; if (mRetryNumber < RETRY_NUMBER_LIMIT && mClient.isGooglePlayServicesAvailable()) { Log.d(TAG, "%s:%s calling retry", mLogPrefix, getName()); retry(this, CONNECTION_RETRY_TIME_MS); } else { connectionFailed(); Log.d(TAG, "%s:%s number of retries exceeded", mLogPrefix, getName()); cleanUp(); Log.d(TAG, "%s:%s cleaned up", mLogPrefix, getName()); } } } catch (RuntimeException e) { Log.e(TAG, "%s:%s runtime exception %s: %s", mLogPrefix, getName(), e.getClass().getName(), e.getMessage()); throw e; } finally { TraceEvent.end("GCore:" + mLogPrefix + ":run"); } }
Example 9
Source File: CastMessageHandler.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * Handles messages related to the cast session, i.e. messages happening on a established * connection. All these messages are sent from the page to the Cast SDK. * @param message The JSONObject message to be handled. */ public boolean handleSessionMessage(JSONObject message) throws JSONException { String messageType = message.getString("type"); if ("v2_message".equals(messageType)) { return handleCastV2Message(message); } else if ("app_message".equals(messageType)) { return handleAppMessage(message); } else { Log.e(TAG, "Unsupported message: %s", message); return false; } }
Example 10
Source File: FirstRunActivity.java From delion with Apache License 2.0 | 5 votes |
private void initializeBrowserProcess() { // The Chrome browser process must be started here because this Activity // may be started explicitly for tests cases, from Android notifications or // when the application is restoring a FRE fragment after Chrome being killed. // This should happen before super.onCreate() because it might recreate a fragment, // and a fragment might depend on the native library. try { ChromeBrowserInitializer.getInstance(this).handleSynchronousStartup(); mNativeSideIsInitialized = true; } catch (ProcessInitException e) { Log.e(TAG, "Unable to load native library.", e); abortFirstRunExperience(); return; } }
Example 11
Source File: CustomTabIntentDataProvider.java From delion with Apache License 2.0 | 5 votes |
/** * Triggers the client-defined action when the user clicks a custom menu item. * @param menuIndex The index that the menu item is shown in the result of * {@link #getMenuTitles()} */ public void clickMenuItemWithUrl(ChromeActivity activity, int menuIndex, String url) { Intent addedIntent = new Intent(); addedIntent.setData(Uri.parse(url)); try { PendingIntent pendingIntent = mMenuEntries.get(menuIndex).second; pendingIntent.send(activity, 0, addedIntent, mOnFinished, null); } catch (CanceledException e) { Log.e(TAG, "Custom tab in Chrome failed to send pending intent."); } }
Example 12
Source File: IntentUtils.java From delion with Apache License 2.0 | 5 votes |
/** * Just like {@link Intent#getIntArrayExtra(String)} but doesn't throw exceptions. */ public static int[] safeGetIntArrayExtra(Intent intent, String name) { try { return intent.getIntArrayExtra(name); } catch (Throwable t) { // Catches un-parceling exceptions. Log.e(TAG, "getIntArrayExtra failed on intent " + intent); return null; } }
Example 13
Source File: MediaResourceGetter.java From 365browser with Apache License 2.0 | 5 votes |
@VisibleForTesting MediaMetadata extract(final Context context, final String url, final String cookies, final String userAgent) { if (!configure(context, url, cookies, userAgent)) { Log.e(TAG, "Unable to configure metadata extractor"); return EMPTY_METADATA; } return doExtractMetadata(); }
Example 14
Source File: IntentUtils.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * Just like {@link Intent#getParcelableArrayExtra(String)} but doesn't throw exceptions. */ public static Parcelable[] safeGetParcelableArrayExtra(Intent intent, String name) { try { return intent.getParcelableArrayExtra(name); } catch (Throwable t) { Log.e(TAG, "getParcelableArrayExtra failed on intent " + intent); return null; } }
Example 15
Source File: UpgradeIntentService.java From AndroidChromium with Apache License 2.0 | 5 votes |
@Override protected void onHandleIntent(Intent intent) { final DocumentModeAssassin assassin = DocumentModeAssassin.getInstance(); if (!assassin.isMigrationNecessary()) return; final CountDownLatch finishSignal = new CountDownLatch(1); ThreadUtils.runOnUiThread(new Runnable() { @Override public void run() { if (assassin.isMigrationNecessary()) { // Kick off migration if it hasn't already started. DocumentModeAssassinObserver observer = new DocumentModeAssassinObserver() { @Override public void onStageChange(int newStage) { if (newStage != DocumentModeAssassin.STAGE_DONE) return; assassin.removeObserver(this); finishSignal.countDown(); } }; assassin.addObserver(observer); assassin.migrateFromDocumentToTabbedMode(); } else { // Migration finished in the background. finishSignal.countDown(); } } }); try { boolean success = finishSignal.await(TIMEOUT_MS, TimeUnit.MILLISECONDS); Log.d(TAG, "Migration completed. Status: " + success); } catch (InterruptedException e) { Log.e(TAG, "Failed to migrate user on time."); } }
Example 16
Source File: HttpNegotiateAuthenticator.java From 365browser with Apache License 2.0 | 4 votes |
@Override public void run(AccountManagerFuture<Account[]> future) { Account[] accounts; try { accounts = future.getResult(); } catch (OperationCanceledException | AuthenticatorException | IOException e) { Log.w(TAG, "ERR_UNEXPECTED: Error while attempting to retrieve accounts.", e); nativeSetResult(mRequestData.nativeResultObject, NetError.ERR_UNEXPECTED, null); return; } if (accounts.length == 0) { Log.w(TAG, "ERR_MISSING_AUTH_CREDENTIALS: No account provided for the kerberos " + "authentication. Please verify the configuration policies and " + "that the CONTACTS runtime permission is granted. "); nativeSetResult(mRequestData.nativeResultObject, NetError.ERR_MISSING_AUTH_CREDENTIALS, null); return; } if (accounts.length > 1) { Log.w(TAG, "ERR_MISSING_AUTH_CREDENTIALS: Found %d accounts eligible for the " + "kerberos authentication. Please fix the configuration by " + "providing a single account.", accounts.length); nativeSetResult(mRequestData.nativeResultObject, NetError.ERR_MISSING_AUTH_CREDENTIALS, null); return; } if (lacksPermission(ContextUtils.getApplicationContext(), "android.permission.USE_CREDENTIALS", true)) { // Protecting the AccountManager#getAuthToken call. // API < 23 Requires the USE_CREDENTIALS permission or throws an exception. // API >= 23 USE_CREDENTIALS permission is removed Log.e(TAG, "ERR_MISCONFIGURED_AUTH_ENVIRONMENT: USE_CREDENTIALS permission not " + "granted. Aborting authentication."); nativeSetResult(mRequestData.nativeResultObject, NetError.ERR_MISCONFIGURED_AUTH_ENVIRONMENT, null); return; } mRequestData.account = accounts[0]; mRequestData.accountManager.getAuthToken(mRequestData.account, mRequestData.authTokenType, mRequestData.options, true /* notifyAuthFailure */, new GetTokenCallback(mRequestData), new Handler(ThreadUtils.getUiThreadLooper())); }
Example 17
Source File: CastSessionImpl.java From 365browser with Apache License 2.0 | 4 votes |
@Override public CastSessionInfo getSessionInfo() { if (isApiClientInvalid()) return null; // Due to a Google Play Services issue, the api client might still get disconnected so that // calls like {@link Cast.CastApi#getVolume()} will throw an {@link IllegalStateException}. // Until the issue is fixed, catch the exception and return null if it was thrown instead of // crashing. See https://crbug.com/708964 for details. try { CastSessionInfo.VolumeInfo.Builder volumeBuilder = new CastSessionInfo.VolumeInfo.Builder() .setLevel(Cast.CastApi.getVolume(mApiClient)) .setMuted(Cast.CastApi.isMute(mApiClient)); CastSessionInfo.ReceiverInfo.Builder receiverBuilder = new CastSessionInfo.ReceiverInfo.Builder() .setLabel(mCastDevice.getDeviceId()) .setFriendlyName(mCastDevice.getFriendlyName()) .setVolume(volumeBuilder.build()) .setIsActiveInput(Cast.CastApi.getActiveInputState(mApiClient)) .setDisplayStatus(null) .setReceiverType("cast") .addCapabilities(getCapabilities(mCastDevice)); CastSessionInfo.Builder sessionInfoBuilder = new CastSessionInfo.Builder() .setSessionId(mSessionId) .setStatusText(mApplicationStatus) .setReceiver(receiverBuilder.build()) .setStatus("connected") .setTransportId("web-4") .addNamespaces(mNamespaces); if (mApplicationMetadata != null) { sessionInfoBuilder.setAppId(mApplicationMetadata.getApplicationId()) .setDisplayName(mApplicationMetadata.getName()); } else { sessionInfoBuilder.setAppId(mSource.getApplicationId()) .setDisplayName(mCastDevice.getFriendlyName()); } return sessionInfoBuilder.build(); } catch (IllegalStateException e) { Log.e(TAG, "Couldn't get session info", e); return null; } }
Example 18
Source File: TracingControllerAndroid.java From 365browser with Apache License 2.0 | 4 votes |
private void logAndToastError(String str) { Log.e(TAG, str); if (mShowToasts) Toast.makeText(mContext, str, Toast.LENGTH_SHORT).show(); }
Example 19
Source File: VideoCaptureCamera.java From 365browser with Apache License 2.0 | 4 votes |
@Override public boolean takePhoto(final long callbackId) { if (mCamera == null || !mIsRunning) { Log.e(TAG, "takePhoto: mCamera is null or is not running"); return false; } // Only one picture can be taken at once. synchronized (mPhotoTakenCallbackLock) { if (mPhotoTakenCallbackId != 0) return false; mPhotoTakenCallbackId = callbackId; } mPreviewParameters = getCameraParameters(mCamera); android.hardware.Camera.Parameters photoParameters = getCameraParameters(mCamera); photoParameters.setRotation(getCameraRotation()); if (mPhotoWidth > 0 || mPhotoHeight > 0) { final List<android.hardware.Camera.Size> supportedSizes = photoParameters.getSupportedPictureSizes(); android.hardware.Camera.Size closestSize = null; int minDiff = Integer.MAX_VALUE; for (android.hardware.Camera.Size size : supportedSizes) { final int diff = ((mPhotoWidth > 0) ? Math.abs(size.width - mPhotoWidth) : 0) + ((mPhotoHeight > 0) ? Math.abs(size.height - mPhotoHeight) : 0); if (diff < minDiff) { minDiff = diff; closestSize = size; } } if (minDiff != Integer.MAX_VALUE) { Log.d(TAG, "requested resolution: (%dx%d); matched (%dx%d)", mPhotoWidth, mPhotoHeight, closestSize.width, closestSize.height); photoParameters.setPictureSize(closestSize.width, closestSize.height); } } try { Log.d(TAG, "|photoParameters|: %s", photoParameters.flatten()); mCamera.setParameters(photoParameters); } catch (RuntimeException ex) { Log.e(TAG, "setParameters " + ex); return false; } mCamera.takePicture(null, null, null, new CrPictureCallback()); return true; }
Example 20
Source File: VideoCaptureCamera2.java From 365browser with Apache License 2.0 | 4 votes |
@Override public boolean allocate(int width, int height, int frameRate) { Log.d(TAG, "allocate: requested (%d x %d) @%dfps", width, height, frameRate); ThreadUtils.assertOnUiThread(); synchronized (mCameraStateLock) { if (mCameraState == CameraState.OPENING || mCameraState == CameraState.CONFIGURING) { Log.e(TAG, "allocate() invoked while Camera is busy opening/configuring."); return false; } } final CameraCharacteristics cameraCharacteristics = getCameraCharacteristics(mId); final StreamConfigurationMap streamMap = cameraCharacteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP); // Find closest supported size. final Size[] supportedSizes = streamMap.getOutputSizes(ImageFormat.YUV_420_888); final Size closestSupportedSize = findClosestSizeInArray(supportedSizes, width, height); if (closestSupportedSize == null) { Log.e(TAG, "No supported resolutions."); return false; } final List<Range<Integer>> fpsRanges = Arrays.asList(cameraCharacteristics.get( CameraCharacteristics.CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES)); if (fpsRanges.isEmpty()) { Log.e(TAG, "No supported framerate ranges."); return false; } final List<FramerateRange> framerateRanges = new ArrayList<FramerateRange>(fpsRanges.size()); // On some legacy implementations FPS values are multiplied by 1000. Multiply by 1000 // everywhere for consistency. Set fpsUnitFactor to 1 if fps ranges are already multiplied // by 1000. final int fpsUnitFactor = fpsRanges.get(0).getUpper() > 1000 ? 1 : 1000; for (Range<Integer> range : fpsRanges) { framerateRanges.add(new FramerateRange( range.getLower() * fpsUnitFactor, range.getUpper() * fpsUnitFactor)); } final FramerateRange aeFramerateRange = getClosestFramerateRange(framerateRanges, frameRate * 1000); mAeFpsRange = new Range<Integer>( aeFramerateRange.min / fpsUnitFactor, aeFramerateRange.max / fpsUnitFactor); Log.d(TAG, "allocate: matched (%d x %d) @[%d - %d]", closestSupportedSize.getWidth(), closestSupportedSize.getHeight(), mAeFpsRange.getLower(), mAeFpsRange.getUpper()); // |mCaptureFormat| is also used to configure the ImageReader. mCaptureFormat = new VideoCaptureFormat(closestSupportedSize.getWidth(), closestSupportedSize.getHeight(), frameRate, ImageFormat.YUV_420_888); mCameraNativeOrientation = cameraCharacteristics.get(CameraCharacteristics.SENSOR_ORIENTATION); // TODO(mcasas): The following line is correct for N5 with prerelease Build, // but NOT for N7 with a dev Build. Figure out which one to support. mInvertDeviceOrientationReadings = cameraCharacteristics.get(CameraCharacteristics.LENS_FACING) == CameraCharacteristics.LENS_FACING_BACK; return true; }