public static void log(LoggingBehavior behavior, int priority, String tag, String string) { if (Settings.isLoggingBehaviorEnabled(behavior)) { string = replaceStrings(string); if (tag.startsWith(LOG_TAG_BASE) == false) { tag = LOG_TAG_BASE + tag; } Log.println(priority, tag, string); // Developer errors warrant special treatment by printing out a stack trace, to make both more noticeable, // and let the source of the problem be more easily pinpointed. if (behavior == LoggingBehavior.DEVELOPER_ERRORS) { (new Exception()).printStackTrace(); } } }
public void clearCache() { // get the current directory listing of files to delete final File[] filesToDelete = directory.listFiles(BufferFile.excludeBufferFiles()); lastClearCacheTime.set(System.currentTimeMillis()); if (filesToDelete != null) { Settings.getExecutor().execute(new Runnable() { @Override public void run() { for (File file : filesToDelete) { file.delete(); } } }); } }
private void postTrim() { synchronized (lock) { if (!isTrimPending) { isTrimPending = true; Settings.getExecutor().execute(new Runnable() { @Override public void run() { trim(); } }); } } }
public static Intent createProxyAuthIntent(Context context, String applicationId, List<String> permissions, String e2e, boolean isRerequest, SessionDefaultAudience defaultAudience) { for (NativeAppInfo appInfo : facebookAppInfoList) { Intent intent = new Intent() .setClassName(appInfo.getPackage(), FACEBOOK_PROXY_AUTH_ACTIVITY) .putExtra(FACEBOOK_PROXY_AUTH_APP_ID_KEY, applicationId); if (!Utility.isNullOrEmpty(permissions)) { intent.putExtra(FACEBOOK_PROXY_AUTH_PERMISSIONS_KEY, TextUtils.join(",", permissions)); } if (!Utility.isNullOrEmpty(e2e)) { intent.putExtra(FACEBOOK_PROXY_AUTH_E2E_KEY, e2e); } intent.putExtra(ServerProtocol.DIALOG_PARAM_RESPONSE_TYPE, ServerProtocol.DIALOG_RESPONSE_TYPE_TOKEN); intent.putExtra(ServerProtocol.DIALOG_PARAM_RETURN_SCOPES, ServerProtocol.DIALOG_RETURN_SCOPES_TRUE); intent.putExtra(ServerProtocol.DIALOG_PARAM_DEFAULT_AUDIENCE, defaultAudience.getNativeProtocolAudience()); if (!Settings.getPlatformCompatibilityEnabled()) { // Override the API Version for Auth intent.putExtra(ServerProtocol.DIALOG_PARAM_LEGACY_OVERRIDE, ServerProtocol.GRAPH_API_VERSION); // Only set the rerequest auth type for non legacy requests if (isRerequest) { intent.putExtra(ServerProtocol.DIALOG_PARAM_AUTH_TYPE, ServerProtocol.DIALOG_REREQUEST_AUTH_TYPE); } } intent = validateActivityIntent(context, intent, appInfo); if (intent != null) { return intent; } } return null; }
/** * Request to login async. * * @param strPath * - Path of login. * @param callback * - Call back function. */ public <T> void requestAsync( String strPath, final OnResult<T> callback) { Settings.addLoggingBehavior(LoggingBehavior.INCLUDE_ACCESS_TOKENS); Settings.addLoggingBehavior(LoggingBehavior.REQUESTS); Session session = Session.getActiveSession(); Request request = Request.newGraphPathRequest(session, strPath, new Request.Callback() { @Override public void onCompleted(Response response) { if (response.getError() != null) { Log.i("MainActivity", String.format( "Error making request: %s", response.getError())); } else { GraphUser user = response.getGraphObjectAs(GraphUser.class); callback.onResult((T) user); Log.i("MainActivity", String.format( "Name: %s", user.getName())); } } }); request.executeAsync(); }
public synchronized static void registerAccessToken(String accessToken) { if (Settings.isLoggingBehaviorEnabled(LoggingBehavior.INCLUDE_ACCESS_TOKENS) == false) { registerStringToReplace(accessToken, "ACCESS_TOKEN_REMOVED"); } }
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); } }
private boolean shouldLog() { return Settings.isLoggingBehaviorEnabled(behavior); }
WorkQueue(int maxConcurrent) { this(maxConcurrent, Settings.getExecutor()); }
public static final String getDialogAuthority() { return String.format(DIALOG_AUTHORITY_FORMAT, Settings.getFacebookDomain()); }
public static final String getGraphUrlBase() { return String.format(GRAPH_URL_FORMAT, Settings.getFacebookDomain()); }
public static final String getGraphVideoUrlBase() { return String.format(GRAPH_VIDEO_URL_FORMAT, Settings.getFacebookDomain()); }
public static final String getRestUrlBase() { return String.format(REST_URL_FORMAT, Settings.getFacebookDomain()); }
public static final String getAPIVersion() { if (Settings.getPlatformCompatibilityEnabled()) { return LEGACY_API_VERSION; } return GRAPH_API_VERSION; }