Skip to content

Commit 920bcd8

Browse files
tdmcyngnmikeNG
authored andcommitted
Settings: Set root access options appropriately
It is possible to be running a user build with a debuggable boot image. In this case, "su" will not be available. So only show none/adb. Issue-Id: BACON-4461 Change-Id: Iaa7df8311b9ea81eabb1566ba6f9159fdc9fab34
1 parent 1ad5974 commit 920bcd8

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

res/values/cm_arrays.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,14 @@
3838
<item>2</item>
3939
<item>3</item>
4040
</string-array>
41+
42+
<string-array name="root_access_entries_adb" translatable="false">
43+
<item>@string/root_access_none</item>
44+
<item>@string/root_access_adb</item>
45+
</string-array>
46+
47+
<string-array name="root_access_values_adb" translatable="false">
48+
<item>0</item>
49+
<item>2</item>
50+
</string-array>
4151
</resources>

res/xml/development_prefs.xml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,7 @@
124124
<ListPreference
125125
android:key="root_access"
126126
android:title="@string/root_access"
127-
android:persistent="false"
128-
android:entries="@array/root_access_entries"
129-
android:entryValues="@array/root_access_values" />
127+
android:persistent="false" />
130128

131129
<Preference
132130
android:key="root_appops"

src/com/android/settings/development/DevelopmentSettings.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@
108108

109109
import lineageos.providers.LineageSettings;
110110

111+
import org.lineageos.internal.util.FileUtils;
112+
111113
import java.util.ArrayList;
112114
import java.util.Arrays;
113115
import java.util.HashSet;
@@ -628,6 +630,13 @@ public void onCreate(Bundle icicle) {
628630
mRootAppops.setOnPreferenceClickListener(this);
629631

630632
if (!removeRootOptionsIfRequired()) {
633+
if (FileUtils.fileExists("/system/xbin/su")) {
634+
mRootAccess.setEntries(R.array.root_access_entries);
635+
mRootAccess.setEntryValues(R.array.root_access_values);
636+
} else {
637+
mRootAccess.setEntries(R.array.root_access_entries_adb);
638+
mRootAccess.setEntryValues(R.array.root_access_values_adb);
639+
}
631640
mAllPrefs.add(mRootAccess);
632641
mAllPrefs.add(mRootAppops);
633642
}

0 commit comments

Comments
 (0)