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

Commit 6dd086b4 authored by Evan Charlton's avatar Evan Charlton Committed by Steve Kondik
Browse files

Kill foreground process by long-pressing BACK

This patch allows the user to force the running foreground application to be
killed. One example use case for this is applications which trap buttons,
leaving the user stuck. Another would be a memory-heavy application that
traps the BACK button (so the user wouldn't want to leave it in memory by
pressing HOME). Browser is a good example of this second use case.

Change-Id: Idd916a670c0c9051195c6fee5b5779c825e8a71f
parent 273cc740
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -2063,6 +2063,10 @@ found in the list of installed applications.</string>
    <string name="allow_mock_location">Allow mock locations</string>
    <!-- setting Checkbox summary whether to allow mock locations  -->
    <string name="allow_mock_location_summary">Allow mock locations</string>
    <!-- Setting checkbox title whether to allow killing foreground app by longpress on BACK. -->
    <string name="kill_app_longpress_back">Stop app via long-press</string>
    <!-- Setting checkbox summary whether to allow killing foreground app by longpress on BACK. -->
    <string name="kill_app_longpress_back_summary">Long-pressing the BACK button will kill the foreground application.</string>
    <!-- Title of warning dialog about the implications of enabling USB debugging -->
    <string name="adb_warning_title">Allow USB debugging?</string>
    <!-- Warning text to user about the implications of enabling USB debugging -->
+5 −0
Original line number Diff line number Diff line
@@ -38,4 +38,9 @@
        android:title="@string/allow_mock_location" 
        android:summary="@string/allow_mock_location_summary"/>

    <CheckBoxPreference
        android:key="kill_app_longpress_back"
        android:title="@string/kill_app_longpress_back"
        android:summary="@string/kill_app_longpress_back_summary" />

</PreferenceScreen>
+8 −0
Original line number Diff line number Diff line
@@ -39,11 +39,13 @@ public class DevelopmentSettings extends PreferenceActivity
    private static final String ADB_NOTIFY = "adb_notify";
    private static final String KEEP_SCREEN_ON = "keep_screen_on";
    private static final String ALLOW_MOCK_LOCATION = "allow_mock_location";
    private static final String KILL_APP_LONGPRESS_BACK = "kill_app_longpress_back";

    private CheckBoxPreference mEnableAdb;
    private CheckBoxPreference mAdbNotify;
    private CheckBoxPreference mKeepScreenOn;
    private CheckBoxPreference mAllowMockLocation;
    private CheckBoxPreference mKillAppLongpressBack;

    // To track whether Yes was clicked in the adb warning dialog
    private boolean mOkClicked;
@@ -60,6 +62,7 @@ public class DevelopmentSettings extends PreferenceActivity
        mAdbNotify = (CheckBoxPreference) findPreference(ADB_NOTIFY);
        mKeepScreenOn = (CheckBoxPreference) findPreference(KEEP_SCREEN_ON);
        mAllowMockLocation = (CheckBoxPreference) findPreference(ALLOW_MOCK_LOCATION);
        mKillAppLongpressBack = (CheckBoxPreference) findPreference(KILL_APP_LONGPRESS_BACK);
    }

    @Override
@@ -76,6 +79,8 @@ public class DevelopmentSettings extends PreferenceActivity
                Settings.System.STAY_ON_WHILE_PLUGGED_IN, 0) != 0);
        mAllowMockLocation.setChecked(Settings.Secure.getInt(getContentResolver(),
                Settings.Secure.ALLOW_MOCK_LOCATION, 0) != 0);
        mKillAppLongpressBack.setChecked(Settings.Secure.getInt(getContentResolver(),
                Settings.Secure.KILL_APP_LONGPRESS_BACK, 0) != 0);
    }

    @Override
@@ -110,6 +115,9 @@ public class DevelopmentSettings extends PreferenceActivity
        } else if (preference == mAllowMockLocation) {
            Settings.Secure.putInt(getContentResolver(), Settings.Secure.ALLOW_MOCK_LOCATION,
                    mAllowMockLocation.isChecked() ? 1 : 0);
        } else if (preference == mKillAppLongpressBack) {
            Settings.Secure.putInt(getContentResolver(), Settings.Secure.KILL_APP_LONGPRESS_BACK,
                    mKillAppLongpressBack.isChecked() ? 1 : 0);
        }

        return false;