Skip to content

Commit 2eb6841

Browse files
committed
ensure Prefs has the ApplicationContext set in all cases
- addresses crash seen in some backup systems that don't init the Application
1 parent bf212e5 commit 2eb6841

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

orbotservice/src/main/java/org/torproject/android/service/OrbotService.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,8 @@ public void onCreate() {
674674
}
675675

676676
private void configLanguage() {
677-
Configuration config = getBaseContext().getResources().getConfiguration();
677+
Configuration config = getApplicationContext().getResources().getConfiguration();
678+
Prefs.setContext(getApplicationContext());
678679
Locale locale = new Locale(Prefs.getDefaultLocale());
679680
Locale.setDefault(locale);
680681
config.locale = locale;

orbotservice/src/main/java/org/torproject/android/service/StartTorReceiver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public void onReceive(Context context, Intent intent) {
1919

2020
try {
2121
/* sanitize the Intent before forwarding it to OrbotService */
22-
Prefs.setContext(context);
22+
Prefs.setContext(context.getApplicationContext());
2323
String action = intent.getAction();
2424
if (TextUtils.equals(action, ACTION_START)) {
2525
String packageName = intent.getStringExtra(EXTRA_PACKAGE_NAME);

orbotservice/src/main/java/org/torproject/android/service/util/Prefs.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,4 +262,5 @@ public static void setSecureWindow (boolean isFlagSecure) {
262262
public static boolean isSecureWindow () {
263263
return prefs.getBoolean(PREF_SECURE_WINDOW_FLAG, true);
264264
}
265+
265266
}

0 commit comments

Comments
 (0)