Java Code Examples for org.chromium.base.Log#d()

The following examples show how to use org.chromium.base.Log#d() . 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: UrlManager.java    From delion with Apache License 2.0 6 votes vote down vote up
/**
 * Get the list of URLs which are both nearby and resolved through PWS.
 * @param allowUnresolved If true, include unresolved URLs only if the
 * resolved URL list is empty.
 * @return A set of nearby URLs, sorted by distance.
 */
@VisibleForTesting
public List<UrlInfo> getUrls(boolean allowUnresolved) {
    Set<String> intersection = new HashSet<>(mNearbyUrls);
    intersection.retainAll(mResolvedUrls);
    Log.d(TAG, "Get URLs With: %d nearby, %d resolved, and %d in intersection.",
            mNearbyUrls.size(), mResolvedUrls.size(), intersection.size());

    List<UrlInfo> urlInfos = null;
    if (allowUnresolved && mResolvedUrls.isEmpty()) {
        urlInfos = getUrlInfoList(mNearbyUrls);
    } else {
        urlInfos = getUrlInfoList(intersection);
    }
    Collections.sort(urlInfos, new Comparator<UrlInfo>() {
        @Override
        public int compare(UrlInfo urlInfo1, UrlInfo urlInfo2) {
            return Double.compare(urlInfo1.getDistance(), urlInfo2.getDistance());
        }
    });
    return urlInfos;
}
 
Example 2
Source File: OfflinePageTabObserver.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Builds a new OfflinePageTabObserver.
 * @param tabModelSelector Tab model selector for the activity.
 * @param snackbarManager The snackbar manager to show and dismiss snackbars.
 * @param snackbarController Controller to use to build the snackbar.
 */
OfflinePageTabObserver(TabModelSelector tabModelSelector, SnackbarManager snackbarManager,
        SnackbarController snackbarController) {
    mSnackbarManager = snackbarManager;
    mSnackbarController = snackbarController;
    mTabModelSelector = tabModelSelector;
    mTabModelObserver = new TabModelSelectorTabModelObserver(tabModelSelector) {
        @Override
        public void tabRemoved(Tab tab) {
            Log.d(TAG, "tabRemoved");
            stopObservingTab(tab);
            mSnackbarManager.dismissSnackbars(mSnackbarController);
        }
    };
    // The first time observer is created snackbar has net yet been shown.
    mIsObservingNetworkChanges = false;
}
 
Example 3
Source File: DefaultMediaRouteController.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Send the given intent to the current route. The result will be returned in the given
 * ResultBundleHandler. This function will also check to see if the current route can handle the
 * intent before sending it.
 *
 * @param intent the intent to send to the current route.
 * @param bundleHandler contains the result of sending the intent
 */
private void sendIntentToRoute(final Intent intent, final ResultBundleHandler bundleHandler) {
    if (getCurrentRoute() == null) {
        logIntent("sendIntentToRoute ", intent);
        Log.d(TAG, "The current route is null.");
        if (bundleHandler != null) bundleHandler.onError(null, null);
        return;
    }

    if (!getCurrentRoute().supportsControlRequest(intent)) {
        logIntent("sendIntentToRoute ", intent);
        Log.d(TAG, "The intent is not supported by the route: %s", getCurrentRoute());
        if (bundleHandler != null) bundleHandler.onError(null, null);
        return;
    }

    sendControlIntent(intent, bundleHandler);
}
 
Example 4
Source File: OfflinePageTabObserver.java    From delion with Apache License 2.0 6 votes vote down vote up
@Override
public void onShown(Tab tab) {
    if (!getTabHelper().isOfflinePage(tab)) return;

    // Whenever we get a new tab shown, we will give a reload snackbar a chance to be shown,
    // therefor the state is reset to false. Also the currently shown tab is captured.
    mWasSnackbarShown = false;
    mCurrentTab = tab;
    if (isConnected() && !wasSnackbarShown()) {
        Log.d(TAG, "onShown, showing 'delayed' snackbar");
        showReloadSnackbar();
        // TODO(fgorski): Move the variable assignment to the method above, once
        // OfflinePageUtils can be mocked.
        mWasSnackbarShown = true;
    }
}
 
Example 5
Source File: TabPrinter.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
public boolean print() {
    Tab tab = mTab.get();
    if (tab == null || !tab.isInitialized()) {
        Log.d(TAG, "Tab not ready, unable to start printing.");
        return false;
    }
    return tab.print();
}
 
Example 6
Source File: RemoteMediaPlayerBridge.java    From 365browser with Apache License 2.0 5 votes vote down vote up
private void onRouteAvailabilityChange() {
    Log.d(TAG, "onRouteAvailabilityChange: " + mRouteIsAvailable + ", " + mIsPlayable);
    if (mNativeRemoteMediaPlayerBridge == 0) return;

    int availability = WebRemotePlaybackAvailability.DEVICE_NOT_AVAILABLE;
    if (!mRouteIsAvailable && !mIsPlayable) {
        availability = WebRemotePlaybackAvailability.SOURCE_NOT_SUPPORTED;
    } else if (mRouteIsAvailable && mIsPlayable) {
        availability = WebRemotePlaybackAvailability.DEVICE_AVAILABLE;
    } else if (mRouteIsAvailable) {
        // mIsPlayable is false here.
        availability = WebRemotePlaybackAvailability.SOURCE_NOT_COMPATIBLE;
    }
    nativeOnRouteAvailabilityChanged(mNativeRemoteMediaPlayerBridge, availability);
}
 
Example 7
Source File: RemoteMediaPlayerBridge.java    From 365browser with Apache License 2.0 5 votes vote down vote up
private RemoteMediaPlayerBridge(long nativeRemoteMediaPlayerBridge, String sourceUrl,
        String frameUrl, String userAgent) {
    Log.d(TAG, "Creating RemoteMediaPlayerBridge");
    mNativeRemoteMediaPlayerBridge = nativeRemoteMediaPlayerBridge;
    mOriginalSourceUrl = sourceUrl;
    mOriginalFrameUrl = frameUrl;
    mUserAgent = userAgent;
    // This will get null if there isn't a mediaRouteController that can play this media.
    mRouteController = RemoteMediaPlayerController.instance()
            .getMediaRouteController(sourceUrl, frameUrl);
}
 
Example 8
Source File: BackgroundOfflinerTask.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Triggers processing of background offlining requests.  This is called when
 * system conditions are appropriate for background offlining, typically from the
 * GcmTaskService onRunTask() method.  In response, we will start the
 * task processing by passing the call along to the C++ RequestCoordinator.
 * Also starts UMA collection.
 *
 * @returns true for success
 */
public boolean startBackgroundRequests(Context context, Bundle bundle,
                                       ChromeBackgroundServiceWaiter waiter) {
    // Set up backup scheduled task in case processing is killed before RequestCoordinator
    // has a chance to reschedule base on remaining work.
    TriggerConditions previousTriggerConditions =
            TaskExtrasPacker.unpackTriggerConditionsFromBundle(bundle);
    BackgroundScheduler.backupSchedule(context, previousTriggerConditions, DEFER_START_SECONDS);

    DeviceConditions currentConditions = OfflinePageUtils.getDeviceConditions(context);
    if (!currentConditions.isPowerConnected()
            && currentConditions.getBatteryPercentage()
                    < previousTriggerConditions.getMinimumBatteryPercentage()) {
        Log.d(TAG, "Battery percentage is lower than minimum to start processing");
        return false;
    }

    if (SysUtils.isLowEndDevice() && ApplicationStatus.hasVisibleActivities()) {
        Log.d(TAG, "Application visible on low-end device so deferring background processing");
        return false;
    }

    // Now initiate processing.
    processBackgroundRequests(bundle, currentConditions, waiter);

    // Gather UMA data to measure how often the user's machine is amenable to background
    // loading when we wake to do a task.
    long taskScheduledTimeMillis = TaskExtrasPacker.unpackTimeFromBundle(bundle);
    OfflinePageUtils.recordWakeupUMA(context, taskScheduledTimeMillis);

    return true;
}
 
Example 9
Source File: VideoCaptureCamera2.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public void onConfigured(CameraCaptureSession cameraCaptureSession) {
    Log.d(TAG, "CrPreviewSessionListener.onConfigured");
    mPreviewSession = cameraCaptureSession;
    try {
        // This line triggers the preview. A |listener| is registered to receive the actual
        // capture result details. A CrImageReaderListener will be triggered every time a
        // downloaded image is ready. Since |handler| is null, we'll work on the current
        // Thread Looper.
        mPreviewSession.setRepeatingRequest(
                mPreviewRequest, new CameraCaptureSession.CaptureCallback() {
                    @Override
                    public void onCaptureCompleted(CameraCaptureSession session,
                            CaptureRequest request, TotalCaptureResult result) {
                        mLastExposureTimeNs =
                                result.get(CaptureResult.SENSOR_EXPOSURE_TIME);
                    }
                }, null);

    } catch (CameraAccessException | SecurityException | IllegalStateException
            | IllegalArgumentException ex) {
        Log.e(TAG, "setRepeatingRequest: ", ex);
        return;
    }
    // Now wait for trigger on CrPreviewReaderListener.onImageAvailable();
    nativeOnStarted(mNativeVideoCaptureDeviceAndroid);
    changeCameraStateAndNotify(CameraState.STARTED);
}
 
Example 10
Source File: TabPersistentStore.java    From 365browser with Apache License 2.0 5 votes vote down vote up
private void restoreTab(TabRestoreDetails tabToRestore, boolean setAsActive) {
    // As we do this in startup, and restoring the active tab's state is critical, we permit
    // this read in the event that the prefetch task is not available. Either:
    // 1. The user just upgraded, has not yet set the new active tab id pref yet. Or
    // 2. restoreTab is used to preempt async queue and restore immediately on the UI thread.
    StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
    try {
        long time = SystemClock.uptimeMillis();
        TabState state;
        int restoredTabId = mPreferences.getInt(PREF_ACTIVE_TAB_ID, Tab.INVALID_TAB_ID);
        if (restoredTabId == tabToRestore.id && mPrefetchActiveTabTask != null) {
            long timeWaitingForPrefetch = SystemClock.uptimeMillis();
            state = mPrefetchActiveTabTask.get();
            logExecutionTime("RestoreTabPrefetchTime", timeWaitingForPrefetch);
        } else {
            // Necessary to do on the UI thread as a last resort.
            state = TabState.restoreTabState(getStateDirectory(), tabToRestore.id);
        }
        logExecutionTime("RestoreTabTime", time);
        restoreTab(tabToRestore, state, setAsActive);
    } catch (Exception e) {
        // Catch generic exception to prevent a corrupted state from crashing the app
        // at startup.
        Log.d(TAG, "loadTabs exception: " + e.toString(), e);
    } finally {
        StrictMode.setThreadPolicy(oldPolicy);
    }
}
 
Example 11
Source File: AbstractMediaRouteController.java    From 365browser with Apache License 2.0 5 votes vote down vote up
private void startWatchingRouteSelection() {
    if (mWatchingRouteSelection || mediaRouterInitializationFailed()) return;

    mWatchingRouteSelection = true;
    // Start listening
    getMediaRouter().addCallback(mMediaRouteSelector, mDeviceSelectionCallback,
            MediaRouter.CALLBACK_FLAG_REQUEST_DISCOVERY);
    Log.d(TAG, "Started route selection discovery");
}
 
Example 12
Source File: CastMediaRouteProvider.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public void sendStringMessage(String routeId, String message, int nativeCallbackId) {
    Log.d(TAG, "Received message from client: %s", message);

    if (!mRoutes.containsKey(routeId)) {
        mManager.onMessageSentResult(false, nativeCallbackId);
        return;
    }

    boolean success = false;
    try {
        JSONObject jsonMessage = new JSONObject(message);

        String messageType = jsonMessage.getString("type");
        // TODO(zqzhang): Move the handling of "client_connect", "client_disconnect" and
        // "leave_session" from CastMRP to CastMessageHandler. Also, need to have a
        // ClientManager for client managing.
        if ("client_connect".equals(messageType)) {
            success = handleClientConnectMessage(jsonMessage);
        } else if ("client_disconnect".equals(messageType)) {
            success = handleClientDisconnectMessage(jsonMessage);
        } else if ("leave_session".equals(messageType)) {
            success = handleLeaveSessionMessage(jsonMessage);
        } else if (mSession != null) {
            success = mMessageHandler.handleSessionMessage(jsonMessage);
        }
    } catch (JSONException e) {
        Log.e(TAG, "JSONException while handling internal message: " + e);
        success = false;
    }

    mManager.onMessageSentResult(success, nativeCallbackId);
}
 
Example 13
Source File: DelayedInvalidationsController.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Notify any invalidations that were delayed while Chromium was backgrounded.
 * @return whether there were any invalidations pending to be notified.
 */
public boolean notifyPendingInvalidations(final Context context) {
    SharedPreferences prefs = ContextUtils.getAppSharedPreferences();
    String accountName = prefs.getString(DELAYED_ACCOUNT_NAME, null);
    if (accountName == null) {
        Log.d(TAG, "No pending invalidations.");
        return false;
    } else {
        Log.d(TAG, "Handling pending invalidations.");
        Account account = AccountManagerHelper.createAccountFromName(accountName);
        List<Bundle> bundles = popPendingInvalidations(context);
        notifyInvalidationsOnBackgroundThread(context, account, bundles);
        return true;
    }
}
 
Example 14
Source File: PhysicalWebBleClient.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Begin a background subscription to URLs broadcasted from BLE beacons.
 * This currently does nothing and should be overridden by a subclass.
 * @param callback Callback to be run when subscription task is done, regardless of whether it
 *         is successful.
 */
void backgroundSubscribe(Runnable callback) {
    Log.d(TAG, "background subscribing in empty client");
    if (callback != null) {
        callback.run();
    }
}
 
Example 15
Source File: CastSessionImpl.java    From delion with Apache License 2.0 4 votes vote down vote up
@Override
public void onMessageReceived(CastDevice castDevice, String namespace, String message) {
    Log.d(TAG, "Received message from Cast device: namespace=\"" + namespace
               + "\" message=\"" + message + "\"");
    mSession.getMessageHandler().onMessageReceived(namespace, message);
}
 
Example 16
Source File: ThreadedInputConnectionFactory.java    From 365browser with Apache License 2.0 4 votes vote down vote up
@Override
public void onViewDetachedFromWindow() {
    if (DEBUG_LOGS) Log.d(TAG, "onViewDetachedFromWindow");
    if (mCheckInvalidator != null) mCheckInvalidator.invalidate();
    if (mProxyView != null) mProxyView.onOriginalViewDetachedFromWindow();
}
 
Example 17
Source File: ClearNotificationAlarmReceiver.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
    Log.d(TAG, "Running NotificationCleanupAlarmReceiver");
    UrlManager.getInstance().clearNotification();
}
 
Example 18
Source File: AbstractAppRestrictionsProvider.java    From 365browser with Apache License 2.0 3 votes vote down vote up
/**
 * Restrictions to be used during tests. Subsequent attempts to retrieve the restrictions will
 * return the provided bundle instead.
 *
 * Chrome and WebView tests are set up to use annotations for policy testing and reset the
 * restrictions to an empty bundle if nothing is specified. To stop using a test bundle,
 * provide {@code null} as value instead.
 */
@VisibleForTesting
public static void setTestRestrictions(Bundle policies) {
    Log.d(TAG, "Test Restrictions: %s",
            (policies == null ? null : policies.keySet().toArray()));
    sTestRestrictions = policies;
}
 
Example 19
Source File: PhysicalWebBleClient.java    From AndroidChromium with Apache License 2.0 2 votes vote down vote up
/**
 * Cancel a foreground subscription to URLs broadcasted from BLE beacons.
 * This currently does nothing and should be overridden by a subclass.
 */
void foregroundUnsubscribe() {
    Log.d(TAG, "foreground unsubscribing in empty client");
}
 
Example 20
Source File: PhysicalWebBleClient.java    From delion with Apache License 2.0 2 votes vote down vote up
/**
 * Cancel a foreground subscription to URLs broadcasted from BLE beacons.
 * This currently does nothing and should be overridden by a subclass.
 */
void foregroundUnsubscribe() {
    Log.d(TAG, "foreground unsubscribing in empty client");
}