Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
14792 manas 1
/**
2
 * Copyright 2010-present Facebook.
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *    http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16
 
17
package com.facebook;
18
 
19
import android.content.ContentResolver;
20
import android.content.Context;
21
import android.content.SharedPreferences;
22
import android.content.pm.ApplicationInfo;
23
import android.content.pm.PackageInfo;
24
import android.content.pm.PackageManager;
25
import android.content.pm.Signature;
26
import android.database.Cursor;
27
import android.net.Uri;
28
import android.os.AsyncTask;
29
import android.os.Handler;
30
import android.os.Looper;
31
import android.util.Base64;
32
import android.util.Log;
33
import com.facebook.android.BuildConfig;
34
import com.facebook.internal.AttributionIdentifiers;
35
import com.facebook.internal.Utility;
36
import com.facebook.internal.Validate;
37
import com.facebook.model.GraphObject;
38
import org.json.JSONException;
39
import org.json.JSONObject;
40
 
41
import java.lang.reflect.Field;
42
import java.security.MessageDigest;
43
import java.security.NoSuchAlgorithmException;
44
import java.util.Arrays;
45
import java.util.Collections;
46
import java.util.HashSet;
47
import java.util.Set;
48
import java.util.concurrent.*;
49
import java.util.concurrent.atomic.AtomicInteger;
50
import java.util.concurrent.atomic.AtomicLong;
51
 
52
/**
53
 * Allows some customization of sdk behavior.
54
 */
55
public final class Settings {
56
    private static final String TAG = Settings.class.getCanonicalName();
57
    private static final HashSet<LoggingBehavior> loggingBehaviors =
58
            new HashSet<LoggingBehavior>(Arrays.asList(LoggingBehavior.DEVELOPER_ERRORS));
59
    private static volatile Executor executor;
60
    private static volatile boolean shouldAutoPublishInstall;
61
    private static volatile String appVersion;
62
    private static volatile String applicationId;
63
    private static volatile String appClientToken;
64
    private static volatile boolean defaultsLoaded = false;
65
    private static final String FACEBOOK_COM = "facebook.com";
66
    private static volatile String facebookDomain = FACEBOOK_COM;
67
    private static AtomicLong onProgressThreshold = new AtomicLong(65536);
68
    private static volatile boolean platformCompatibilityEnabled;
69
    private static volatile boolean isDebugEnabled = BuildConfig.DEBUG;
70
 
71
    private static final int DEFAULT_CORE_POOL_SIZE = 5;
72
    private static final int DEFAULT_MAXIMUM_POOL_SIZE = 128;
73
    private static final int DEFAULT_KEEP_ALIVE = 1;
74
    private static final Object LOCK = new Object();
75
 
76
    private static final Uri ATTRIBUTION_ID_CONTENT_URI =
77
            Uri.parse("content://com.facebook.katana.provider.AttributionIdProvider");
78
    private static final String ATTRIBUTION_ID_COLUMN_NAME = "aid";
79
 
80
    private static final String ATTRIBUTION_PREFERENCES = "com.facebook.sdk.attributionTracking";
81
    private static final String PUBLISH_ACTIVITY_PATH = "%s/activities";
82
    private static final String MOBILE_INSTALL_EVENT = "MOBILE_APP_INSTALL";
83
    private static final String ANALYTICS_EVENT = "event";
84
    private static final String AUTO_PUBLISH = "auto_publish";
85
 
86
    private static final String APP_EVENT_PREFERENCES = "com.facebook.sdk.appEventPreferences";
87
 
88
    private static final BlockingQueue<Runnable> DEFAULT_WORK_QUEUE = new LinkedBlockingQueue<Runnable>(10);
89
 
90
    private static final ThreadFactory DEFAULT_THREAD_FACTORY = new ThreadFactory() {
91
        private final AtomicInteger counter = new AtomicInteger(0);
92
 
93
        public Thread newThread(Runnable runnable) {
94
            return new Thread(runnable, "FacebookSdk #" + counter.incrementAndGet());
95
        }
96
    };
97
 
98
    /**
99
     * loadDefaultsFromMetadata will attempt to load certain settings (e.g., application ID, client token) from
100
     * metadata in the app's AndroidManifest.xml. The application ID will be read from this key.
101
     */
102
    public static final String APPLICATION_ID_PROPERTY = "com.facebook.sdk.ApplicationId";
103
    /**
104
     * loadDefaultsFromMetadata will attempt to load certain settings (e.g., application ID, client token) from
105
     * metadata in the app's AndroidManifest.xml. The client token will be read from this key.
106
     */
107
    public static final String CLIENT_TOKEN_PROPERTY = "com.facebook.sdk.ClientToken";
108
 
109
    private static Boolean sdkInitialized = false;
110
 
111
    /**
112
     * Initialize SDK
113
     * This function will be called once in the application, it is tried to be called as early as possible;
114
     * This is the place to register broadcast listeners.
115
     */
116
    public static synchronized void sdkInitialize(Context context) {
117
        if (sdkInitialized == true) {
118
          return;
119
        }
120
 
121
        // Make sure we've loaded default settings if we haven't already.
122
        Settings.loadDefaultsFromMetadataIfNeeded(context);
123
        // Load app settings from network so that dialog configs are available
124
        Utility.loadAppSettingsAsync(context, Settings.getApplicationId());
125
 
126
        BoltsMeasurementEventListener.getInstance(context.getApplicationContext());
127
        sdkInitialized = true;
128
    }
129
 
130
    /**
131
     * Certain logging behaviors are available for debugging beyond those that should be
132
     * enabled in production.
133
     *
134
     * Returns the types of extended logging that are currently enabled.
135
     *
136
     * @return a set containing enabled logging behaviors
137
     */
138
    public static final Set<LoggingBehavior> getLoggingBehaviors() {
139
        synchronized (loggingBehaviors) {
140
            return Collections.unmodifiableSet(new HashSet<LoggingBehavior>(loggingBehaviors));
141
        }
142
    }
143
 
144
    /**
145
     * Certain logging behaviors are available for debugging beyond those that should be
146
     * enabled in production.
147
     *
148
     * Enables a particular extended logging in the sdk.
149
     *
150
     * @param behavior
151
     *          The LoggingBehavior to enable
152
     */
153
    public static final void addLoggingBehavior(LoggingBehavior behavior) {
154
        synchronized (loggingBehaviors) {
155
            loggingBehaviors.add(behavior);
156
        }
157
    }
158
 
159
    /**
160
     * Certain logging behaviors are available for debugging beyond those that should be
161
     * enabled in production.
162
     *
163
     * Disables a particular extended logging behavior in the sdk.
164
     *
165
     * @param behavior
166
     *          The LoggingBehavior to disable
167
     */
168
    public static final void removeLoggingBehavior(LoggingBehavior behavior) {
169
        synchronized (loggingBehaviors) {
170
            loggingBehaviors.remove(behavior);
171
        }
172
    }
173
 
174
    /**
175
     * Certain logging behaviors are available for debugging beyond those that should be
176
     * enabled in production.
177
     *
178
     * Disables all extended logging behaviors.
179
     */
180
    public static final void clearLoggingBehaviors() {
181
        synchronized (loggingBehaviors) {
182
            loggingBehaviors.clear();
183
        }
184
    }
185
 
186
    /**
187
     * Certain logging behaviors are available for debugging beyond those that should be
188
     * enabled in production.
189
     *
190
     * Checks if a particular extended logging behavior is enabled.
191
     *
192
     * @param behavior
193
     *          The LoggingBehavior to check
194
     * @return whether behavior is enabled
195
     */
196
    public static final boolean isLoggingBehaviorEnabled(LoggingBehavior behavior) {
197
        synchronized (loggingBehaviors) {
198
            return Settings.isDebugEnabled() && loggingBehaviors.contains(behavior);
199
        }
200
    }
201
 
202
    /**
203
     * This method is deprecated.  Use {@link Settings#isDebugEnabled()} instead.
204
     */
205
    @Deprecated
206
    public static final boolean isLoggingEnabled() {
207
        return isDebugEnabled();
208
    }
209
 
210
    /**
211
     * This method is deprecated.  Use {@link Settings#setIsDebugEnabled(boolean)} instead.
212
     */
213
    @Deprecated
214
    public static final void setIsLoggingEnabled(boolean enabled) {
215
        setIsDebugEnabled(enabled);
216
    }
217
 
218
    /**
219
     * Indicates if we are in debug mode.
220
     */
221
    public static final boolean isDebugEnabled() {
222
        return isDebugEnabled;
223
    }
224
 
225
    /**
226
     * Used to enable or disable logging, and other debug features. Defaults to BuildConfig.DEBUG.
227
     * @param enabled Debug features (like logging) are enabled if true, disabled if false.
228
     */
229
    public static final void setIsDebugEnabled(boolean enabled) {
230
        isDebugEnabled = enabled;
231
    }
232
 
233
    /**
234
     * Returns the Executor used by the SDK for non-AsyncTask background work.
235
     *
236
     * By default this uses AsyncTask Executor via reflection if the API level is high enough.
237
     * Otherwise this creates a new Executor with defaults similar to those used in AsyncTask.
238
     *
239
     * @return an Executor used by the SDK.  This will never be null.
240
     */
241
    public static Executor getExecutor() {
242
        synchronized (LOCK) {
243
            if (Settings.executor == null) {
244
                Executor executor = getAsyncTaskExecutor();
245
                if (executor == null) {
246
                    executor = new ThreadPoolExecutor(DEFAULT_CORE_POOL_SIZE, DEFAULT_MAXIMUM_POOL_SIZE,
247
                            DEFAULT_KEEP_ALIVE, TimeUnit.SECONDS, DEFAULT_WORK_QUEUE, DEFAULT_THREAD_FACTORY);
248
                }
249
                Settings.executor = executor;
250
            }
251
        }
252
        return Settings.executor;
253
    }
254
 
255
    /**
256
     * Sets the Executor used by the SDK for non-AsyncTask background work.
257
     *
258
     * @param executor
259
     *          the Executor to use; must not be null.
260
     */
261
    public static void setExecutor(Executor executor) {
262
        Validate.notNull(executor, "executor");
263
        synchronized (LOCK) {
264
            Settings.executor = executor;
265
        }
266
    }
267
 
268
    /**
269
     * Gets the base Facebook domain to use when making Web requests; in production code this will always be
270
     * "facebook.com".
271
     *
272
     * @return the Facebook domain
273
     */
274
    public static String getFacebookDomain() {
275
        return facebookDomain;
276
    }
277
 
278
    /**
279
     * Sets the base Facebook domain to use when making Web requests. This defaults to "facebook.com", but may
280
     * be overridden to, e.g., "beta.facebook.com" to direct requests at a different domain. This method should
281
     * never be called from production code.
282
     *
283
     * @param facebookDomain the base domain to use instead of "facebook.com"
284
     */
285
    public static void setFacebookDomain(String facebookDomain) {
286
        if (!BuildConfig.DEBUG) {
287
            Log.w(TAG, "WARNING: Calling setFacebookDomain from non-DEBUG code.");
288
        }
289
 
290
        Settings.facebookDomain = facebookDomain;
291
    }
292
 
293
    private static Executor getAsyncTaskExecutor() {
294
        Field executorField = null;
295
        try {
296
            executorField = AsyncTask.class.getField("THREAD_POOL_EXECUTOR");
297
        } catch (NoSuchFieldException e) {
298
            return null;
299
        }
300
 
301
        Object executorObject = null;
302
        try {
303
            executorObject = executorField.get(null);
304
        } catch (IllegalAccessException e) {
305
            return null;
306
        }
307
 
308
        if (executorObject == null) {
309
            return null;
310
        }
311
 
312
        if (!(executorObject instanceof Executor)) {
313
            return null;
314
        }
315
 
316
        return (Executor) executorObject;
317
    }
318
 
319
    static void publishInstallAsync(final Context context, final String applicationId,
320
        final Request.Callback callback) {
321
        // grab the application context ahead of time, since we will return to the caller immediately.
322
        final Context applicationContext = context.getApplicationContext();
323
        Settings.getExecutor().execute(new Runnable() {
324
            @Override
325
            public void run() {
326
                final Response response = Settings.publishInstallAndWaitForResponse(applicationContext, applicationId, false);
327
                if (callback != null) {
328
                    // invoke the callback on the main thread.
329
                    Handler handler = new Handler(Looper.getMainLooper());
330
                    handler.post(new Runnable() {
331
                        @Override
332
                        public void run() {
333
                            callback.onCompleted(response);
334
                        }
335
                    });
336
                }
337
            }
338
        });
339
    }
340
 
341
    /**
342
     * Sets whether opening a Session should automatically publish install attribution to the Facebook graph.
343
     *
344
     * @param shouldAutoPublishInstall true to automatically publish, false to not
345
     *
346
     * This method is deprecated.  See {@link AppEventsLogger#activateApp(Context, String)} for more info.
347
     */
348
    @Deprecated
349
    public static void setShouldAutoPublishInstall(boolean shouldAutoPublishInstall) {
350
        Settings.shouldAutoPublishInstall = shouldAutoPublishInstall;
351
    }
352
 
353
    /**
354
     * Gets whether opening a Session should automatically publish install attribution to the Facebook graph.
355
     *
356
     * @return true to automatically publish, false to not
357
     *
358
     * This method is deprecated.  See {@link AppEventsLogger#activateApp(Context, String)} for more info.
359
     */
360
    @Deprecated
361
    public static boolean getShouldAutoPublishInstall() {
362
        return shouldAutoPublishInstall;
363
    }
364
 
365
    static Response publishInstallAndWaitForResponse(
366
            final Context context,
367
            final String applicationId,
368
            final boolean isAutoPublish) {
369
        try {
370
            if (context == null || applicationId == null) {
371
                throw new IllegalArgumentException("Both context and applicationId must be non-null");
372
            }
373
            AttributionIdentifiers identifiers = AttributionIdentifiers.getAttributionIdentifiers(context);
374
            SharedPreferences preferences = context.getSharedPreferences(ATTRIBUTION_PREFERENCES, Context.MODE_PRIVATE);
375
            String pingKey = applicationId+"ping";
376
            String jsonKey = applicationId+"json";
377
            long lastPing = preferences.getLong(pingKey, 0);
378
            String lastResponseJSON = preferences.getString(jsonKey, null);
379
 
380
            // prevent auto publish from occurring if we have an explicit call.
381
            if (!isAutoPublish) {
382
                setShouldAutoPublishInstall(false);
383
            }
384
 
385
            GraphObject publishParams = GraphObject.Factory.create();
386
            publishParams.setProperty(ANALYTICS_EVENT, MOBILE_INSTALL_EVENT);
387
 
388
            Utility.setAppEventAttributionParameters(publishParams,
389
                    identifiers,
390
                    Utility.getHashedDeviceAndAppID(context, applicationId),
391
                    getLimitEventAndDataUsage(context));
392
            publishParams.setProperty(AUTO_PUBLISH, isAutoPublish);
393
            publishParams.setProperty("application_package_name", context.getPackageName());
394
 
395
            String publishUrl = String.format(PUBLISH_ACTIVITY_PATH, applicationId);
396
            Request publishRequest = Request.newPostRequest(null, publishUrl, publishParams, null);
397
 
398
            if (lastPing != 0) {
399
                GraphObject graphObject = null;
400
                try {
401
                    if (lastResponseJSON != null) {
402
                        graphObject = GraphObject.Factory.create(new JSONObject(lastResponseJSON));
403
                    }
404
                }
405
                catch (JSONException je) {
406
                    // return the default graph object if there is any problem reading the data.
407
                }
408
                if (graphObject == null) {
409
                    return Response.createResponsesFromString("true", null, new RequestBatch(publishRequest), true).get(0);
410
                } else {
411
                    return new Response(null, null, null, graphObject, true);
412
                }
413
            } else if (identifiers == null ||
414
                       (identifiers.getAndroidAdvertiserId() == null && identifiers.getAttributionId() == null)) {
415
                throw new FacebookException("No attribution id available to send to server.");
416
            } else {
417
                if (!Utility.queryAppSettings(applicationId, false).supportsAttribution()) {
418
                    throw new FacebookException("Install attribution has been disabled on the server.");
419
                }
420
 
421
                Response publishResponse = publishRequest.executeAndWait();
422
 
423
                // denote success since no error threw from the post.
424
                SharedPreferences.Editor editor = preferences.edit();
425
                lastPing = System.currentTimeMillis();
426
                editor.putLong(pingKey, lastPing);
427
 
428
                // if we got an object response back, cache the string of the JSON.
429
                if (publishResponse.getGraphObject() != null &&
430
                    publishResponse.getGraphObject().getInnerJSONObject() != null) {
431
                    editor.putString(jsonKey, publishResponse.getGraphObject().getInnerJSONObject().toString());
432
                }
433
                editor.apply();
434
 
435
                return publishResponse;
436
            }
437
        } catch (Exception e) {
438
            // if there was an error, fall through to the failure case.
439
            Utility.logd("Facebook-publish", e);
440
            return new Response(null, null, new FacebookRequestError(null, e));
441
        }
442
    }
443
 
444
    /**
445
     * Acquire the current attribution id from the facebook app.
446
     * @return returns null if the facebook app is not present on the phone.
447
     */
448
    public static String getAttributionId(ContentResolver contentResolver) {
449
        Cursor c = null;
450
        try {
451
            String [] projection = {ATTRIBUTION_ID_COLUMN_NAME};
452
            c = contentResolver.query(ATTRIBUTION_ID_CONTENT_URI, projection, null, null, null);
453
            if (c == null || !c.moveToFirst()) {
454
                return null;
455
            }
456
            String attributionId = c.getString(c.getColumnIndex(ATTRIBUTION_ID_COLUMN_NAME));
457
            return attributionId;
458
        } catch (Exception e) {
459
            Log.d(TAG, "Caught unexpected exception in getAttributionId(): " + e.toString());
460
            return null;
461
        } finally {
462
            if (c != null) {
463
                c.close();
464
            }
465
        }
466
    }
467
 
468
    /**
469
     * Gets the application version to the provided string.
470
     * @return application version set via setAppVersion.
471
     */
472
    public static String getAppVersion() {
473
        return appVersion;
474
    }
475
 
476
    /**
477
     * Sets the application version to the provided string.  AppEventsLogger.logEvent calls logs its event with the
478
     * current app version, and App Insights allows breakdown of events by app version.
479
     *
480
     * @param appVersion  The version identifier of the Android app that events are being logged through.
481
     *                    Enables analysis and breakdown of logged events by app version.
482
     */
483
    public static void setAppVersion(String appVersion) {
484
        Settings.appVersion = appVersion;
485
    }
486
 
487
    /**
488
     * Gets the current version of the Facebook SDK for Android as a string.
489
     *
490
     * @return the current version of the SDK
491
     */
492
    public static String getSdkVersion() {
493
        return FacebookSdkVersion.BUILD;
494
    }
495
 
496
    /**
497
     * Gets whether data such as that generated through AppEventsLogger and sent to Facebook should be restricted from
498
     * being used for purposes other than analytics and conversions, such as for targeting ads to this user.  Defaults
499
     * to false.  This value is stored on the device and persists across app launches.
500
     *
501
     * @param context   Used to read the value.
502
     */
503
    public static boolean getLimitEventAndDataUsage(Context context) {
504
        SharedPreferences preferences = context.getSharedPreferences(APP_EVENT_PREFERENCES, Context.MODE_PRIVATE);
505
        return preferences.getBoolean("limitEventUsage", false);
506
    }
507
 
508
    /**
509
     * Sets whether data such as that generated through AppEventsLogger and sent to Facebook should be restricted from
510
     * being used for purposes other than analytics and conversions, such as for targeting ads to this user.  Defaults
511
     * to false.  This value is stored on the device and persists across app launches.  Changes to this setting will
512
     * apply to app events currently queued to be flushed.
513
     *
514
     * @param context   Used to persist this value across app runs.
515
     */
516
    public static void setLimitEventAndDataUsage(Context context, boolean limitEventUsage) {
517
        context.getSharedPreferences(APP_EVENT_PREFERENCES, Context.MODE_PRIVATE)
518
            .edit()
519
            .putBoolean("limitEventUsage", limitEventUsage)
520
            .apply();
521
    }
522
 
523
    /**
524
     * Gets the threshold used to report progress on requests.
525
     */
526
    public static long getOnProgressThreshold() {
527
        return onProgressThreshold.get();
528
    }
529
 
530
    /**
531
     * Sets the threshold used to report progress on requests. Note that the value will be read when the
532
     * request is started and can not be changed during a request (or batch) execution.
533
     *
534
     * @param threshold The number of bytes progressed to force a callback.
535
     */
536
    public static void setOnProgressThreshold(long threshold) {
537
        onProgressThreshold.set(threshold);
538
    }
539
 
540
    /**
541
     * Gets whether the SDK is running in Platform Compatibility mode (i.e. making calls to v1.0 endpoints by default)
542
     * The default is false.
543
     *
544
     * @return the value
545
     */
546
    public static boolean getPlatformCompatibilityEnabled() {
547
        return platformCompatibilityEnabled;
548
    }
549
 
550
    /**
551
     * Sets whether the SDK is running in Platform Compatibility mode (i.e. making calls to v1.0 endpoints by default)
552
     * The default is false.  This is provided for apps that have strong reason not to take advantage of new
553
     * capabilities in version 2.0+ of the API.
554
     *
555
     * @param platformCompatibilityEnabled whether to set Legacy Graph API mode
556
     */
557
    public static void setPlatformCompatibilityEnabled(boolean platformCompatibilityEnabled) {
558
        Settings.platformCompatibilityEnabled = platformCompatibilityEnabled;
559
    }
560
 
561
    /**
562
     * Loads default values for certain settings from an application's AndroidManifest.xml metadata, if possible.
563
     * If values have been explicitly set for a particular setting, they will not be overwritten. The following
564
     * settings are currently loaded from metadata: APPLICATION_ID_PROPERTY, CLIENT_TOKEN_PROPERTY
565
     * @param context the Context to use for loading metadata
566
     */
567
    public static void loadDefaultsFromMetadata(Context context) {
568
        defaultsLoaded = true;
569
 
570
        if (context == null) {
571
            return;
572
        }
573
 
574
        ApplicationInfo ai = null;
575
        try {
576
            ai = context.getPackageManager().getApplicationInfo(
577
                    context.getPackageName(), PackageManager.GET_META_DATA);
578
        } catch (PackageManager.NameNotFoundException e) {
579
            return;
580
        }
581
 
582
        if (ai == null || ai.metaData == null) {
583
            return;
584
        }
585
 
586
        if (applicationId == null) {
587
            applicationId = ai.metaData.getString(APPLICATION_ID_PROPERTY);
588
        }
589
        if (appClientToken == null) {
590
            appClientToken = ai.metaData.getString(CLIENT_TOKEN_PROPERTY);
591
        }
592
    }
593
 
594
    static void loadDefaultsFromMetadataIfNeeded(Context context) {
595
        if (!defaultsLoaded) {
596
            loadDefaultsFromMetadata(context);
597
        }
598
    }
599
 
600
    public static String getApplicationSignature(Context context) {
601
        if (context == null) {
602
            return null;
603
        }
604
        PackageManager packageManager = context.getPackageManager();
605
        if (packageManager == null) {
606
            return null;
607
        }
608
 
609
        String packageName = context.getPackageName();
610
        PackageInfo pInfo;
611
        try {
612
            pInfo = packageManager.getPackageInfo(packageName, PackageManager.GET_SIGNATURES);
613
        } catch (PackageManager.NameNotFoundException e) {
614
            return null;
615
        }
616
 
617
        Signature[] signatures = pInfo.signatures;
618
        if (signatures == null || signatures.length == 0) {
619
            return null;
620
        }
621
 
622
        MessageDigest md;
623
        try {
624
            md = MessageDigest.getInstance("SHA-1");
625
        } catch (NoSuchAlgorithmException e) {
626
            return null;
627
        }
628
 
629
        md.update(pInfo.signatures[0].toByteArray());
630
        return Base64.encodeToString(md.digest(),  Base64.URL_SAFE | Base64.NO_PADDING);
631
    }
632
 
633
    /**
634
     * Gets the Facebook application ID for the current app. This will be null unless explicitly set or unless
635
     * loadDefaultsFromMetadata has been called.
636
     * @return the application ID
637
     */
638
    public static String getApplicationId() {
639
        return applicationId;
640
    }
641
 
642
    /**
643
     * Sets the Facebook application ID for the current app.
644
     * @param applicationId the application ID
645
     */
646
    public static void setApplicationId(String applicationId) {
647
        Settings.applicationId = applicationId;
648
    }
649
 
650
    /**
651
     * Gets the client token for the current app. This will be null unless explicitly set or unless
652
     * loadDefaultsFromMetadata has been called.
653
     * @return the client token
654
     */
655
    public static String getClientToken() {
656
        return appClientToken;
657
    }
658
 
659
    /**
660
     * Sets the Facebook client token for the current app.
661
     * @param clientToken the client token
662
     */
663
    public static void setClientToken(String clientToken) {
664
        appClientToken = clientToken;
665
    }
666
}