/**
   * Persists all supported data types present in the passed in Bundle, to the cache
   *
   * @param bundle The Bundle containing information to be cached
   */
  public void save(Bundle bundle) {
    Validate.notNull(bundle, "bundle");

    SharedPreferences.Editor editor = cache.edit();

    for (String key : bundle.keySet()) {
      try {
        serializeKey(key, bundle, editor);
      } catch (JSONException e) {
        // Error in the bundle. Don't store a partial cache.
        Logger.log(
            LoggingBehavior.CACHE,
            Log.WARN,
            TAG,
            "Error processing value for key: '" + key + "' -- " + e);

        // Bypass the commit and just return. This cancels the entire edit transaction
        return;
      }
    }

    boolean successfulCommit = editor.commit();
    if (!successfulCommit) {
      Logger.log(
          LoggingBehavior.CACHE,
          Log.WARN,
          TAG,
          "SharedPreferences.Editor.commit() was not successful");
    }
  }
 void onResume(AppEventsLogger appeventslogger, long l, String s)
 {
     long l2;
     if (isColdLaunch() || l - lastActivateEventLoggedTime > 0x493e0L)
     {
         Bundle bundle = new Bundle();
         bundle.putString("fb_mobile_launch_source", s);
         appeventslogger.logEvent("fb_mobile_activate_app", bundle);
         lastActivateEventLoggedTime = l;
     }
     if (isAppActive)
     {
         Logger.log(LoggingBehavior.APP_EVENTS, TAG, "Resume for active app");
         return;
     }
     long l1;
     if (wasSuspendedEver())
     {
         l1 = l - lastSuspendTime;
     } else
     {
         l1 = 0L;
     }
     l2 = l1;
     if (l1 < 0L)
     {
         Logger.log(LoggingBehavior.APP_EVENTS, TAG, "Clock skew detected");
         l2 = 0L;
     }
     if (l2 <= 60000L) goto _L2; else goto _L1
Пример #3
0
  private void processResponse(ImageResponse response) {
    // First check if the response is for the right request. We may have:
    // 1. Sent a new request, thus super-ceding this one.
    // 2. Detached this view, in which case the response should be discarded.
    if (response.getRequest() == lastRequest) {
      lastRequest = null;
      Bitmap responseImage = response.getBitmap();
      Exception error = response.getError();
      if (error != null) {
        OnErrorListener listener = onErrorListener;
        if (listener != null) {
          listener.onError(
              new FacebookException(
                  "Error in downloading profile picture for profileId: " + getProfileId(), error));
        } else {
          Logger.log(LoggingBehavior.REQUESTS, Log.ERROR, TAG, error.toString());
        }
      } else if (responseImage != null) {
        setImageBitmap(responseImage);

        if (response.isCachedRedirect()) {
          sendImageRequest(false);
        }
      }
    }
  }
Пример #4
0
  private void sendImageRequest(boolean allowCachedResponse) {
    try {
      ImageRequest.Builder requestBuilder =
          new ImageRequest.Builder(
              getContext(), ImageRequest.getProfilePictureUri(profileId, queryWidth, queryHeight));

      ImageRequest request =
          requestBuilder
              .setAllowCachedRedirects(allowCachedResponse)
              .setCallerTag(this)
              .setCallback(
                  new ImageRequest.Callback() {
                    @Override
                    public void onCompleted(ImageResponse response) {
                      processResponse(response);
                    }
                  })
              .build();

      // Make sure to cancel the old request before sending the new one to prevent
      // accidental cancellation of the new request. This could happen if the URL and
      // caller tag stayed the same.
      if (lastRequest != null) {
        ImageDownloader.cancelRequest(lastRequest);
      }
      lastRequest = request;

      ImageDownloader.downloadAsync(request);
    } catch (Exception e) {
      Logger.log(LoggingBehavior.REQUESTS, Log.ERROR, TAG, e.toString());
    }
  }
 protected void processError(FacebookRequestError facebookrequesterror)
 {
     if (facebookrequesterror.getErrorCode() == 3501)
     {
         error = null;
         return;
     } else
     {
         Logger.log(LoggingBehavior.REQUESTS, LikeActionController.access$100(), "Error liking object '%s' with type '%s' : %s", new Object[] {
             objectId, objectType, facebookrequesterror
         });
         LikeActionController.access$2400(LikeActionController.this, "publish_like", facebookrequesterror);
         return;
     }
 }
  /**
   * Returns a Bundle that contains the information stored in this cache
   *
   * @return A Bundle with the information contained in this cache
   */
  public Bundle load() {
    Bundle settings = new Bundle();

    Map<String, ?> allCachedEntries = cache.getAll();

    for (String key : allCachedEntries.keySet()) {
      try {
        deserializeKey(key, settings);
      } catch (JSONException e) {
        // Error in the cache. So consider it corrupted and return null
        Logger.log(
            LoggingBehavior.CACHE,
            Log.WARN,
            TAG,
            "Error reading cached value for key: '" + key + "' -- " + e);
        return null;
      }
    }

    return settings;
  }
Пример #7
0
  public static Bundle getQueryParamsForPlatformActivityIntentWebFallback(
      Context context, String callId, int version, String applicationName, Bundle methodArgs) {

    String keyHash = Settings.getApplicationSignature(context);
    if (Utility.isNullOrEmpty(keyHash)) {
      return null;
    }

    Bundle webParams = new Bundle();

    webParams.putString(FALLBACK_DIALOG_PARAM_KEY_HASH, keyHash);
    webParams.putString(FALLBACK_DIALOG_PARAM_APP_ID, Settings.getApplicationId());
    webParams.putInt(FALLBACK_DIALOG_PARAM_VERSION, version);
    webParams.putString(DIALOG_PARAM_DISPLAY, FALLBACK_DIALOG_DISPLAY_VALUE_TOUCH);

    Bundle bridgeArguments = new Bundle();
    bridgeArguments.putString(NativeProtocol.BRIDGE_ARG_ACTION_ID_STRING, callId);
    bridgeArguments.putString(NativeProtocol.BRIDGE_ARG_APP_NAME_STRING, applicationName);

    methodArgs = (methodArgs == null) ? new Bundle() : methodArgs;

    try {
      JSONObject bridgeArgsJSON = BundleJSONConverter.convertToJSON(bridgeArguments);
      JSONObject methodArgsJSON = BundleJSONConverter.convertToJSON(methodArgs);

      if (bridgeArgsJSON == null || methodArgsJSON == null) {
        return null;
      }

      webParams.putString(FALLBACK_DIALOG_PARAM_BRIDGE_ARGS, bridgeArgsJSON.toString());
      webParams.putString(FALLBACK_DIALOG_PARAM_METHOD_ARGS, methodArgsJSON.toString());
    } catch (JSONException je) {
      webParams = null;
      Logger.log(LoggingBehavior.DEVELOPER_ERRORS, Log.ERROR, TAG, "Error creating Url -- " + je);
    }

    return webParams;
  }
Пример #8
0
 /**
  * Invoke this method, rather than throwing an Exception, for situations where user/server input
  * might reasonably cause this to occur, and thus don't want an exception thrown at production
  * time, but do want logging notification.
  */
 private static void notifyDeveloperError(String message) {
   Logger.log(LoggingBehavior.DEVELOPER_ERRORS, "Insights", message);
 }
 public static void log(LoggingBehavior behavior, String tag, String format, Object... args) {
   if (Settings.isLoggingBehaviorEnabled(behavior)) {
     String string = String.format(format, args);
     log(behavior, Log.DEBUG, tag, string);
   }
 }
 public static void log(LoggingBehavior behavior, String tag, String string) {
   log(behavior, Log.DEBUG, tag, string);
 }
 // Immediately logs a string, ignoring any accumulated contents, which are left unchanged.
 public void logString(String string) {
   log(behavior, priority, tag, string);
 }