org.chromium.base.Log Java Examples
The following examples show how to use
org.chromium.base.Log.
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: ChromeDownloadDelegate.java From delion with Apache License 2.0 | 6 votes |
/** * Check the external storage and notify user on error. * * @param fullDirPath The dir path to download a file. Normally this is external storage. * @param externalStorageStatus The status of the external storage. * @return Whether external storage is ok for downloading. */ private boolean checkExternalStorageAndNotify( String filename, String fullDirPath, String externalStorageStatus) { if (fullDirPath == null) { Log.e(TAG, "Download failed: no SD card"); alertDownloadFailure( filename, DownloadManager.ERROR_DEVICE_NOT_FOUND); return false; } if (!externalStorageStatus.equals(Environment.MEDIA_MOUNTED)) { int reason = DownloadManager.ERROR_DEVICE_NOT_FOUND; // Check to see if the SDCard is busy, same as the music app if (externalStorageStatus.equals(Environment.MEDIA_SHARED)) { Log.e(TAG, "Download failed: SD card unavailable"); reason = DownloadManager.ERROR_FILE_ERROR; } else { Log.e(TAG, "Download failed: no SD card"); } alertDownloadFailure(filename, reason); return false; } return true; }
Example #2
Source File: WebappLauncherActivity.java From delion with Apache License 2.0 | 6 votes |
/** * Checks whether the package being targeted is a valid WebAPK and whether the url supplied * can be fulfilled by that WebAPK. * * @param webApkPackage The package name of the requested WebAPK. * @param url The url to navigate to. * @return true iff all validation criteria are met. */ private boolean isValidWebApk(String webApkPackage, String url) { if (!CommandLine.getInstance().hasSwitch(ChromeSwitches.ENABLE_WEBAPK) || webApkPackage == null) { return false; } if (!WebApkValidator.isValidWebApk(this, webApkPackage)) { Log.d(TAG, "%s is not valid WebAPK", webApkPackage); return false; } if (!webApkPackage.equals(WebApkValidator.queryWebApkPackage(this, url))) { Log.d(TAG, "%s is not within scope of %s WebAPK", url, webApkPackage); return false; } return true; }
Example #3
Source File: TabPersistentStore.java From delion with Apache License 2.0 | 6 votes |
/** * Atomically writes the given serialized data out to disk. * @param stateDirectory Directory to save TabModel data into. * @param selectorIndex Index of the TabModelSelector to write out. * @param listData TabModel data in the form of a serialized byte array. */ public static void saveListToFile(File stateDirectory, int selectorIndex, byte[] listData) { synchronized (SAVE_LIST_LOCK) { // Save the index file containing the list of tabs to restore. File metadataFile = new File(stateDirectory, getStateFileName(selectorIndex)); AtomicFile file = new AtomicFile(metadataFile); FileOutputStream stream = null; try { stream = file.startWrite(); stream.write(listData, 0, listData.length); file.finishWrite(stream); } catch (IOException e) { if (stream != null) file.failWrite(stream); Log.e(TAG, "Failed to write file: " + metadataFile.getAbsolutePath()); } } }
Example #4
Source File: CreateRouteRequest.java From 365browser with Apache License 2.0 | 6 votes |
@Override public void onConnected(Bundle connectionHint) { if (mState != STATE_CONNECTING_TO_API && mState != STATE_API_CONNECTION_SUSPENDED) { throwInvalidState(); } // TODO(avayvod): switch to using ConnectedTask class for GoogleApiClient operations. // See https://crbug.com/522478 if (mState == STATE_API_CONNECTION_SUSPENDED) return; try { launchApplication(mApiClient, mSource.getApplicationId(), true) .setResultCallback(this); mState = STATE_LAUNCHING_APPLICATION; } catch (Exception e) { Log.e(TAG, "Launch application failed: %s", mSource.getApplicationId(), e); reportError(); } }
Example #5
Source File: NewTabPageAdapter.java From AndroidChromium with Apache License 2.0 | 6 votes |
@Override public void onNewSuggestions(@CategoryInt int category) { @CategoryStatusEnum int status = mNewTabPageManager.getSuggestionsSource().getCategoryStatus(category); if (!canLoadSuggestions(category, status)) return; // We never want to refresh the suggestions if we already have some content. if (mSections.get(category).hasSuggestions()) return; List<SnippetArticle> suggestions = mNewTabPageManager.getSuggestionsSource().getSuggestionsForCategory(category); Log.d(TAG, "Received %d new suggestions for category %d.", suggestions.size(), category); // At first, there might be no suggestions available, we wait until they have been fetched. if (suggestions.isEmpty()) return; setSuggestions(category, suggestions, status); }
Example #6
Source File: ConnectivityTask.java From delion with Apache License 2.0 | 6 votes |
/** * Starts the current task by calling the appropriate method on the * {@link ConnectivityChecker}. * The result will be put in {@link #mResult} when it comes back from the network stack. */ public void start(Profile profile, int timeoutMs) { Log.v(TAG, "Starting task for " + mType); switch (mType) { case CHROME_HTTP: ConnectivityChecker.checkConnectivityChromeNetworkStack( profile, false, timeoutMs, this); break; case CHROME_HTTPS: ConnectivityChecker.checkConnectivityChromeNetworkStack( profile, true, timeoutMs, this); break; case SYSTEM_HTTP: ConnectivityChecker.checkConnectivitySystemNetworkStack(false, timeoutMs, this); break; case SYSTEM_HTTPS: ConnectivityChecker.checkConnectivitySystemNetworkStack(true, timeoutMs, this); break; default: Log.e(TAG, "Failed to recognize type " + mType); } }
Example #7
Source File: HttpNegotiateAuthenticator.java From 365browser with Apache License 2.0 | 6 votes |
/** * Requests an authentication token. If the account is not properly setup, it will result in * a failure. * * @param ctx The application context * @param requestData The object holding the data related to the current request * @param features An array of the account features to require, may be null or empty */ private void requestTokenWithoutActivity( Context ctx, RequestData requestData, String[] features) { if (lacksPermission(ctx, Manifest.permission.GET_ACCOUNTS, true /* onlyPreM */)) { // Protecting the AccountManager#getAccountsByTypeAndFeatures call. // API < 23 Requires the GET_ACCOUNTS permission or throws an exception. // API >= 23 Requires the GET_ACCOUNTS permission (CONTACTS permission group) or // returns only the accounts whose authenticator has a signature that // matches our app. Working with this restriction and not requesting // the permission is a valid use case in the context of WebView, so we // don't require it on M+ Log.e(TAG, "ERR_MISCONFIGURED_AUTH_ENVIRONMENT: GET_ACCOUNTS permission not " + "granted. Aborting authentication."); nativeSetResult(requestData.nativeResultObject, NetError.ERR_MISCONFIGURED_AUTH_ENVIRONMENT, null); return; } requestData.accountManager.getAccountsByTypeAndFeatures(mAccountType, features, new GetAccountsCallback(requestData), new Handler(ThreadUtils.getUiThreadLooper())); }
Example #8
Source File: FeatureUtilities.java From delion with Apache License 2.0 | 6 votes |
/** * @return Which flavor of Herb is being tested. See {@link ChromeSwitches#HERB_FLAVOR_ANISE} * and its related switches. */ public static String getHerbFlavor() { Context context = ContextUtils.getApplicationContext(); if (isHerbDisallowed(context)) return ChromeSwitches.HERB_FLAVOR_DISABLED; if (!sIsHerbFlavorCached) { sCachedHerbFlavor = null; // Allowing disk access for preferences while prototyping. StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads(); try { sCachedHerbFlavor = ChromePreferenceManager.getInstance(context).getCachedHerbFlavor(); } finally { StrictMode.setThreadPolicy(oldPolicy); } sIsHerbFlavorCached = true; Log.d(TAG, "Retrieved cached Herb flavor: " + sCachedHerbFlavor); } return sCachedHerbFlavor; }
Example #9
Source File: NewTabPageAdapter.java From delion with Apache License 2.0 | 6 votes |
@Override public void onSnippetsReceived(List<SnippetArticle> listSnippets) { if (!mWantsSnippets) return; int newSnippetCount = listSnippets.size(); Log.d(TAG, "Received %d new snippets.", newSnippetCount); // At first, there might be no snippets available, we wait until they have been fetched. if (newSnippetCount == 0) return; loadSnippets(listSnippets); // We don't want to get notified of other changes. mWantsSnippets = false; NewTabPageUma.recordSnippetAction(NewTabPageUma.SNIPPETS_ACTION_SHOWN); }
Example #10
Source File: PhysicalWebPreferenceFragment.java From delion with Apache License 2.0 | 6 votes |
@Override public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) { switch (requestCode) { case REQUEST_ID: if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { PhysicalWebUma.onPrefsLocationGranted(getActivity()); Log.d(TAG, "Location permission granted"); PhysicalWeb.startPhysicalWeb( (ChromeApplication) getActivity().getApplicationContext()); } else { PhysicalWebUma.onPrefsLocationDenied(getActivity()); Log.d(TAG, "Location permission denied"); } break; default: } }
Example #11
Source File: MediaNotificationManager.java From 365browser with Apache License 2.0 | 6 votes |
@VisibleForTesting void showNotificationImmediately(MediaNotificationInfo mediaNotificationInfo) { // If no notification hasn't been updated in the last THROTTLE_MILLIS, update // immediately and queue a task for blocking further updates. mManager.showNotification(mediaNotificationInfo); mTask = new Runnable() { @Override public void run() { if (mLastPendingInfo != null) { // If any notification info is pended during the throttling time window, // update the notification. showNotificationImmediately(mLastPendingInfo); mLastPendingInfo = null; } else { // Otherwise, clear the task so further update is unthrottled. mTask = null; } } }; if (!mHandler.postDelayed(mTask, THROTTLE_MILLIS)) { Log.w(TAG, "Failed to post the throttler task."); mTask = null; } }
Example #12
Source File: ChromeBluetoothDevice.java From 365browser with Apache License 2.0 | 6 votes |
@Override public void onCharacteristicWrite( final Wrappers.BluetoothGattCharacteristicWrapper characteristic, final int status) { Wrappers.ThreadUtilsWrapper.getInstance().runOnUiThread(new Runnable() { @Override public void run() { ChromeBluetoothRemoteGattCharacteristic chromeCharacteristic = mWrapperToChromeCharacteristicsMap.get(characteristic); if (chromeCharacteristic == null) { // Android events arriving with no Chrome object is expected rarely: only // when the event races object destruction. Log.v(TAG, "onCharacteristicWrite when chromeCharacteristic == null."); } else { RecordHistogram.recordSparseSlowlyHistogram( "Bluetooth.Web.Android.onCharacteristicWrite.Status", status); chromeCharacteristic.onCharacteristicWrite(status); } } }); }
Example #13
Source File: CreateRouteRequest.java From AndroidChromium with Apache License 2.0 | 6 votes |
@Override public void onResult(Cast.ApplicationConnectionResult result) { if (mState != STATE_LAUNCHING_APPLICATION && mState != STATE_API_CONNECTION_SUSPENDED) { throwInvalidState(); } Status status = result.getStatus(); if (!status.isSuccess()) { Log.e(TAG, "Launch application failed with status: %s, %d, %s", mSource.getApplicationId(), status.getStatusCode(), status.getStatusMessage()); reportError(); } mState = STATE_LAUNCH_SUCCEEDED; reportSuccess(result); }
Example #14
Source File: IntentWithGesturesHandler.java From AndroidChromium with Apache License 2.0 | 6 votes |
/** * Generate a new token for the intent that has user gesture. This will * invalidate the token on the previously launched intent with user gesture. * * @param intent Intent with user gesture. */ public void onNewIntentWithGesture(Intent intent) { if (mSecureRandomInitializer != null) { try { mSecureRandom = mSecureRandomInitializer.get(); } catch (InterruptedException | ExecutionException e) { Log.e(TAG, "Error fetching SecureRandom", e); } mSecureRandomInitializer = null; } if (mSecureRandom == null) return; mIntentToken = new byte[32]; mSecureRandom.nextBytes(mIntentToken); intent.putExtra(EXTRA_USER_GESTURE_TOKEN, mIntentToken); mUri = IntentHandler.getUrlFromIntent(intent); }
Example #15
Source File: ImeAdapter.java From 365browser with Apache License 2.0 | 6 votes |
/** * @see BaseInputConnection#performContextMenuAction(int) */ boolean performContextMenuAction(int id) { if (DEBUG_LOGS) Log.i(TAG, "performContextMenuAction: id [%d]", id); switch (id) { case android.R.id.selectAll: mWebContents.selectAll(); return true; case android.R.id.cut: mWebContents.cut(); return true; case android.R.id.copy: mWebContents.copy(); return true; case android.R.id.paste: mWebContents.paste(); return true; default: return false; } }
Example #16
Source File: MinidumpUploadService.java From AndroidChromium with Apache License 2.0 | 6 votes |
private void handleFindAndUploadLastCrash(Intent intent) { CrashFileManager fileManager = new CrashFileManager(getApplicationContext().getCacheDir()); File[] minidumpFiles = fileManager.getAllMinidumpFiles(MAX_TRIES_ALLOWED); if (minidumpFiles.length == 0) { // Try again later. Maybe the minidump hasn't finished being written. Log.d(TAG, "Could not find any crash dumps to upload"); return; } File minidumpFile = minidumpFiles[0]; File logfile = fileManager.getCrashUploadLogFile(); Intent uploadIntent = createUploadIntent(getApplicationContext(), minidumpFile, logfile); // We should have at least one chance to secure logcat to the minidump now. uploadIntent.putExtra(FINISHED_LOGCAT_EXTRACTION_KEY, true); startService(uploadIntent); }
Example #17
Source File: SigninManager.java From delion with Apache License 2.0 | 6 votes |
/** * Starts the sign-in flow, and executes the callback when finished. * * If an activity is provided, it is considered an "interactive" sign-in and the user can be * prompted to confirm various aspects of sign-in using dialogs inside the activity. * The sign-in flow goes through the following steps: * * - Wait for AccountTrackerService to be seeded. * - If interactive, confirm the account change with the user. * - Wait for policy to be checked for the account. * - If interactive and the account is managed, warn the user. * - If managed, wait for the policy to be fetched. * - Complete sign-in with the native SigninManager and kick off token requests. * - Call the callback if provided. * * @param account The account to sign in to. * @param activity The activity used to launch UI prompts, or null for a forced signin. * @param callback Optional callback for when the sign-in process is finished. */ public void signIn( Account account, @Nullable Activity activity, @Nullable SignInCallback callback) { if (account == null) { Log.w(TAG, "Ignoring sign-in request due to null account."); if (callback != null) callback.onSignInAborted(); return; } if (mSignInState != null) { Log.w(TAG, "Ignoring sign-in request as another sign-in request is pending."); if (callback != null) callback.onSignInAborted(); return; } if (mFirstRunCheckIsPending) { Log.w(TAG, "Ignoring sign-in request until the First Run check completes."); if (callback != null) callback.onSignInAborted(); return; } mSignInState = new SignInState(account, activity, callback); notifySignInAllowedChanged(); progressSignInFlowSeedSystemAccounts(); }
Example #18
Source File: RemoteMediaPlayerController.java From 365browser with Apache License 2.0 | 6 votes |
private void showMediaRouteDialog(MediaStateListener player, MediaRouteController controller, Activity activity) { FragmentManager fm = ((FragmentActivity) activity).getSupportFragmentManager(); if (fm == null) { throw new IllegalStateException("The activity must be a subclass of FragmentActivity"); } MediaRouteDialogFactory factory = new MediaRouteChooserDialogFactory(player, controller, activity); if (fm.findFragmentByTag( "android.support.v7.mediarouter:MediaRouteChooserDialogFragment") != null) { Log.w(TAG, "showDialog(): Route chooser dialog already showing!"); return; } MediaRouteChooserDialogFragment f = factory.onCreateChooserDialogFragment(); f.setRouteSelector(controller.buildMediaRouteSelector()); f.show(fm, "android.support.v7.mediarouter:MediaRouteChooserDialogFragment"); }
Example #19
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 #20
Source File: TabPrinter.java From AndroidChromium with Apache License 2.0 | 5 votes |
@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 #21
Source File: DelayedInvalidationsController.java From 365browser with Apache License 2.0 | 5 votes |
/** * 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 #22
Source File: SnippetsLauncher.java From 365browser with Apache License 2.0 | 5 votes |
@CalledByNative private boolean schedule(long periodWifiSeconds, long periodFallbackSeconds) { if (!mGCMEnabled) return false; Log.i(TAG, "Scheduling: " + periodWifiSeconds + " " + periodFallbackSeconds); boolean isScheduled = periodWifiSeconds != 0 || periodFallbackSeconds != 0; ContextUtils.getAppSharedPreferences() .edit() .putBoolean(PREF_IS_SCHEDULED, isScheduled) .apply(); // Google Play Services may not be up to date, if the application was not installed through // the Play Store. In this case, scheduling the task will fail silently. try { mScheduler.cancelTask(OBSOLETE_TASK_TAG_WIFI_CHARGING, ChromeBackgroundService.class); scheduleOrCancelFetchTask( TASK_TAG_WIFI, periodWifiSeconds, Task.NETWORK_STATE_UNMETERED); scheduleOrCancelFetchTask( TASK_TAG_FALLBACK, periodFallbackSeconds, Task.NETWORK_STATE_CONNECTED); mScheduler.cancelTask(OBSOLETE_TASK_TAG_RESCHEDULE, ChromeBackgroundService.class); } catch (IllegalArgumentException e) { // Disable GCM for the remainder of this session. mGCMEnabled = false; ContextUtils.getAppSharedPreferences().edit().remove(PREF_IS_SCHEDULED).apply(); // Return false so that the failure will be logged. return false; } return true; }
Example #23
Source File: CustomButtonParams.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * Parses a list of {@link CustomButtonParams} from the intent sent by clients. * @param intent The intent sent by the client. * @return A list of parsed {@link CustomButtonParams}. Return an empty list if input is invalid */ static List<CustomButtonParams> fromIntent(Context context, Intent intent) { List<CustomButtonParams> paramsList = new ArrayList<>(1); if (intent == null) return paramsList; Bundle singleBundle = IntentUtils.safeGetBundleExtra(intent, CustomTabsIntent.EXTRA_ACTION_BUTTON_BUNDLE); ArrayList<Bundle> bundleList = IntentUtils.getParcelableArrayListExtra(intent, CustomTabsIntent.EXTRA_TOOLBAR_ITEMS); boolean tinted = IntentUtils.safeGetBooleanExtra(intent, CustomTabsIntent.EXTRA_TINT_ACTION_BUTTON, false); if (singleBundle != null) { CustomButtonParams singleParams = fromBundle(context, singleBundle, tinted, false); if (singleParams != null) paramsList.add(singleParams); } if (bundleList != null) { Set<Integer> ids = new HashSet<>(); for (Bundle bundle : bundleList) { CustomButtonParams params = fromBundle(context, bundle, tinted, true); if (params == null) { continue; } else if (ids.contains(params.getId())) { Log.e(TAG, "Bottom bar items contain duplicate id: " + params.getId()); continue; } ids.add(params.getId()); paramsList.add(params); } } return paramsList; }
Example #24
Source File: CastSessionImpl.java From delion with Apache License 2.0 | 5 votes |
@Override public HandleVolumeMessageResult handleVolumeMessage( JSONObject volume, final String clientId, final int sequenceNumber) throws JSONException { if (volume == null) return new HandleVolumeMessageResult(false, false); if (isApiClientInvalid()) return new HandleVolumeMessageResult(false, false); boolean waitForVolumeChange = false; try { if (!volume.isNull("muted")) { boolean newMuted = volume.getBoolean("muted"); if (Cast.CastApi.isMute(mApiClient) != newMuted) { Cast.CastApi.setMute(mApiClient, newMuted); waitForVolumeChange = true; } } if (!volume.isNull("level")) { double newLevel = volume.getDouble("level"); double currentLevel = Cast.CastApi.getVolume(mApiClient); if (!Double.isNaN(currentLevel) && Math.abs(currentLevel - newLevel) > MIN_VOLUME_LEVEL_DELTA) { Cast.CastApi.setVolume(mApiClient, newLevel); waitForVolumeChange = true; } } } catch (IOException e) { Log.e(TAG, "Failed to send volume command: " + e); return new HandleVolumeMessageResult(false, false); } return new HandleVolumeMessageResult(true, waitForVolumeChange); }
Example #25
Source File: IntentUtils.java From delion with Apache License 2.0 | 5 votes |
/** * Just like {@link Intent#getStringExtra(String)} but doesn't throw exceptions. */ public static String safeGetStringExtra(Intent intent, String name) { try { return intent.getStringExtra(name); } catch (Throwable t) { // Catches un-parceling exceptions. Log.e(TAG, "getStringExtra failed on intent " + intent); return null; } }
Example #26
Source File: InputMethodManagerWrapper.java From 365browser with Apache License 2.0 | 5 votes |
/** * @see android.view.inputmethod.InputMethodManager#updateSelection(View, int, int, int, int) */ public void updateSelection(View view, int selStart, int selEnd, int candidatesStart, int candidatesEnd) { if (DEBUG_LOGS) { Log.i(TAG, "updateSelection: SEL [%d, %d], COM [%d, %d]", selStart, selEnd, candidatesStart, candidatesEnd); } getInputMethodManager().updateSelection(view, selStart, selEnd, candidatesStart, candidatesEnd); }
Example #27
Source File: TabbedModeTabPersistencePolicy.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * Upgrades users from an old version of Chrome when the state file was still in the root * directory. */ @WorkerThread private void performLegacyMigration() { Log.w(TAG, "Starting to perform legacy migration."); File newFolder = getOrCreateStateDirectory(); File[] newFiles = newFolder.listFiles(); // Attempt migration if we have no tab state file in the new directory. if (newFiles == null || newFiles.length == 0) { File oldFolder = ContextUtils.getApplicationContext().getFilesDir(); File modelFile = new File(oldFolder, LEGACY_SAVED_STATE_FILE); if (modelFile.exists()) { if (!modelFile.renameTo(new File(newFolder, getStateFileName()))) { Log.e(TAG, "Failed to rename file: " + modelFile); } } File[] files = oldFolder.listFiles(); if (files != null) { for (File file : files) { if (TabState.parseInfoFromFilename(file.getName()) != null) { if (!file.renameTo(new File(newFolder, file.getName()))) { Log.e(TAG, "Failed to rename file: " + file); } } } } } setLegacyFileMigrationPref(); Log.w(TAG, "Finished performing legacy migration."); }
Example #28
Source File: SelectFileDialog.java From 365browser with Apache License 2.0 | 5 votes |
@Override public Uri doInBackground(Void...voids) { try { Context context = mWindowAndroid.getApplicationContext(); return ApiCompatibilityUtils.getUriForImageCaptureFile( getFileForImageCapture(context)); } catch (IOException e) { Log.e(TAG, "Cannot retrieve content uri from file", e); return null; } }
Example #29
Source File: DownloadManagerService.java From 365browser with Apache License 2.0 | 5 votes |
/** * Open the Activity which shows a list of all downloads. * @param context Application context */ public static void openDownloadsPage(Context context) { if (DownloadUtils.showDownloadManager(null, null)) return; // Open the Android Download Manager. Intent pageView = new Intent(DownloadManager.ACTION_VIEW_DOWNLOADS); pageView.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); try { context.startActivity(pageView); } catch (ActivityNotFoundException e) { Log.e(TAG, "Cannot find Downloads app", e); } }
Example #30
Source File: UrlManager.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * Add a URL to the store of URLs. * This method additionally updates the Physical Web notification. * @param urlInfo The URL to add. */ @VisibleForTesting public void addUrl(UrlInfo urlInfo) { Log.d(TAG, "URL found: %s", urlInfo); urlInfo = updateCacheEntry(urlInfo); garbageCollect(); putCachedUrlInfoMap(); recordUpdate(); // In the rare event that our entry is immediately garbage collected from the cache, we // should stop here. if (!mUrlInfoMap.containsKey(urlInfo.getUrl())) { return; } if (mNearbyUrls.contains(urlInfo.getUrl())) { // The URL has been seen before. Notify listeners with the new distance estimate. if (urlInfo.getDistance() >= 0.0 && mPwsResultMap.containsKey(urlInfo.getUrl())) { safeNotifyNativeListenersOnDistanceChanged(urlInfo.getUrl(), urlInfo.getDistance()); } return; } // This is a new URL. Add it to the nearby set. mNearbyUrls.add(urlInfo.getUrl()); putCachedNearbyUrls(); if (!PhysicalWeb.isOnboarding() && !mPwsResultMap.containsKey(urlInfo.getUrl())) { // We need to resolve the URL. resolveUrl(urlInfo); return; } registerNewDisplayableUrl(urlInfo); }