Beispiel #1
0
 @Override
 public void onResult(int result) {
   ThreadUtils.assertOnUiThread();
   Log.v(
       TAG,
       "Got result for "
           + getHumanReadableType(mType)
           + ": result = "
           + getHumanReadableResult(result));
   mResult.put(mType, result);
   if (isDone()) postCallbackResult();
 }
  /**
   * Set whether or not precaching is enabled. If precaching is enabled, this receiver will start
   * the PrecacheService when it receives an intent. If precaching is disabled, any running
   * PrecacheService will be stopped, and this receiver will do nothing when it receives an intent.
   *
   * @param context The Context to use.
   * @param enabled Whether or not precaching is enabled.
   */
  public static void setIsPrecachingEnabled(Context context, boolean enabled) {
    Log.v(TAG, "setIsPrecachingEnabled(%s)", enabled);
    Editor editor = PreferenceManager.getDefaultSharedPreferences(context).edit();
    editor.putBoolean(PREF_IS_PRECACHING_ENABLED, enabled);
    editor.apply();

    if (!enabled) {
      // Stop any running PrecacheService. If PrecacheService is not running, then this does
      // nothing.
      Intent serviceIntent = new Intent(null, null, context, PrecacheService.class);
      context.stopService(serviceIntent);
    }
  }
Beispiel #3
0
 /**
  * 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);
   }
 }
Beispiel #4
0
 /** Creates a FakeBluetoothAdapter. */
 @CalledByNative("FakeBluetoothAdapter")
 public static FakeBluetoothAdapter create(long nativeBluetoothTestAndroid) {
   Log.v(TAG, "FakeBluetoothAdapter created.");
   return new FakeBluetoothAdapter(nativeBluetoothTestAndroid);
 }