mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2025-02-03 21:47:32 +01:00
Avoid crash when getExternelDir() returns null (huh!)
This commit is contained in:
parent
1fb20926b3
commit
f105bbbde3
@ -6,6 +6,7 @@ import android.content.SharedPreferences;
|
|||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Build.VERSION;
|
import android.os.Build.VERSION;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@ -47,11 +48,17 @@ public class GBApplication extends Application {
|
|||||||
private void setupLogging() {
|
private void setupLogging() {
|
||||||
if (isFileLoggingEnabled()) {
|
if (isFileLoggingEnabled()) {
|
||||||
File dir = getExternalFilesDir(null);
|
File dir = getExternalFilesDir(null);
|
||||||
if (dir != null && !dir.exists()) {
|
if (dir != null) {
|
||||||
dir.mkdirs();
|
if (!dir.exists()) {
|
||||||
|
dir.mkdirs();
|
||||||
|
}
|
||||||
|
// used by assets/logback.xml since the location cannot be statically determined
|
||||||
|
System.setProperty("GB_LOGFILES_DIR", dir.getAbsolutePath());
|
||||||
|
} else {
|
||||||
|
Log.e("GBApplication", "External files dir is null, cannot log to file");
|
||||||
|
System.setProperty("GB_LOGFILES_DIR", "/dev/null");
|
||||||
|
|
||||||
}
|
}
|
||||||
// used by assets/logback.xml since the location cannot be statically determined
|
|
||||||
System.setProperty("GB_LOGFILES_DIR", dir.getAbsolutePath());
|
|
||||||
} else {
|
} else {
|
||||||
System.setProperty("GB_LOGFILES_DIR", "/dev/null"); // just to please logback configuration, not used at all
|
System.setProperty("GB_LOGFILES_DIR", "/dev/null"); // just to please logback configuration, not used at all
|
||||||
try {
|
try {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user