Loading AndroidManifest.xml +1 −0 Original line number Diff line number Diff line Loading @@ -101,6 +101,7 @@ <uses-permission android:name="android.permission.MANAGE_SCOPED_ACCESS_DIRECTORY_PERMISSIONS" /> <uses-permission android:name="android.permission.CAMERA" /> <uses-permission android:name="android.permission.MEDIA_CONTENT_CONTROL" /> <uses-permission android:name="android.permission.ADBROOT" /> <application android:label="@string/settings_label" android:icon="@mipmap/ic_launcher" Loading res/values/cm_strings.xml +4 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,10 @@ <string name="adb_enable">Android debugging</string> <string name="adb_enable_summary">Enable the Android Debug Bridge (ADB) interface</string> <!-- Android debugging as root --> <string name="adb_enable_root">Rooted debugging</string> <string name="adb_enable_summary_root">Allow running Android debugging as root</string> <!-- Android debugging notification --> <string name="adb_notify">Debugging notify</string> <string name="adb_notify_summary">Display a notification when USB or network debugging is enabled</string> Loading res/xml/development_settings.xml +6 −0 Original line number Diff line number Diff line Loading @@ -148,6 +148,12 @@ android:title="@string/adb_enable" android:summary="@string/adb_enable_summary" /> <SwitchPreference android:key="enable_adb_root" android:title="@string/adb_enable_root" android:summary="@string/adb_enable_summary_root" android:dependency="enable_adb" /> <lineageos.preference.LineageSecureSettingSwitchPreference android:key="adb_notify" android:title="@string/adb_notify" Loading src/com/android/settings/development/AdbRootPreferenceController.java 0 → 100644 +81 −0 Original line number Diff line number Diff line /* * Copyright (C) 2018 The LineageOS Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.settings.development; import android.adb.ADBRootService; import android.content.Context; import android.os.UserManager; import androidx.preference.Preference; import androidx.preference.PreferenceScreen; import androidx.preference.SwitchPreference; import com.android.settings.R; import com.android.settings.core.PreferenceControllerMixin; import com.android.settingslib.development.DeveloperOptionsPreferenceController; import lineageos.providers.LineageSettings; public class AdbRootPreferenceController extends DeveloperOptionsPreferenceController implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin { private static final String TAG = "AdbRootPreferenceController"; private static final String PREF_KEY = "enable_adb_root"; private final ADBRootService mADBRootService; public AdbRootPreferenceController(Context context, DevelopmentSettingsDashboardFragment fragment) { super(context); mADBRootService = new ADBRootService(context); } @Override public String getPreferenceKey() { return PREF_KEY; } @Override public void displayPreference(PreferenceScreen screen) { super.displayPreference(screen); ((SwitchPreference) mPreference).setChecked(mADBRootService.getEnabled()); if (!isAdminUser()) { mPreference.setEnabled(false); } } @Override public boolean onPreferenceChange(Preference preference, Object newValue) { final boolean rootEnabled = (Boolean) newValue; mADBRootService.setEnabled(rootEnabled); return true; } @Override protected void onDeveloperOptionsSwitchEnabled() { if (isAdminUser()) { mPreference.setEnabled(true); } } boolean isAdminUser() { return ((UserManager) mContext.getSystemService(Context.USER_SERVICE)).isAdminUser(); } } src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java +1 −0 Original line number Diff line number Diff line Loading @@ -430,6 +430,7 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra controllers.add(new CoolColorTemperaturePreferenceController(context)); controllers.add(new DisableAutomaticUpdatesPreferenceController(context)); controllers.add(new AdbPreferenceController(context, fragment)); controllers.add(new AdbRootPreferenceController(context, fragment)); controllers.add(new WirelessAdbPreferenceController(context, fragment)); controllers.add(new ClearAdbKeysPreferenceController(context, fragment)); controllers.add(new LocalTerminalPreferenceController(context)); Loading Loading
AndroidManifest.xml +1 −0 Original line number Diff line number Diff line Loading @@ -101,6 +101,7 @@ <uses-permission android:name="android.permission.MANAGE_SCOPED_ACCESS_DIRECTORY_PERMISSIONS" /> <uses-permission android:name="android.permission.CAMERA" /> <uses-permission android:name="android.permission.MEDIA_CONTENT_CONTROL" /> <uses-permission android:name="android.permission.ADBROOT" /> <application android:label="@string/settings_label" android:icon="@mipmap/ic_launcher" Loading
res/values/cm_strings.xml +4 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,10 @@ <string name="adb_enable">Android debugging</string> <string name="adb_enable_summary">Enable the Android Debug Bridge (ADB) interface</string> <!-- Android debugging as root --> <string name="adb_enable_root">Rooted debugging</string> <string name="adb_enable_summary_root">Allow running Android debugging as root</string> <!-- Android debugging notification --> <string name="adb_notify">Debugging notify</string> <string name="adb_notify_summary">Display a notification when USB or network debugging is enabled</string> Loading
res/xml/development_settings.xml +6 −0 Original line number Diff line number Diff line Loading @@ -148,6 +148,12 @@ android:title="@string/adb_enable" android:summary="@string/adb_enable_summary" /> <SwitchPreference android:key="enable_adb_root" android:title="@string/adb_enable_root" android:summary="@string/adb_enable_summary_root" android:dependency="enable_adb" /> <lineageos.preference.LineageSecureSettingSwitchPreference android:key="adb_notify" android:title="@string/adb_notify" Loading
src/com/android/settings/development/AdbRootPreferenceController.java 0 → 100644 +81 −0 Original line number Diff line number Diff line /* * Copyright (C) 2018 The LineageOS Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.settings.development; import android.adb.ADBRootService; import android.content.Context; import android.os.UserManager; import androidx.preference.Preference; import androidx.preference.PreferenceScreen; import androidx.preference.SwitchPreference; import com.android.settings.R; import com.android.settings.core.PreferenceControllerMixin; import com.android.settingslib.development.DeveloperOptionsPreferenceController; import lineageos.providers.LineageSettings; public class AdbRootPreferenceController extends DeveloperOptionsPreferenceController implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin { private static final String TAG = "AdbRootPreferenceController"; private static final String PREF_KEY = "enable_adb_root"; private final ADBRootService mADBRootService; public AdbRootPreferenceController(Context context, DevelopmentSettingsDashboardFragment fragment) { super(context); mADBRootService = new ADBRootService(context); } @Override public String getPreferenceKey() { return PREF_KEY; } @Override public void displayPreference(PreferenceScreen screen) { super.displayPreference(screen); ((SwitchPreference) mPreference).setChecked(mADBRootService.getEnabled()); if (!isAdminUser()) { mPreference.setEnabled(false); } } @Override public boolean onPreferenceChange(Preference preference, Object newValue) { final boolean rootEnabled = (Boolean) newValue; mADBRootService.setEnabled(rootEnabled); return true; } @Override protected void onDeveloperOptionsSwitchEnabled() { if (isAdminUser()) { mPreference.setEnabled(true); } } boolean isAdminUser() { return ((UserManager) mContext.getSystemService(Context.USER_SERVICE)).isAdminUser(); } }
src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java +1 −0 Original line number Diff line number Diff line Loading @@ -430,6 +430,7 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra controllers.add(new CoolColorTemperaturePreferenceController(context)); controllers.add(new DisableAutomaticUpdatesPreferenceController(context)); controllers.add(new AdbPreferenceController(context, fragment)); controllers.add(new AdbRootPreferenceController(context, fragment)); controllers.add(new WirelessAdbPreferenceController(context, fragment)); controllers.add(new ClearAdbKeysPreferenceController(context, fragment)); controllers.add(new LocalTerminalPreferenceController(context)); Loading