blob: bde5114b6b4187099afea494e586f8e93be1baaa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
package se.leap.bitmaskclient;
import android.content.Context;
import android.content.SharedPreferences;
import androidx.multidex.MultiDexApplication;
import androidx.appcompat.app.AppCompatDelegate;
import com.squareup.leakcanary.LeakCanary;
import com.squareup.leakcanary.RefWatcher;
import se.leap.bitmaskclient.tethering.TetheringStateManager;
import static se.leap.bitmaskclient.Constants.SHARED_PREFERENCES;
import static se.leap.bitmaskclient.utils.PreferenceHelper.getSavedProviderFromSharedPreferences;
/**
* Created by cyberta on 24.10.17.
*/
public class BitmaskApp extends MultiDexApplication {
private final static String TAG = BitmaskApp.class.getSimpleName();
private RefWatcher refWatcher;
private ProviderObservable providerObservable;
@Override
public void onCreate() {
super.onCreate();
if (LeakCanary.isInAnalyzerProcess(this)) {
// This process is dedicated to LeakCanary for heap analysis.
// You should not init your app in this process.
return;
}
refWatcher = LeakCanary.install(this);
// Normal app init code...*/
PRNGFixes.apply();
SharedPreferences preferences = getSharedPreferences(SHARED_PREFERENCES, MODE_PRIVATE);
providerObservable = ProviderObservable.getInstance();
providerObservable.updateProvider(getSavedProviderFromSharedPreferences(preferences));
EipSetupObserver.init(this, preferences);
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
TetheringStateManager.getInstance().init(this);
}
/**
* Use this method to get a RefWatcher object that checks for memory leaks in the given context.
* Call refWatcher.watch(this) to check if all references get garbage collected.
* @param context
* @return the RefWatcher object
*/
public static RefWatcher getRefWatcher(Context context) {
BitmaskApp application = (BitmaskApp) context.getApplicationContext();
return application.refWatcher;
}
}
|