Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0bb18f7d authored by Steve Kondik's avatar Steve Kondik Committed by Bruno Martins
Browse files

Settings: Add developer setting for root access

Also includes following change:

    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

Change-Id: If96219d893c0dfdcf4ad36e1cd8de3a413db0e8b
parent 42a4decb
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -116,6 +116,15 @@
    <string name="proximity_wake_title">Prevent accidental wake-up</string>
    <string name="proximity_wake_summary">Check the proximity sensor prior to waking up screen</string>

    <!-- Setting checkbox title for root access -->
    <string name="root_access">Root access</string>
    <string name="root_access_warning_title">Allow root access?</string>
    <string name="root_access_warning_message">Allowing apps to request root access is very dangerous and could compromise the security of your system!</string>
    <string name="root_access_none">Disabled</string>
    <string name="root_access_apps">Apps only</string>
    <string name="root_access_adb">ADB only</string>
    <string name="root_access_all">Apps and ADB</string>

    <!-- Touchscreen gesture settings -->
    <string name="touchscreen_gesture_settings_title">Touchscreen gestures</string>
    <string name="touchscreen_gesture_settings_summary">Perform various touchscreen gestures for quick actions</string>
+43 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
     Copyright (C) 2012-2015 The CyanogenMod Project
     Copyright (C) 2018 The LinegeOS 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.
-->
<resources>
    <!-- Arrays for root access capability -->
    <string-array name="root_access_entries" translatable="false">
        <item>@string/root_access_none</item>
        <item>@string/root_access_apps</item>
        <item>@string/root_access_adb</item>
        <item>@string/root_access_all</item>
    </string-array>

    <string-array name="root_access_values" translatable="false">
        <item>0</item>
        <item>1</item>
        <item>2</item>
        <item>3</item>
    </string-array>

    <string-array name="root_access_entries_adb" translatable="false">
        <item>@string/root_access_none</item>
        <item>@string/root_access_adb</item>
    </string-array>

    <string-array name="root_access_values_adb" translatable="false">
        <item>0</item>
        <item>2</item>
    </string-array>
</resources>
+5 −0
Original line number Diff line number Diff line
@@ -137,6 +137,11 @@
            android:key="quick_settings_tiles"
            android:title="@string/quick_settings_developer_tiles"
            android:fragment="com.android.settings.development.qstile.DevelopmentTileConfigFragment" />

        <ListPreference
            android:key="root_access"
            android:title="@string/root_access"
            android:persistent="false" />
    </PreferenceCategory>

    <PreferenceCategory
+17 −1
Original line number Diff line number Diff line
@@ -57,7 +57,8 @@ import java.util.List;
public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFragment
        implements SwitchBar.OnSwitchChangeListener, OemUnlockDialogHost, AdbDialogHost,
        WirelessAdbDialogHost, AdbClearKeysDialogHost, LogPersistDialogHost,
        BluetoothA2dpHwOffloadRebootDialog.OnA2dpHwDialogConfirmedListener {
        BluetoothA2dpHwOffloadRebootDialog.OnA2dpHwDialogConfirmedListener,
        RootAccessDialogHost {

    private static final String TAG = "DevSettingsDashboard";

@@ -291,6 +292,20 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra
        controller.onA2dpHwDialogConfirmed();
    }

    @Override
    public void onRootAccessDialogConfirmed() {
        final RootAccessPreferenceController controller =
                getDevelopmentOptionsController(RootAccessPreferenceController.class);
        controller.onRootAccessDialogConfirmed();
    }

    @Override
    public void onRootAccessDialogDismissed() {
        final RootAccessPreferenceController controller =
                getDevelopmentOptionsController(RootAccessPreferenceController.class);
        controller.onRootAccessDialogDismissed();
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        boolean handledResult = false;
@@ -471,6 +486,7 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra
        controllers.add(new FreeformWindowsPreferenceController(context));
        controllers.add(new ShortcutManagerThrottlingPreferenceController(context));
        controllers.add(new EnableGnssRawMeasFullTrackingPreferenceController(context));
        controllers.add(new RootAccessPreferenceController(context, fragment));
        controllers.add(new DefaultLaunchPreferenceController(context, "running_apps"));
        controllers.add(new DefaultLaunchPreferenceController(context, "demo_mode"));
        controllers.add(new DefaultLaunchPreferenceController(context, "quick_settings_tiles"));
+33 −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;

/**
 * Interface for RootAccessWarningDialogFragment callbacks.
 */
public interface RootAccessDialogHost {

    /**
     * Called when the user presses ok on the warning dialog.
     */
    void onRootAccessDialogConfirmed();

    /**
     * Called when the user dismisses or cancels the warning dialog.
     */
    void onRootAccessDialogDismissed();
}
Loading