1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2024-11-26 22:31:16 +00:00

Fix NullPointerException for STGUIASSETS

On devices without SD-card / shared-storage, getExternalFilesDir() may
return null.
This commit is contained in:
Martin Carpella 2016-10-20 20:48:36 +02:00
parent 0c7d0431d4
commit 9373a5fd3f

View file

@ -13,6 +13,7 @@ import com.nutomic.syncthingandroid.BuildConfig;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
@ -118,7 +119,9 @@ public class SyncthingRunnable implements Runnable {
// Set home directory to data folder for web GUI folder picker. // Set home directory to data folder for web GUI folder picker.
env.put("HOME", Environment.getExternalStorageDirectory().getAbsolutePath()); env.put("HOME", Environment.getExternalStorageDirectory().getAbsolutePath());
env.put("STTRACE", sp.getString("sttrace", "")); env.put("STTRACE", sp.getString("sttrace", ""));
env.put("STGUIASSETS", mContext.getExternalFilesDir(null).getAbsolutePath() + "/gui"); File externalFilesDir = mContext.getExternalFilesDir(null);
if (externalFilesDir != null)
env.put("STGUIASSETS", externalFilesDir.getAbsolutePath() + "/gui");
env.put("STNORESTART", "1"); env.put("STNORESTART", "1");
env.put("STNOUPGRADE", "1"); env.put("STNOUPGRADE", "1");
if (sp.getBoolean("use_tor", false)) { if (sp.getBoolean("use_tor", false)) {