mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-12-23 11:21:29 +00:00
Chown syncthing files after disabling root (fixes #395).
This commit is contained in:
parent
924d033474
commit
ad00368735
1 changed files with 18 additions and 1 deletions
|
@ -21,6 +21,8 @@ import com.nutomic.syncthingandroid.activities.SyncthingActivity;
|
|||
import com.nutomic.syncthingandroid.syncthing.RestApi;
|
||||
import com.nutomic.syncthingandroid.syncthing.SyncthingService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import eu.chainfire.libsuperuser.Shell;
|
||||
|
||||
public class SettingsFragment extends PreferenceFragment
|
||||
|
@ -279,8 +281,11 @@ public class SettingsFragment extends PreferenceFragment
|
|||
return false;
|
||||
}
|
||||
|
||||
if (preference.getKey().equals(SyncthingService.PREF_USE_ROOT))
|
||||
if (preference.getKey().equals(SyncthingService.PREF_USE_ROOT)) {
|
||||
if (!(Boolean) o)
|
||||
new Thread(new ChownFilesRunnable()).start();
|
||||
requireRestart = true;
|
||||
}
|
||||
|
||||
if (requireRestart)
|
||||
mSyncthingService.getApi().requireRestart(getActivity());
|
||||
|
@ -289,6 +294,18 @@ public class SettingsFragment extends PreferenceFragment
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the owner of syncthing files so they can be accessed without root.
|
||||
*/
|
||||
private class ChownFilesRunnable implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
String f = getActivity().getFilesDir().getAbsolutePath();
|
||||
List<String> out = Shell.SU.run("chown -R --reference=" + f + " " + f);
|
||||
Log.i(TAG, "Changed owner of syncthing files, output: " + out);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
switch (preference.getKey()) {
|
||||
|
|
Loading…
Reference in a new issue