private AccessToken getLegacyAccessToken() { AccessToken accessToken = null; Bundle bundle = getTokenCachingStrategy().load(); if (bundle != null && LegacyTokenHelper.hasTokenInformation(bundle)) { accessToken = AccessToken.createFromLegacyCache(bundle); } return accessToken; }
public void run() { for (Pair<Callback, GraphResponse> pair : callbacks) { pair.first.onCompleted(pair.second); } List<GraphRequestBatch.Callback> batchCallbacks = requests.getCallbacks(); for (GraphRequestBatch.Callback batchCallback : batchCallbacks) { batchCallback.onBatchCompleted(requests); } } };
private void addProgress(long size) { if (currentRequestProgress != null) { currentRequestProgress.addProgress(size); } batchProgress += size; if (batchProgress >= lastReportedProgress + threshold || batchProgress >= maxProgress) { reportBatchProgress(); } }
@Override public void onCompleted(GraphResponse response) { if (response.getError() != null) { blocker.setException(response.getError().getException()); } blocker.signal(); } });
@Override public void setUp() { super.setUp(); FacebookSdk.setApplicationId("123456789"); FacebookSdk.setAutoLogAppEventsEnabled(false); FacebookSdk.sdkInitialize(RuntimeEnvironment.application); }
/** * Sets the current {@link AccessToken} with an expiration time of now. No action is taken if * there is no current AccessToken. */ static void expireCurrentAccessToken() { final AccessToken accessToken = AccessTokenManager.getInstance().getCurrentAccessToken(); if (accessToken != null) { setCurrentAccessToken(AccessToken.createExpired(accessToken)); } }
@LargeTest public void testExecuteSingleGetFailureCase() { final AccessToken accessToken = getAccessTokenForSharedUser(); GraphRequest request = new GraphRequest(accessToken, "-1", null, null, new ExpectFailureCallback()); TestGraphRequestAsyncTask task = new TestGraphRequestAsyncTask(request); task.executeOnBlockerThread(); // Wait on 2 signals: request and task will both signal. waitAndAssertSuccess(2); }
@Override public void onCompleted(GraphResponse response) { if (callback != null) { callback.onCompleted(response.getJSONObject(), response); } } };
@Override public void setUp() throws Exception { super.setUp(); AccessToken.setCurrentAccessToken(getAccessTokenForSharedUser()); }
/** * Returns whether the current {@link AccessToken} is active or not. * * @return true if the current AccessToken exists and has not expired; false, otherwise. */ public static boolean isCurrentAccessTokenActive() { final AccessToken accessToken = AccessTokenManager.getInstance().getCurrentAccessToken(); return accessToken != null && !accessToken.isExpired(); }
@Override public void tearDown() throws Exception { AccessToken.setCurrentAccessToken(null); super.tearDown(); }
public static void sdkInitialized() { if (!FacebookSdk.isInitialized()) { throw new FacebookSdkNotInitializedException( "The SDK has not been initialized, make sure to call " + "FacebookSdk.sdkInitialize() first."); } }
boolean loadCurrentAccessToken() { AccessToken accessToken = accessTokenCache.load(); if (accessToken != null) { setCurrentAccessToken(accessToken, false); return true; } return false; }
boolean loadCurrentProfile() { Profile profile = profileCache.load(); if (profile != null) { setCurrentProfile(profile, false); return true; } return false; }
public static boolean getAdvertiserIDCollectionEnabled() { initializeIfNotInitialized(); return advertiserIDCollectionEnabled.getValue(); }
protected void setUp() throws Exception { super.setUp(); // Tests that need this set should explicitly set it. GraphRequest.setDefaultBatchApplicationId(null); }
@Override protected void onCurrentProfileChanged(Profile oldProfile, Profile currentProfile) { getTestBlocker().signal(); } };
protected TestUserManager getTestUserManager() { if (testUserManager == null) { synchronized (FacebookActivityTestCase.class) { if (testUserManager == null) { readApplicationIdAndSecret(); testUserManager = new TestUserManager(applicationSecret, applicationId); } } } return testUserManager; }
protected AccessToken getAccessTokenForSharedUserWithPermissions(String sessionUniqueUserTag, List<String> permissions) { return getTestUserManager().getAccessTokenForSharedUser(permissions, sessionUniqueUserTag); }
public static boolean getCodelessSetupEnabled() { initializeIfNotInitialized(); return codelessSetupEnabled.getValue(); }