Add mount namespace options

This commit is contained in:
topjohnwu 2017-06-08 22:27:24 +08:00
parent bc576a9659
commit 343161b195
6 changed files with 39 additions and 1 deletions

View File

@ -77,6 +77,7 @@ public class MagiskManager extends Application {
public int multiuserMode; public int multiuserMode;
public int suResponseType; public int suResponseType;
public int suNotificationType; public int suNotificationType;
public int suNamespaceMode;
// Global resources // Global resources
public SharedPreferences prefs; public SharedPreferences prefs;
@ -137,6 +138,7 @@ public class MagiskManager extends Application {
.putString("su_notification", String.valueOf(suNotificationType)) .putString("su_notification", String.valueOf(suNotificationType))
.putString("su_access", String.valueOf(suAccessState)) .putString("su_access", String.valueOf(suAccessState))
.putString("multiuser_mode", String.valueOf(multiuserMode)) .putString("multiuser_mode", String.valueOf(multiuserMode))
.putString("mnt_ns", String.valueOf(suNamespaceMode))
.putString("busybox_version", BUSYBOX_VERSION) .putString("busybox_version", BUSYBOX_VERSION)
.apply(); .apply();
// Add busybox to PATH // Add busybox to PATH
@ -164,6 +166,7 @@ public class MagiskManager extends Application {
if (isSuClient) { if (isSuClient) {
suAccessState = suDB.getSettings(SuDatabaseHelper.ROOT_ACCESS, 3); suAccessState = suDB.getSettings(SuDatabaseHelper.ROOT_ACCESS, 3);
multiuserMode = suDB.getSettings(SuDatabaseHelper.MULTIUSER_MODE, 0); multiuserMode = suDB.getSettings(SuDatabaseHelper.MULTIUSER_MODE, 0);
suNamespaceMode = suDB.getSettings(SuDatabaseHelper.MNT_NS, 1);
} }
} }

View File

@ -60,7 +60,7 @@ public class SettingsActivity extends Activity {
private SharedPreferences prefs; private SharedPreferences prefs;
private PreferenceScreen prefScreen; private PreferenceScreen prefScreen;
private ListPreference suAccess, autoRes, suNotification, requestTimeout, multiuserMode; private ListPreference suAccess, autoRes, suNotification, requestTimeout, multiuserMode, namespaceMode;
private MagiskManager magiskManager; private MagiskManager magiskManager;
@Override @Override
@ -80,6 +80,7 @@ public class SettingsActivity extends Activity {
requestTimeout = (ListPreference) findPreference("su_request_timeout"); requestTimeout = (ListPreference) findPreference("su_request_timeout");
suNotification = (ListPreference) findPreference("su_notification"); suNotification = (ListPreference) findPreference("su_notification");
multiuserMode = (ListPreference) findPreference("multiuser_mode"); multiuserMode = (ListPreference) findPreference("multiuser_mode");
namespaceMode = (ListPreference) findPreference("mnt_ns");
setSummary(); setSummary();
@ -182,6 +183,11 @@ public class SettingsActivity extends Activity {
case "multiuser_mode": case "multiuser_mode":
magiskManager.multiuserMode = Utils.getPrefsInt(prefs, "multiuser_mode", 0); magiskManager.multiuserMode = Utils.getPrefsInt(prefs, "multiuser_mode", 0);
magiskManager.suDB.setSettings(SuDatabaseHelper.MULTIUSER_MODE, magiskManager.multiuserMode); magiskManager.suDB.setSettings(SuDatabaseHelper.MULTIUSER_MODE, magiskManager.multiuserMode);
break;
case "mnt_ns":
magiskManager.suNamespaceMode = Utils.getPrefsInt(prefs, "mnt_ns", 1);
magiskManager.suDB.setSettings(SuDatabaseHelper.MNT_NS, magiskManager.suNamespaceMode);
break;
case "su_request_timeout": case "su_request_timeout":
magiskManager.suRequestTimeout = Utils.getPrefsInt(prefs, "su_request_timeout", 10); magiskManager.suRequestTimeout = Utils.getPrefsInt(prefs, "su_request_timeout", 10);
break; break;
@ -212,6 +218,8 @@ public class SettingsActivity extends Activity {
getString(R.string.request_timeout_summary, prefs.getString("su_request_timeout", "10"))); getString(R.string.request_timeout_summary, prefs.getString("su_request_timeout", "10")));
multiuserMode.setSummary(getResources() multiuserMode.setSummary(getResources()
.getStringArray(R.array.multiuser_summary)[magiskManager.multiuserMode]); .getStringArray(R.array.multiuser_summary)[magiskManager.multiuserMode]);
namespaceMode.setSummary(getResources()
.getStringArray(R.array.namespace_summary)[magiskManager.suNamespaceMode]);
} }
} }

View File

@ -21,6 +21,7 @@ public class SuDatabaseHelper extends SQLiteOpenHelper {
public static final String ROOT_ACCESS = "root_access"; public static final String ROOT_ACCESS = "root_access";
public static final String MULTIUSER_MODE = "multiuser_mode"; public static final String MULTIUSER_MODE = "multiuser_mode";
public static final String MNT_NS = "mnt_ns";
private static final int DATABASE_VER = 2; private static final int DATABASE_VER = 2;
private static final String POLICY_TABLE = "policies"; private static final String POLICY_TABLE = "policies";

View File

@ -61,4 +61,16 @@
<item>@string/user_indepenent_summary</item> <item>@string/user_indepenent_summary</item>
</string-array> </string-array>
<string-array name="namespace">
<item>@string/settings_ns_global</item>
<item>@string/settings_ns_requester</item>
<item>@string/settings_ns_isolate</item>
</string-array>
<string-array name="namespace_summary">
<item>@string/global_summary</item>
<item>@string/requester_summary</item>
<item>@string/isolate_summary</item>
</string-array>
</resources> </resources>

View File

@ -175,6 +175,14 @@
<string name="user_indepenent_summary">Each user has its own separate root rules</string> <string name="user_indepenent_summary">Each user has its own separate root rules</string>
<string name="multiuser_hint_owner_request">A request has been sent to the device owner. Please switch to the owner and grant the permission</string> <string name="multiuser_hint_owner_request">A request has been sent to the device owner. Please switch to the owner and grant the permission</string>
<string name="mount_namespace_mode">Mount Namespace Mode</string>
<string name="settings_ns_global">Global Namespace</string>
<string name="settings_ns_requester">Requester Namespace</string>
<string name="settings_ns_isolate">Isolated Namespace</string>
<string name="global_summary">All root sessions use the global mount namespace</string>
<string name="requester_summary">Root sessions will use its requester\'s namespace</string>
<string name="isolate_summary">Each root session will have its own isolated namespace</string>
<string name="settings_development_category">App Development</string> <string name="settings_development_category">App Development</string>
<string name="settings_developer_logging_title">Enable advanced debug logging</string> <string name="settings_developer_logging_title">Enable advanced debug logging</string>
<string name="settings_developer_logging_summary">Check this to enable verbose logging</string> <string name="settings_developer_logging_summary">Check this to enable verbose logging</string>

View File

@ -58,6 +58,12 @@
android:entries="@array/multiuser_mode" android:entries="@array/multiuser_mode"
android:entryValues="@array/value_array" /> android:entryValues="@array/value_array" />
<ListPreference
android:key="mnt_ns"
android:title="@string/mount_namespace_mode"
android:entries="@array/namespace"
android:entryValues="@array/value_array" />
<ListPreference <ListPreference
android:key="su_auto_response" android:key="su_auto_response"
android:title="@string/auto_response" android:title="@string/auto_response"