mirror of
https://github.com/Divested-Mobile/DivestOS-Build.git
synced 2025-03-01 10:51:21 -05:00
Automatic reboot and Bluetooth/Wi-Fi shutoff from GrapheneOS and CalyxOS
Closes https://github.com/Divested-Mobile/DivestOS-Build/issues/59 Tested on 18.1 Untested on 17.1 Signed-off-by: Tad <tad@spotco.us>
This commit is contained in:
parent
e61e288b4a
commit
07bd5a3a0e
@ -0,0 +1,151 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: anupritaisno1 <www.anuprita804@gmail.com>
|
||||||
|
Date: Mon, 7 Jun 2021 22:04:53 +0100
|
||||||
|
Subject: [PATCH] automatically reboot device after timeout if set
|
||||||
|
|
||||||
|
---
|
||||||
|
core/java/android/provider/Settings.java | 7 ++++
|
||||||
|
data/etc/com.android.systemui.xml | 1 +
|
||||||
|
packages/SystemUI/AndroidManifest.xml | 3 ++
|
||||||
|
.../keyguard/KeyguardViewMediator.java | 35 +++++++++++++++++++
|
||||||
|
4 files changed, 46 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
|
||||||
|
index 07779405bbf6..c1677042d9ea 100644
|
||||||
|
--- a/core/java/android/provider/Settings.java
|
||||||
|
+++ b/core/java/android/provider/Settings.java
|
||||||
|
@@ -8215,6 +8215,13 @@ public final class Settings {
|
||||||
|
public static final String LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS =
|
||||||
|
"lock_screen_show_silent_notifications";
|
||||||
|
|
||||||
|
+ /**
|
||||||
|
+ * Whether to automatically reboot the device after a user defined timeout
|
||||||
|
+ *
|
||||||
|
+ * @hide
|
||||||
|
+ */
|
||||||
|
+ public static final String SETTINGS_REBOOT_AFTER_TIMEOUT = "settings_reboot_after_timeout";
|
||||||
|
+
|
||||||
|
/**
|
||||||
|
* Indicates whether snooze options should be shown on notifications
|
||||||
|
* <p>
|
||||||
|
diff --git a/data/etc/com.android.systemui.xml b/data/etc/com.android.systemui.xml
|
||||||
|
index 2f5b5f3bf7b4..83779170d05c 100644
|
||||||
|
--- a/data/etc/com.android.systemui.xml
|
||||||
|
+++ b/data/etc/com.android.systemui.xml
|
||||||
|
@@ -44,6 +44,7 @@
|
||||||
|
<permission name="android.permission.READ_NETWORK_USAGE_HISTORY"/>
|
||||||
|
<permission name="android.permission.READ_PRIVILEGED_PHONE_STATE"/>
|
||||||
|
<permission name="android.permission.REAL_GET_TASKS"/>
|
||||||
|
+ <permission name="android.permission.REBOOT"/>
|
||||||
|
<permission name="android.permission.RECEIVE_MEDIA_RESOURCE_USAGE"/>
|
||||||
|
<permission name="android.permission.START_ACTIVITIES_FROM_BACKGROUND" />
|
||||||
|
<permission name="android.permission.START_ACTIVITY_AS_CALLER"/>
|
||||||
|
diff --git a/packages/SystemUI/AndroidManifest.xml b/packages/SystemUI/AndroidManifest.xml
|
||||||
|
index 55104b4e0ee2..5ed2807922d9 100644
|
||||||
|
--- a/packages/SystemUI/AndroidManifest.xml
|
||||||
|
+++ b/packages/SystemUI/AndroidManifest.xml
|
||||||
|
@@ -250,6 +250,9 @@
|
||||||
|
<!-- Permission to change the display color -->
|
||||||
|
<uses-permission android:name="android.permission.CONTROL_DISPLAY_COLOR_TRANSFORMS" />
|
||||||
|
|
||||||
|
+ <!-- Permission to allow rebooting the device after a user configurable amount of time -->
|
||||||
|
+ <uses-permission android:name="android.permission.REBOOT" />
|
||||||
|
+
|
||||||
|
<protected-broadcast android:name="com.android.settingslib.action.REGISTER_SLICE_RECEIVER" />
|
||||||
|
<protected-broadcast android:name="com.android.settingslib.action.UNREGISTER_SLICE_RECEIVER" />
|
||||||
|
<protected-broadcast android:name="com.android.settings.flashlight.action.FLASHLIGHT_CHANGED" />
|
||||||
|
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
|
||||||
|
index 34f075d601cc..035581bd39a4 100644
|
||||||
|
--- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
|
||||||
|
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
|
||||||
|
@@ -152,6 +152,8 @@ public class KeyguardViewMediator extends SystemUI {
|
||||||
|
|
||||||
|
private final static String TAG = "KeyguardViewMediator";
|
||||||
|
|
||||||
|
+ private static final String DELAYED_REBOOT_ACTION =
|
||||||
|
+ "com.android.internal.policy.impl.PhoneWindowManager.DELAYED_REBOOT";
|
||||||
|
private static final String DELAYED_KEYGUARD_ACTION =
|
||||||
|
"com.android.internal.policy.impl.PhoneWindowManager.DELAYED_KEYGUARD";
|
||||||
|
private static final String DELAYED_LOCK_PROFILE_ACTION =
|
||||||
|
@@ -273,6 +275,11 @@ public class KeyguardViewMediator extends SystemUI {
|
||||||
|
*/
|
||||||
|
private int mDelayedProfileShowingSequence;
|
||||||
|
|
||||||
|
+ /**
|
||||||
|
+ * Same as {@link #mDelayedProfileShowingSequence}, but used for our reboot implementation
|
||||||
|
+ */
|
||||||
|
+ private int mDelayedRebootSequence;
|
||||||
|
+
|
||||||
|
/**
|
||||||
|
* If the user has disabled the keyguard, then requests to exit, this is
|
||||||
|
* how we'll ultimately let them know whether it was successful. We use this
|
||||||
|
@@ -703,6 +710,7 @@ public class KeyguardViewMediator extends SystemUI {
|
||||||
|
final IntentFilter delayedActionFilter = new IntentFilter();
|
||||||
|
delayedActionFilter.addAction(DELAYED_KEYGUARD_ACTION);
|
||||||
|
delayedActionFilter.addAction(DELAYED_LOCK_PROFILE_ACTION);
|
||||||
|
+ delayedActionFilter.addAction(DELAYED_REBOOT_ACTION);
|
||||||
|
mContext.registerReceiver(mDelayedLockBroadcastReceiver, delayedActionFilter,
|
||||||
|
SYSTEMUI_PERMISSION, null /* scheduler */);
|
||||||
|
|
||||||
|
@@ -976,6 +984,18 @@ public class KeyguardViewMediator extends SystemUI {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
+ private void doRebootForOwnerAfterTimeoutIfEnabled(long rebootAfterTimeout) {
|
||||||
|
+ long when = SystemClock.elapsedRealtime() + rebootAfterTimeout;
|
||||||
|
+ Intent rebootIntent = new Intent(DELAYED_REBOOT_ACTION);
|
||||||
|
+ rebootIntent.putExtra("seq", mDelayedRebootSequence);
|
||||||
|
+ rebootIntent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
|
||||||
|
+ PendingIntent sender = PendingIntent.getBroadcast(mContext,
|
||||||
|
+ 0, rebootIntent, PendingIntent.FLAG_CANCEL_CURRENT);
|
||||||
|
+ mAlarmManager.setExactAndAllowWhileIdle(AlarmManager.ELAPSED_REALTIME_WAKEUP, when, sender);
|
||||||
|
+ if (DEBUG) Log.d(TAG, "setting alarm to reboot device, timeout = "
|
||||||
|
+ + String.valueOf(rebootAfterTimeout));
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
private void doKeyguardForChildProfilesLocked() {
|
||||||
|
UserManager um = UserManager.get(mContext);
|
||||||
|
for (int profileId : um.getEnabledProfileIds(UserHandle.myUserId())) {
|
||||||
|
@@ -993,6 +1013,10 @@ public class KeyguardViewMediator extends SystemUI {
|
||||||
|
mDelayedProfileShowingSequence++;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ private void cancelDoRebootForOwnerAfterTimeoutIfEnabled() {
|
||||||
|
+ mDelayedRebootSequence++;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
/**
|
||||||
|
* Let's us know when the device is waking up.
|
||||||
|
*/
|
||||||
|
@@ -1370,6 +1394,10 @@ public class KeyguardViewMediator extends SystemUI {
|
||||||
|
|
||||||
|
if (DEBUG) Log.d(TAG, "doKeyguard: showing the lock screen");
|
||||||
|
showLocked(options);
|
||||||
|
+ final long rebootAfterTimeout = Settings.Global.getLong(mContext.getContentResolver(), Settings.Global.SETTINGS_REBOOT_AFTER_TIMEOUT, 0);
|
||||||
|
+ if (rebootAfterTimeout >= 1) {
|
||||||
|
+ doRebootForOwnerAfterTimeoutIfEnabled(rebootAfterTimeout);
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
|
||||||
|
private void lockProfile(int userId) {
|
||||||
|
@@ -1530,6 +1558,12 @@ public class KeyguardViewMediator extends SystemUI {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
+ } else if (DELAYED_REBOOT_ACTION.equals(intent.getAction())) {
|
||||||
|
+ final int sequence = intent.getIntExtra("seq", 0);
|
||||||
|
+ if (sequence == mDelayedRebootSequence) {
|
||||||
|
+ PowerManager pm = mContext.getSystemService(PowerManager.class);
|
||||||
|
+ pm.reboot(null);
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
@@ -1947,6 +1981,7 @@ public class KeyguardViewMediator extends SystemUI {
|
||||||
|
mHideAnimationRun = false;
|
||||||
|
adjustStatusBarLocked();
|
||||||
|
sendUserPresentBroadcast();
|
||||||
|
+ cancelDoRebootForOwnerAfterTimeoutIfEnabled();
|
||||||
|
}
|
||||||
|
Trace.endSection();
|
||||||
|
}
|
@ -0,0 +1,121 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: pratyush <codelab@pratyush.dev>
|
||||||
|
Date: Thu, 1 Jul 2021 12:26:49 +0530
|
||||||
|
Subject: [PATCH] Bluetooth auto turn off
|
||||||
|
|
||||||
|
---
|
||||||
|
core/java/android/provider/Settings.java | 6 ++
|
||||||
|
.../server/BluetoothManagerService.java | 76 +++++++++++++++++++
|
||||||
|
2 files changed, 82 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
|
||||||
|
index c1677042d9ea..a7056de4ffb4 100644
|
||||||
|
--- a/core/java/android/provider/Settings.java
|
||||||
|
+++ b/core/java/android/provider/Settings.java
|
||||||
|
@@ -8215,6 +8215,12 @@ public final class Settings {
|
||||||
|
public static final String LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS =
|
||||||
|
"lock_screen_show_silent_notifications";
|
||||||
|
|
||||||
|
+ /**
|
||||||
|
+ * The amount of time in milliseconds before bluetooth is turned off
|
||||||
|
+ * @hide
|
||||||
|
+ */
|
||||||
|
+ public static final String BLUETOOTH_OFF_TIMEOUT = "bluetooth_off_timeout";
|
||||||
|
+
|
||||||
|
/**
|
||||||
|
* Whether to automatically reboot the device after a user defined timeout
|
||||||
|
*
|
||||||
|
diff --git a/services/core/java/com/android/server/BluetoothManagerService.java b/services/core/java/com/android/server/BluetoothManagerService.java
|
||||||
|
index 9bcded3e1e14..512cecab807a 100644
|
||||||
|
--- a/services/core/java/com/android/server/BluetoothManagerService.java
|
||||||
|
+++ b/services/core/java/com/android/server/BluetoothManagerService.java
|
||||||
|
@@ -18,6 +18,7 @@ package com.android.server;
|
||||||
|
|
||||||
|
import android.Manifest;
|
||||||
|
import android.app.ActivityManager;
|
||||||
|
+import android.app.AlarmManager;
|
||||||
|
import android.app.AppGlobals;
|
||||||
|
import android.app.AppOpsManager;
|
||||||
|
import android.bluetooth.BluetoothAdapter;
|
||||||
|
@@ -494,6 +495,81 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
|
||||||
|
Slog.w(TAG, "Unable to resolve SystemUI's UID.", e);
|
||||||
|
}
|
||||||
|
mSystemUiUid = systemUiUid;
|
||||||
|
+
|
||||||
|
+ /*
|
||||||
|
+ * System sends ACTION_STATE_CHANGED broadcast soon as any state
|
||||||
|
+ * changes. what it means in action is we don't have to take care if
|
||||||
|
+ * device reboot while BT has not been turned off automatically.
|
||||||
|
+ *
|
||||||
|
+ * A word of warning though it does not check if device as been
|
||||||
|
+ * unlocked or not what it means in real life is if you have sometime
|
||||||
|
+ * like tile ble tracker configured it will turn off BT. As result tile
|
||||||
|
+ * tracking will fail because of auto timeout. this behaviour can be
|
||||||
|
+ * changed with UserManager.isUnlocked()
|
||||||
|
+ * */
|
||||||
|
+ IntentFilter btFilter = new IntentFilter();
|
||||||
|
+ btFilter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);
|
||||||
|
+ btFilter.addAction(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED);
|
||||||
|
+ btFilter.addAction(BluetoothAdapter.ACTION_LOCAL_NAME_CHANGED);
|
||||||
|
+ context.registerReceiver(new BroadcastReceiver() {
|
||||||
|
+ @Override
|
||||||
|
+ public void onReceive(Context broadcastContext, Intent intent) {
|
||||||
|
+ reconfigureBtTimeoutListener();
|
||||||
|
+ }
|
||||||
|
+ }, btFilter);
|
||||||
|
+
|
||||||
|
+ context.getContentResolver().registerContentObserver(
|
||||||
|
+ Settings.Global.getUriFor(Settings.Global.BLUETOOTH_OFF_TIMEOUT),
|
||||||
|
+ false,
|
||||||
|
+ new ContentObserver(new Handler(context.getMainLooper())) {
|
||||||
|
+ @Override
|
||||||
|
+ public void onChange(boolean selfChange) {
|
||||||
|
+ super.onChange(selfChange);
|
||||||
|
+ reconfigureBtTimeoutListener();
|
||||||
|
+ }
|
||||||
|
+ });
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private static final AlarmManager.OnAlarmListener listener = () -> {
|
||||||
|
+ BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
|
||||||
|
+ if (isBtOnAndDisconnected() && bluetoothAdapter != null) {
|
||||||
|
+ bluetoothAdapter.disable();
|
||||||
|
+ }
|
||||||
|
+ };
|
||||||
|
+
|
||||||
|
+ // If device is still connected cancel timeout for now and wait for disconnected signal
|
||||||
|
+ private void reconfigureBtTimeoutListener() {
|
||||||
|
+ AlarmManager alarmManager = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE);
|
||||||
|
+ if (isTimeoutEnabled(mContext) && isBtOnAndDisconnected()) {
|
||||||
|
+ final long timeout = SystemClock.elapsedRealtime() + btTimeoutDurationInMilli(mContext);
|
||||||
|
+ alarmManager.cancel(listener);
|
||||||
|
+ alarmManager.setExact(
|
||||||
|
+ AlarmManager.ELAPSED_REALTIME_WAKEUP,
|
||||||
|
+ timeout,
|
||||||
|
+ "BT Idle Timeout",
|
||||||
|
+ listener,
|
||||||
|
+ new Handler(mContext.getMainLooper())
|
||||||
|
+ );
|
||||||
|
+ } else {
|
||||||
|
+ alarmManager.cancel(listener);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private static boolean isBtOnAndDisconnected() {
|
||||||
|
+ BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
|
||||||
|
+ return bluetoothAdapter != null && bluetoothAdapter.getState() == BluetoothAdapter.STATE_ON
|
||||||
|
+ && bluetoothAdapter.getState() == BluetoothAdapter.STATE_ON &&
|
||||||
|
+ bluetoothAdapter.getConnectionState() == BluetoothAdapter.STATE_DISCONNECTED;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private static long btTimeoutDurationInMilli(Context context) {
|
||||||
|
+ return Settings.Global.getLong(context.getContentResolver(),
|
||||||
|
+ Settings.Global.BLUETOOTH_OFF_TIMEOUT, 0);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /** Zero is default and means disabled */
|
||||||
|
+ private static boolean isTimeoutEnabled(Context context) {
|
||||||
|
+ return 0 != btTimeoutDurationInMilli(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
@ -0,0 +1,124 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Pratyush <codelab@pratyush.dev>
|
||||||
|
Date: Tue, 6 Jul 2021 18:18:06 +0530
|
||||||
|
Subject: [PATCH] Wi-Fi auto turn off
|
||||||
|
|
||||||
|
---
|
||||||
|
core/java/android/provider/Settings.java | 6 ++
|
||||||
|
.../server/net/NetworkStatsService.java | 70 +++++++++++++++++++
|
||||||
|
2 files changed, 76 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
|
||||||
|
index a7056de4ffb4..339ab91354e3 100644
|
||||||
|
--- a/core/java/android/provider/Settings.java
|
||||||
|
+++ b/core/java/android/provider/Settings.java
|
||||||
|
@@ -8221,6 +8221,12 @@ public final class Settings {
|
||||||
|
*/
|
||||||
|
public static final String BLUETOOTH_OFF_TIMEOUT = "bluetooth_off_timeout";
|
||||||
|
|
||||||
|
+ /**
|
||||||
|
+ * The amount of time in milliseconds before Wi-Fi is turned off
|
||||||
|
+ * @hide
|
||||||
|
+ */
|
||||||
|
+ public static final String WIFI_OFF_TIMEOUT = "wifi_off_timeout";
|
||||||
|
+
|
||||||
|
/**
|
||||||
|
* Whether to automatically reboot the device after a user defined timeout
|
||||||
|
*
|
||||||
|
diff --git a/services/core/java/com/android/server/net/NetworkStatsService.java b/services/core/java/com/android/server/net/NetworkStatsService.java
|
||||||
|
index d1b5534e3777..831f26a63e97 100644
|
||||||
|
--- a/services/core/java/com/android/server/net/NetworkStatsService.java
|
||||||
|
+++ b/services/core/java/com/android/server/net/NetworkStatsService.java
|
||||||
|
@@ -82,6 +82,7 @@ import android.content.Intent;
|
||||||
|
import android.content.IntentFilter;
|
||||||
|
import android.content.pm.ApplicationInfo;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
+import android.database.ContentObserver;
|
||||||
|
import android.net.DataUsageRequest;
|
||||||
|
import android.net.INetworkManagementEventObserver;
|
||||||
|
import android.net.INetworkStatsService;
|
||||||
|
@@ -97,8 +98,10 @@ import android.net.NetworkStats.NonMonotonicObserver;
|
||||||
|
import android.net.NetworkStatsHistory;
|
||||||
|
import android.net.NetworkTemplate;
|
||||||
|
import android.net.TrafficStats;
|
||||||
|
+import android.net.wifi.WifiManager;
|
||||||
|
import android.os.BestClock;
|
||||||
|
import android.os.Binder;
|
||||||
|
+import android.os.Bundle;
|
||||||
|
import android.os.DropBoxManager;
|
||||||
|
import android.os.Environment;
|
||||||
|
import android.os.Handler;
|
||||||
|
@@ -366,6 +369,73 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
|
||||||
|
mSystemDir = checkNotNull(systemDir, "missing systemDir");
|
||||||
|
mBaseDir = checkNotNull(baseDir, "missing baseDir");
|
||||||
|
mUseBpfTrafficStats = new File("/sys/fs/bpf/map_netd_app_uid_stats_map").exists();
|
||||||
|
+
|
||||||
|
+ IntentFilter wifiFilter = new IntentFilter();
|
||||||
|
+ wifiFilter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
|
||||||
|
+ wifiFilter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION);
|
||||||
|
+
|
||||||
|
+ context.registerReceiver(
|
||||||
|
+ new BroadcastReceiver() {
|
||||||
|
+ @Override
|
||||||
|
+ public void onReceive(Context context, Intent intent) {
|
||||||
|
+ if (WifiManager.NETWORK_STATE_CHANGED_ACTION.equals(intent.getAction())) {
|
||||||
|
+ Bundle bundle = intent.getExtras();
|
||||||
|
+ NetworkInfo networkInfo = bundle.getParcelable(WifiManager.EXTRA_NETWORK_INFO);
|
||||||
|
+ isWifiConnected = networkInfo != null && networkInfo.isConnected();
|
||||||
|
+ }
|
||||||
|
+ reconfigureWiFiTimeoutListener();
|
||||||
|
+ }
|
||||||
|
+ }, wifiFilter
|
||||||
|
+ );
|
||||||
|
+
|
||||||
|
+ context.getContentResolver().registerContentObserver(
|
||||||
|
+ Global.getUriFor(Global.WIFI_OFF_TIMEOUT),
|
||||||
|
+ false,
|
||||||
|
+ new ContentObserver(new Handler(context.getMainLooper())) {
|
||||||
|
+ @Override
|
||||||
|
+ public void onChange(boolean selfChange) {
|
||||||
|
+ super.onChange(selfChange);
|
||||||
|
+ reconfigureWiFiTimeoutListener();
|
||||||
|
+ }
|
||||||
|
+ });
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private static boolean isWifiConnected = false;
|
||||||
|
+ private final AlarmManager.OnAlarmListener listener = this::turnOffWifi;
|
||||||
|
+
|
||||||
|
+ private void turnOffWifi() {
|
||||||
|
+ WifiManager wifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
|
||||||
|
+ if (isWifiTimeoutEnabled(mContext) && wifiManager.isWifiEnabled()) {
|
||||||
|
+ // setWifiEnabled(enabled) is deprecated, though AOSP still uses
|
||||||
|
+ // it internally and system apps/services are exempted
|
||||||
|
+ wifiManager.setWifiEnabled(false);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private void reconfigureWiFiTimeoutListener() {
|
||||||
|
+ if (isWifiTimeoutEnabled(mContext) && !isWifiConnected) {
|
||||||
|
+ final long timeout = SystemClock.elapsedRealtime() + wifiTimeoutDurationInMilli(mContext);
|
||||||
|
+ mAlarmManager.cancel(listener);
|
||||||
|
+ mAlarmManager.setExact(
|
||||||
|
+ AlarmManager.ELAPSED_REALTIME_WAKEUP,
|
||||||
|
+ timeout,
|
||||||
|
+ "Wi-Fi Idle Timeout",
|
||||||
|
+ listener,
|
||||||
|
+ new Handler(mContext.getMainLooper())
|
||||||
|
+ );
|
||||||
|
+ } else {
|
||||||
|
+ mAlarmManager.cancel(listener);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private static long wifiTimeoutDurationInMilli(Context mContext) {
|
||||||
|
+ return Settings.Global.getLong(mContext.getContentResolver(),
|
||||||
|
+ Global.WIFI_OFF_TIMEOUT, 0);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /** Zero is default and means disabled */
|
||||||
|
+ private static boolean isWifiTimeoutEnabled(Context mContext) {
|
||||||
|
+ return 0 != wifiTimeoutDurationInMilli(mContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void registerLocalService() {
|
@ -0,0 +1,189 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: pratyush <codelab@pratyush.dev>
|
||||||
|
Date: Mon, 7 Jun 2021 22:15:59 +0100
|
||||||
|
Subject: [PATCH] add auto-reboot setting
|
||||||
|
|
||||||
|
---
|
||||||
|
res/values/arrays.xml | 31 +++++++
|
||||||
|
res/values/strings.xml | 3 +
|
||||||
|
res/xml/security_dashboard_settings.xml | 8 ++
|
||||||
|
.../AutoRebootPreferenceController.java | 82 +++++++++++++++++++
|
||||||
|
.../settings/security/SecuritySettings.java | 1 +
|
||||||
|
5 files changed, 125 insertions(+)
|
||||||
|
create mode 100644 src/com/android/settings/security/AutoRebootPreferenceController.java
|
||||||
|
|
||||||
|
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
|
||||||
|
index b983f467df..5813bb18db 100644
|
||||||
|
--- a/res/values/arrays.xml
|
||||||
|
+++ b/res/values/arrays.xml
|
||||||
|
@@ -144,6 +144,37 @@
|
||||||
|
<item>1800000</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
+ <!-- Auto reboot settings -->
|
||||||
|
+ <string-array name="auto_reboot_entries">
|
||||||
|
+ <item>Off</item>
|
||||||
|
+ <item>10 minutes</item>
|
||||||
|
+ <item>30 minutes</item>
|
||||||
|
+ <item>1 hour</item>
|
||||||
|
+ <item>2 hours</item>
|
||||||
|
+ <item>4 hours</item>
|
||||||
|
+ <item>8 hours</item>
|
||||||
|
+ <item>12 hours</item>
|
||||||
|
+ <item>24 hours</item>
|
||||||
|
+ <item>36 hours</item>
|
||||||
|
+ <item>48 hours</item>
|
||||||
|
+ <item>72 hours</item>
|
||||||
|
+ </string-array>
|
||||||
|
+
|
||||||
|
+ <string-array name="auto_reboot_values" translatable="false">
|
||||||
|
+ <item>0</item> <!-- Disabled -->
|
||||||
|
+ <item>600000</item>
|
||||||
|
+ <item>1800000</item>
|
||||||
|
+ <item>3600000</item>
|
||||||
|
+ <item>7200000</item>
|
||||||
|
+ <item>14400000</item>
|
||||||
|
+ <item>28800000</item>
|
||||||
|
+ <item>43200000</item>
|
||||||
|
+ <item>86400000</item>
|
||||||
|
+ <item>129600000</item>
|
||||||
|
+ <item>172800000</item>
|
||||||
|
+ <item>259200000</item>
|
||||||
|
+ </string-array>
|
||||||
|
+
|
||||||
|
<string-array name="entries_font_size">
|
||||||
|
<item msgid="6490061470416867723">Small</item>
|
||||||
|
<item msgid="3579015730662088893">Default</item>
|
||||||
|
diff --git a/res/values/strings.xml b/res/values/strings.xml
|
||||||
|
index 2180ea45f6..eeee1c039f 100644
|
||||||
|
--- a/res/values/strings.xml
|
||||||
|
+++ b/res/values/strings.xml
|
||||||
|
@@ -810,6 +810,9 @@
|
||||||
|
<!-- Text shown for the description of the lockdown option -->
|
||||||
|
<string name="lockdown_settings_summary">Display power button option that turns off Smart Lock, biometric unlocking, and notifications on the lock screen</string>
|
||||||
|
|
||||||
|
+ <string name="auto_reboot_title">Auto reboot</string>
|
||||||
|
+ <string name="auto_reboot_summary">Automatically reboot the device, if the phone hasn\'t been unlocked within the selected number of hours.</string>
|
||||||
|
+
|
||||||
|
<!-- Text shown for the title of the extend unlock mode option for trust agents [CHAR LIMIT=40] -->
|
||||||
|
<string name="trust_agents_extend_unlock_title">Trust agents only extend unlock</string>
|
||||||
|
<!-- Text shown for the description of the extend unlock mode option [CHAR LIMIT=NONE] -->
|
||||||
|
diff --git a/res/xml/security_dashboard_settings.xml b/res/xml/security_dashboard_settings.xml
|
||||||
|
index 6a896ced42..1667943ba4 100644
|
||||||
|
--- a/res/xml/security_dashboard_settings.xml
|
||||||
|
+++ b/res/xml/security_dashboard_settings.xml
|
||||||
|
@@ -55,6 +55,14 @@
|
||||||
|
android:title="@string/security_settings_face_preference_title"
|
||||||
|
android:summary="@string/summary_placeholder"
|
||||||
|
settings:keywords="@string/keywords_face_settings" />
|
||||||
|
+
|
||||||
|
+ <ListPreference
|
||||||
|
+ android:key="auto_reboot"
|
||||||
|
+ android:title="@string/auto_reboot_title"
|
||||||
|
+ android:summary="@string/auto_reboot_summary"
|
||||||
|
+ android:persistent="false"
|
||||||
|
+ android:entries="@array/auto_reboot_entries"
|
||||||
|
+ android:entryValues="@array/auto_reboot_values" />
|
||||||
|
</PreferenceCategory>
|
||||||
|
|
||||||
|
<!-- work profile security section -->
|
||||||
|
diff --git a/src/com/android/settings/security/AutoRebootPreferenceController.java b/src/com/android/settings/security/AutoRebootPreferenceController.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000..c7a75219a5
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/com/android/settings/security/AutoRebootPreferenceController.java
|
||||||
|
@@ -0,0 +1,82 @@
|
||||||
|
+package com.android.settings.security;
|
||||||
|
+
|
||||||
|
+import android.content.Context;
|
||||||
|
+import android.os.UserManager;
|
||||||
|
+import android.provider.Settings;
|
||||||
|
+import android.util.Log;
|
||||||
|
+
|
||||||
|
+import androidx.preference.ListPreference;
|
||||||
|
+import androidx.preference.Preference;
|
||||||
|
+import androidx.preference.PreferenceCategory;
|
||||||
|
+import androidx.preference.PreferenceScreen;
|
||||||
|
+
|
||||||
|
+import com.android.settings.core.PreferenceControllerMixin;
|
||||||
|
+import com.android.settingslib.core.AbstractPreferenceController;
|
||||||
|
+import com.android.settingslib.core.lifecycle.events.OnResume;
|
||||||
|
+
|
||||||
|
+public class AutoRebootPreferenceController extends AbstractPreferenceController
|
||||||
|
+ implements PreferenceControllerMixin, OnResume,
|
||||||
|
+ Preference.OnPreferenceChangeListener {
|
||||||
|
+
|
||||||
|
+ private static final String KEY_AUTO_REBOOT = "auto_reboot";
|
||||||
|
+ private static final String PREF_KEY_SECURITY_CATEGORY = "security_category";
|
||||||
|
+
|
||||||
|
+ private PreferenceCategory mSecurityCategory;
|
||||||
|
+ private boolean mIsAdmin;
|
||||||
|
+ private final UserManager mUm;
|
||||||
|
+
|
||||||
|
+ public AutoRebootPreferenceController(Context context) {
|
||||||
|
+ super(context);
|
||||||
|
+ mUm = UserManager.get(context);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public void displayPreference(PreferenceScreen screen) {
|
||||||
|
+ super.displayPreference(screen);
|
||||||
|
+ mSecurityCategory = screen.findPreference(PREF_KEY_SECURITY_CATEGORY);
|
||||||
|
+ updatePreferenceState();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public boolean isAvailable() {
|
||||||
|
+ mIsAdmin = mUm.isAdminUser();
|
||||||
|
+ return mIsAdmin;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public String getPreferenceKey() {
|
||||||
|
+ return KEY_AUTO_REBOOT;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ // TODO: should we use onCreatePreferences() instead?
|
||||||
|
+ private void updatePreferenceState() {
|
||||||
|
+ if (mSecurityCategory == null) {
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (mIsAdmin) {
|
||||||
|
+ ListPreference autoReboot =
|
||||||
|
+ (ListPreference) mSecurityCategory.findPreference(KEY_AUTO_REBOOT);
|
||||||
|
+ autoReboot.setValue(Long.toString(Settings.Global.getLong(
|
||||||
|
+ mContext.getContentResolver(), Settings.Global.SETTINGS_REBOOT_AFTER_TIMEOUT, 0)));
|
||||||
|
+ } else {
|
||||||
|
+ mSecurityCategory.removePreference(
|
||||||
|
+ mSecurityCategory.findPreference(KEY_AUTO_REBOOT));
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public void onResume() {
|
||||||
|
+ updatePreferenceState();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public boolean onPreferenceChange(Preference preference, Object value) {
|
||||||
|
+ final String key = preference.getKey();
|
||||||
|
+ if (KEY_AUTO_REBOOT.equals(key) && mIsAdmin) {
|
||||||
|
+ long timeout = Long.parseLong((String) value);
|
||||||
|
+ Settings.Global.putLong(mContext.getContentResolver(), Settings.Global.SETTINGS_REBOOT_AFTER_TIMEOUT, timeout);
|
||||||
|
+ }
|
||||||
|
+ return true;
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
diff --git a/src/com/android/settings/security/SecuritySettings.java b/src/com/android/settings/security/SecuritySettings.java
|
||||||
|
index ecf3359e20..b5d7814e4a 100644
|
||||||
|
--- a/src/com/android/settings/security/SecuritySettings.java
|
||||||
|
+++ b/src/com/android/settings/security/SecuritySettings.java
|
||||||
|
@@ -120,6 +120,7 @@ public class SecuritySettings extends DashboardFragment {
|
||||||
|
securityPreferenceControllers.add(new FaceStatusPreferenceController(context));
|
||||||
|
securityPreferenceControllers.add(new FingerprintStatusPreferenceController(context));
|
||||||
|
securityPreferenceControllers.add(new ChangeScreenLockPreferenceController(context, host));
|
||||||
|
+ securityPreferenceControllers.add(new AutoRebootPreferenceController(context));
|
||||||
|
controllers.add(new PreferenceCategoryController(context, SECURITY_CATEGORY)
|
||||||
|
.setChildren(securityPreferenceControllers));
|
||||||
|
controllers.addAll(securityPreferenceControllers);
|
@ -0,0 +1,238 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Oliver Scott <olivercscott@gmail.com>
|
||||||
|
Date: Fri, 2 Oct 2020 12:37:30 -0400
|
||||||
|
Subject: [PATCH] add bluetooth auto-turn-off setting
|
||||||
|
|
||||||
|
---
|
||||||
|
res/values/arrays.xml | 44 +++++++
|
||||||
|
res/values/strings.xml | 19 +++
|
||||||
|
res/xml/connected_devices.xml | 8 ++
|
||||||
|
.../BluetoothTimeoutPreferenceController.java | 115 ++++++++++++++++++
|
||||||
|
4 files changed, 186 insertions(+)
|
||||||
|
create mode 100644 src/com/android/settings/bluetooth/BluetoothTimeoutPreferenceController.java
|
||||||
|
|
||||||
|
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
|
||||||
|
index 5813bb18db..40d01907a4 100644
|
||||||
|
--- a/res/values/arrays.xml
|
||||||
|
+++ b/res/values/arrays.xml
|
||||||
|
@@ -39,6 +39,50 @@
|
||||||
|
<item>All</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
+ <!-- Bluetooth settings. The delay in inactivity before bluetooth is turned off. These are shown in a list dialog. -->
|
||||||
|
+ <string-array name="bluetooth_timeout_entries">
|
||||||
|
+ <item>@string/bluetooth_timeout_summary_never</item>
|
||||||
|
+ <item>@string/bluetooth_timeout_summary_15secs</item>
|
||||||
|
+ <item>@string/bluetooth_timeout_summary_30secs</item>
|
||||||
|
+ <item>@string/bluetooth_timeout_summary_1min</item>
|
||||||
|
+ <item>@string/bluetooth_timeout_summary_2mins</item>
|
||||||
|
+ <item>@string/bluetooth_timeout_summary_5mins</item>
|
||||||
|
+ <item>@string/bluetooth_timeout_summary_10mins</item>
|
||||||
|
+ <item>@string/bluetooth_timeout_summary_30mins</item>
|
||||||
|
+ <item>@string/bluetooth_timeout_summary_1hour</item>
|
||||||
|
+ <item>@string/bluetooth_timeout_summary_2hours</item>
|
||||||
|
+ <item>@string/bluetooth_timeout_summary_4hours</item>
|
||||||
|
+ <item>@string/bluetooth_timeout_summary_8hours</item>
|
||||||
|
+ </string-array>
|
||||||
|
+
|
||||||
|
+ <!-- Do not translate. -->
|
||||||
|
+ <string-array name="bluetooth_timeout_values" translatable="false">
|
||||||
|
+ <!-- Do not translate. -->
|
||||||
|
+ <item>0</item>
|
||||||
|
+ <!-- Do not translate. -->
|
||||||
|
+ <item>15000</item>
|
||||||
|
+ <!-- Do not translate. -->
|
||||||
|
+ <item>30000</item>
|
||||||
|
+ <!-- Do not translate. -->
|
||||||
|
+ <item>60000</item>
|
||||||
|
+ <!-- Do not translate. -->
|
||||||
|
+ <item>120000</item>
|
||||||
|
+ <!-- Do not translate. -->
|
||||||
|
+ <item>300000</item>
|
||||||
|
+ <!-- Do not translate. -->
|
||||||
|
+ <item>600000</item>
|
||||||
|
+ <!-- Do not translate. -->
|
||||||
|
+ <item>1800000</item>
|
||||||
|
+ <!-- Do not translate. -->
|
||||||
|
+ <item>3600000</item>
|
||||||
|
+ <!-- Do not translate. -->
|
||||||
|
+ <item>7200000</item>
|
||||||
|
+ <!-- Do not translate. -->
|
||||||
|
+ <item>14400000</item>
|
||||||
|
+ <!-- Do not translate. -->
|
||||||
|
+ <item>28800000</item>
|
||||||
|
+ </string-array>
|
||||||
|
+
|
||||||
|
<!-- Display settings. The delay in inactivity before the screen is turned off. These are shown in a list dialog. -->
|
||||||
|
<string-array name="screen_timeout_entries">
|
||||||
|
<item>15 seconds</item>
|
||||||
|
diff --git a/res/values/strings.xml b/res/values/strings.xml
|
||||||
|
index eeee1c039f..c5287c4489 100644
|
||||||
|
--- a/res/values/strings.xml
|
||||||
|
+++ b/res/values/strings.xml
|
||||||
|
@@ -25,6 +25,25 @@
|
||||||
|
<!-- Strings for Dialog deny button -->
|
||||||
|
<string name="deny">Deny</string>
|
||||||
|
|
||||||
|
+ <!-- Connected devices screen, setting option name to change bluetooth timeout -->
|
||||||
|
+ <string name="bluetooth_timeout">Bluetooth timeout</string>
|
||||||
|
+
|
||||||
|
+ <!-- Connected devices screen, setting option summary to change bluetooth timeout -->
|
||||||
|
+ <string name="bluetooth_timeout_summary">Bluetooth will turn off after <xliff:g id="timeout_description">%1$s</xliff:g> if no devices connected</string>
|
||||||
|
+ <string name="bluetooth_timeout_summary2">Do not automatically turn off Bluetooth</string>
|
||||||
|
+ <string name="bluetooth_timeout_summary_never">Never</string>
|
||||||
|
+ <string name="bluetooth_timeout_summary_15secs">15 seconds</string>
|
||||||
|
+ <string name="bluetooth_timeout_summary_30secs">30 seconds</string>
|
||||||
|
+ <string name="bluetooth_timeout_summary_1min">1 minute</string>
|
||||||
|
+ <string name="bluetooth_timeout_summary_2mins">2 minutes</string>
|
||||||
|
+ <string name="bluetooth_timeout_summary_5mins">5 minutes</string>
|
||||||
|
+ <string name="bluetooth_timeout_summary_10mins">10 minutes</string>
|
||||||
|
+ <string name="bluetooth_timeout_summary_30mins">30 minutes</string>
|
||||||
|
+ <string name="bluetooth_timeout_summary_1hour">1 hour</string>
|
||||||
|
+ <string name="bluetooth_timeout_summary_2hours">2 hours</string>
|
||||||
|
+ <string name="bluetooth_timeout_summary_4hours">4 hours</string>
|
||||||
|
+ <string name="bluetooth_timeout_summary_8hours">8 hours</string>
|
||||||
|
+
|
||||||
|
<!-- Device Info screen. Used for a status item's value when the proper value is not known -->
|
||||||
|
<string name="device_info_default">Unknown</string>
|
||||||
|
<!-- [CHAR LIMIT=NONE] Device Info screen. Countdown for user taps to enable development settings -->
|
||||||
|
diff --git a/res/xml/connected_devices.xml b/res/xml/connected_devices.xml
|
||||||
|
index da55fe33f4..d0f9dcc507 100644
|
||||||
|
--- a/res/xml/connected_devices.xml
|
||||||
|
+++ b/res/xml/connected_devices.xml
|
||||||
|
@@ -52,6 +52,14 @@
|
||||||
|
settings:useAdminDisabledSummary="true"
|
||||||
|
settings:controller="com.android.settings.connecteddevice.AddDevicePreferenceController"/>
|
||||||
|
|
||||||
|
+ <androidx.preference.ListPreference
|
||||||
|
+ android:key="bluetooth_timeout"
|
||||||
|
+ android:title="@string/bluetooth_timeout"
|
||||||
|
+ android:summary="@string/summary_placeholder"
|
||||||
|
+ android:entries="@array/bluetooth_timeout_entries"
|
||||||
|
+ android:entryValues="@array/bluetooth_timeout_values"
|
||||||
|
+ settings:controller="com.android.settings.bluetooth.BluetoothTimeoutPreferenceController"/>
|
||||||
|
+
|
||||||
|
<PreferenceCategory
|
||||||
|
android:key="previously_connected_devices"
|
||||||
|
android:title="@string/connected_device_previously_connected_title"
|
||||||
|
diff --git a/src/com/android/settings/bluetooth/BluetoothTimeoutPreferenceController.java b/src/com/android/settings/bluetooth/BluetoothTimeoutPreferenceController.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000..244147948a
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/com/android/settings/bluetooth/BluetoothTimeoutPreferenceController.java
|
||||||
|
@@ -0,0 +1,115 @@
|
||||||
|
+/*
|
||||||
|
+ * Copyright (C) 2020 The Calyx Institute
|
||||||
|
+ *
|
||||||
|
+ * 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.bluetooth;
|
||||||
|
+
|
||||||
|
+import android.bluetooth.BluetoothAdapter;
|
||||||
|
+import android.content.Context;
|
||||||
|
+import android.provider.Settings;
|
||||||
|
+import android.util.Log;
|
||||||
|
+
|
||||||
|
+import androidx.preference.ListPreference;
|
||||||
|
+import androidx.preference.Preference;
|
||||||
|
+
|
||||||
|
+import com.android.settings.R;
|
||||||
|
+import com.android.settings.core.BasePreferenceController;
|
||||||
|
+import com.android.settings.core.PreferenceControllerMixin;
|
||||||
|
+
|
||||||
|
+public class BluetoothTimeoutPreferenceController extends BasePreferenceController implements
|
||||||
|
+ PreferenceControllerMixin, Preference.OnPreferenceChangeListener {
|
||||||
|
+ private static final String TAG = "BluetoothTimeoutPrefCtrl";
|
||||||
|
+
|
||||||
|
+ public static final int FALLBACK_BLUETOOTH_TIMEOUT_VALUE = 0;
|
||||||
|
+
|
||||||
|
+ private final String mBluetoothTimeoutKey;
|
||||||
|
+
|
||||||
|
+ protected BluetoothAdapter mBluetoothAdapter;
|
||||||
|
+
|
||||||
|
+ public BluetoothTimeoutPreferenceController(Context context, String key) {
|
||||||
|
+ super(context, key);
|
||||||
|
+ mBluetoothTimeoutKey = key;
|
||||||
|
+
|
||||||
|
+ mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
|
||||||
|
+ if (mBluetoothAdapter == null) {
|
||||||
|
+ Log.e(TAG, "Bluetooth is not supported on this device");
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public int getAvailabilityStatus() {
|
||||||
|
+ return mBluetoothAdapter != null ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public String getPreferenceKey() {
|
||||||
|
+ return mBluetoothTimeoutKey;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public void updateState(Preference preference) {
|
||||||
|
+ final ListPreference timeoutListPreference = (ListPreference) preference;
|
||||||
|
+ final long currentTimeout = Settings.Global.getLong(mContext.getContentResolver(),
|
||||||
|
+ Settings.Global.BLUETOOTH_OFF_TIMEOUT, FALLBACK_BLUETOOTH_TIMEOUT_VALUE);
|
||||||
|
+ timeoutListPreference.setValue(String.valueOf(currentTimeout));
|
||||||
|
+ updateTimeoutPreferenceDescription(timeoutListPreference,
|
||||||
|
+ Long.parseLong(timeoutListPreference.getValue()));
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
|
+ try {
|
||||||
|
+ long value = Long.parseLong((String) newValue);
|
||||||
|
+ Settings.Global.putLong(mContext.getContentResolver(), Settings.Global.BLUETOOTH_OFF_TIMEOUT, value);
|
||||||
|
+ updateTimeoutPreferenceDescription((ListPreference) preference, value);
|
||||||
|
+ } catch (NumberFormatException e) {
|
||||||
|
+ Log.e(TAG, "could not persist bluetooth timeout setting", e);
|
||||||
|
+ }
|
||||||
|
+ return true;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public static CharSequence getTimeoutDescription(
|
||||||
|
+ long currentTimeout, CharSequence[] entries, CharSequence[] values) {
|
||||||
|
+ if (currentTimeout < 0 || entries == null || values == null
|
||||||
|
+ || values.length != entries.length) {
|
||||||
|
+ return null;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ for (int i = 0; i < values.length; i++) {
|
||||||
|
+ long timeout = Long.parseLong(values[i].toString());
|
||||||
|
+ if (currentTimeout == timeout) {
|
||||||
|
+ return entries[i];
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ return null;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private void updateTimeoutPreferenceDescription(ListPreference preference,
|
||||||
|
+ long currentTimeout) {
|
||||||
|
+ final CharSequence[] entries = preference.getEntries();
|
||||||
|
+ final CharSequence[] values = preference.getEntryValues();
|
||||||
|
+ final CharSequence timeoutDescription = getTimeoutDescription(
|
||||||
|
+ currentTimeout, entries, values);
|
||||||
|
+ String summary = "";
|
||||||
|
+ if (timeoutDescription != null) {
|
||||||
|
+ if (currentTimeout != 0)
|
||||||
|
+ summary = mContext.getString(R.string.bluetooth_timeout_summary, timeoutDescription);
|
||||||
|
+ else
|
||||||
|
+ summary = mContext.getString(R.string.bluetooth_timeout_summary2);
|
||||||
|
+ }
|
||||||
|
+ preference.setSummary(summary);
|
||||||
|
+ }
|
||||||
|
+}
|
@ -0,0 +1,238 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Oliver Scott <olivercscott@gmail.com>
|
||||||
|
Date: Thu, 25 Feb 2021 11:31:14 -0500
|
||||||
|
Subject: [PATCH] add Wi-Fi timeout feature
|
||||||
|
|
||||||
|
---
|
||||||
|
res/values/arrays.xml | 44 +++++++
|
||||||
|
res/values/strings.xml | 19 +++
|
||||||
|
res/xml/wifi_configure_settings.xml | 8 ++
|
||||||
|
.../wifi/WifiTimeoutPreferenceController.java | 115 ++++++++++++++++++
|
||||||
|
4 files changed, 186 insertions(+)
|
||||||
|
create mode 100644 src/com/android/settings/wifi/WifiTimeoutPreferenceController.java
|
||||||
|
|
||||||
|
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
|
||||||
|
index 40d01907a4..0a9a9a31e8 100644
|
||||||
|
--- a/res/values/arrays.xml
|
||||||
|
+++ b/res/values/arrays.xml
|
||||||
|
@@ -83,6 +83,50 @@
|
||||||
|
<item>28800000</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
+ <!-- Wifi settings. The delay in inactivity before wifi is turned off. These are shown in a list dialog. -->
|
||||||
|
+ <string-array name="wifi_timeout_entries">
|
||||||
|
+ <item>@string/wifi_timeout_summary_never</item>
|
||||||
|
+ <item>@string/wifi_timeout_summary_15secs</item>
|
||||||
|
+ <item>@string/wifi_timeout_summary_30secs</item>
|
||||||
|
+ <item>@string/wifi_timeout_summary_1min</item>
|
||||||
|
+ <item>@string/wifi_timeout_summary_2mins</item>
|
||||||
|
+ <item>@string/wifi_timeout_summary_5mins</item>
|
||||||
|
+ <item>@string/wifi_timeout_summary_10mins</item>
|
||||||
|
+ <item>@string/wifi_timeout_summary_30mins</item>
|
||||||
|
+ <item>@string/wifi_timeout_summary_1hour</item>
|
||||||
|
+ <item>@string/wifi_timeout_summary_2hours</item>
|
||||||
|
+ <item>@string/wifi_timeout_summary_4hours</item>
|
||||||
|
+ <item>@string/wifi_timeout_summary_8hours</item>
|
||||||
|
+ </string-array>
|
||||||
|
+
|
||||||
|
+ <!-- Do not translate. -->
|
||||||
|
+ <string-array name="wifi_timeout_values" translatable="false">
|
||||||
|
+ <!-- Do not translate. -->
|
||||||
|
+ <item>0</item>
|
||||||
|
+ <!-- Do not translate. -->
|
||||||
|
+ <item>15000</item>
|
||||||
|
+ <!-- Do not translate. -->
|
||||||
|
+ <item>30000</item>
|
||||||
|
+ <!-- Do not translate. -->
|
||||||
|
+ <item>60000</item>
|
||||||
|
+ <!-- Do not translate. -->
|
||||||
|
+ <item>120000</item>
|
||||||
|
+ <!-- Do not translate. -->
|
||||||
|
+ <item>300000</item>
|
||||||
|
+ <!-- Do not translate. -->
|
||||||
|
+ <item>600000</item>
|
||||||
|
+ <!-- Do not translate. -->
|
||||||
|
+ <item>1800000</item>
|
||||||
|
+ <!-- Do not translate. -->
|
||||||
|
+ <item>3600000</item>
|
||||||
|
+ <!-- Do not translate. -->
|
||||||
|
+ <item>7200000</item>
|
||||||
|
+ <!-- Do not translate. -->
|
||||||
|
+ <item>14400000</item>
|
||||||
|
+ <!-- Do not translate. -->
|
||||||
|
+ <item>28800000</item>
|
||||||
|
+ </string-array>
|
||||||
|
+
|
||||||
|
<!-- Display settings. The delay in inactivity before the screen is turned off. These are shown in a list dialog. -->
|
||||||
|
<string-array name="screen_timeout_entries">
|
||||||
|
<item>15 seconds</item>
|
||||||
|
diff --git a/res/values/strings.xml b/res/values/strings.xml
|
||||||
|
index c5287c4489..0f254706ff 100644
|
||||||
|
--- a/res/values/strings.xml
|
||||||
|
+++ b/res/values/strings.xml
|
||||||
|
@@ -44,6 +44,25 @@
|
||||||
|
<string name="bluetooth_timeout_summary_4hours">4 hours</string>
|
||||||
|
<string name="bluetooth_timeout_summary_8hours">8 hours</string>
|
||||||
|
|
||||||
|
+ <!-- screen, setting option name to change wifi timeout -->
|
||||||
|
+ <string name="wifi_timeout">Turn off Wi-Fi automatically</string>
|
||||||
|
+
|
||||||
|
+ <!-- screen, setting option summary to change wifi timeout -->
|
||||||
|
+ <string name="wifi_timeout_summary">Wi-Fi will turn off after <xliff:g id="timeout_description">%1$s</xliff:g> if no network connected</string>
|
||||||
|
+ <string name="wifi_timeout_summary2">Disabled</string>
|
||||||
|
+ <string name="wifi_timeout_summary_never">Never</string>
|
||||||
|
+ <string name="wifi_timeout_summary_15secs">15 seconds</string>
|
||||||
|
+ <string name="wifi_timeout_summary_30secs">30 seconds</string>
|
||||||
|
+ <string name="wifi_timeout_summary_1min">1 minute</string>
|
||||||
|
+ <string name="wifi_timeout_summary_2mins">2 minutes</string>
|
||||||
|
+ <string name="wifi_timeout_summary_5mins">5 minutes</string>
|
||||||
|
+ <string name="wifi_timeout_summary_10mins">10 minutes</string>
|
||||||
|
+ <string name="wifi_timeout_summary_30mins">30 minutes</string>
|
||||||
|
+ <string name="wifi_timeout_summary_1hour">1 hour</string>
|
||||||
|
+ <string name="wifi_timeout_summary_2hours">2 hours</string>
|
||||||
|
+ <string name="wifi_timeout_summary_4hours">4 hours</string>
|
||||||
|
+ <string name="wifi_timeout_summary_8hours">8 hours</string>
|
||||||
|
+
|
||||||
|
<!-- Device Info screen. Used for a status item's value when the proper value is not known -->
|
||||||
|
<string name="device_info_default">Unknown</string>
|
||||||
|
<!-- [CHAR LIMIT=NONE] Device Info screen. Countdown for user taps to enable development settings -->
|
||||||
|
diff --git a/res/xml/wifi_configure_settings.xml b/res/xml/wifi_configure_settings.xml
|
||||||
|
index c6214662d3..27e913949e 100644
|
||||||
|
--- a/res/xml/wifi_configure_settings.xml
|
||||||
|
+++ b/res/xml/wifi_configure_settings.xml
|
||||||
|
@@ -26,6 +26,14 @@
|
||||||
|
android:icon="@drawable/ic_auto_wifi"
|
||||||
|
android:summary="@string/wifi_wakeup_summary" />
|
||||||
|
|
||||||
|
+ <ListPreference
|
||||||
|
+ android:key="wifi_timeout"
|
||||||
|
+ android:title="@string/wifi_timeout"
|
||||||
|
+ android:summary="@string/wifi_timeout_summary"
|
||||||
|
+ android:entries="@array/wifi_timeout_entries"
|
||||||
|
+ android:entryValues="@array/wifi_timeout_values"
|
||||||
|
+ settings:controller="com.android.settings.wifi.WifiTimeoutPreferenceController"/>
|
||||||
|
+
|
||||||
|
<SwitchPreference
|
||||||
|
android:key="use_open_wifi_automatically"
|
||||||
|
android:icon="@drawable/ic_open_wifi_autoconnect"
|
||||||
|
diff --git a/src/com/android/settings/wifi/WifiTimeoutPreferenceController.java b/src/com/android/settings/wifi/WifiTimeoutPreferenceController.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000..7116c90519
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/com/android/settings/wifi/WifiTimeoutPreferenceController.java
|
||||||
|
@@ -0,0 +1,115 @@
|
||||||
|
+/*
|
||||||
|
+ * Copyright (C) 2020 The Calyx Institute
|
||||||
|
+ *
|
||||||
|
+ * 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.wifi;
|
||||||
|
+
|
||||||
|
+import android.content.Context;
|
||||||
|
+import android.net.wifi.WifiManager;
|
||||||
|
+import android.provider.Settings;
|
||||||
|
+import android.util.Log;
|
||||||
|
+
|
||||||
|
+import androidx.preference.ListPreference;
|
||||||
|
+import androidx.preference.Preference;
|
||||||
|
+
|
||||||
|
+import com.android.settings.R;
|
||||||
|
+import com.android.settings.core.BasePreferenceController;
|
||||||
|
+import com.android.settings.core.PreferenceControllerMixin;
|
||||||
|
+
|
||||||
|
+public class WifiTimeoutPreferenceController extends BasePreferenceController implements
|
||||||
|
+ PreferenceControllerMixin, Preference.OnPreferenceChangeListener {
|
||||||
|
+ private static final String TAG = "WifiTimeoutPrefCtrl";
|
||||||
|
+
|
||||||
|
+ public static final int FALLBACK_WIFI_TIMEOUT_VALUE = 0;
|
||||||
|
+
|
||||||
|
+ private final String mWifiTimeoutKey;
|
||||||
|
+
|
||||||
|
+ protected WifiManager mWifiManager;
|
||||||
|
+
|
||||||
|
+ public WifiTimeoutPreferenceController(Context context, String key) {
|
||||||
|
+ super(context, key);
|
||||||
|
+ mWifiTimeoutKey = key;
|
||||||
|
+
|
||||||
|
+ mWifiManager = context.getSystemService(WifiManager.class);
|
||||||
|
+ if (mWifiManager == null) {
|
||||||
|
+ Log.e(TAG, "Wifi is not supported on this device");
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public int getAvailabilityStatus() {
|
||||||
|
+ return mWifiManager != null ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public String getPreferenceKey() {
|
||||||
|
+ return mWifiTimeoutKey;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public void updateState(Preference preference) {
|
||||||
|
+ final ListPreference timeoutListPreference = (ListPreference) preference;
|
||||||
|
+ final long currentTimeout = Settings.Global.getLong(mContext.getContentResolver(),
|
||||||
|
+ Settings.Global.WIFI_OFF_TIMEOUT, FALLBACK_WIFI_TIMEOUT_VALUE);
|
||||||
|
+ timeoutListPreference.setValue(String.valueOf(currentTimeout));
|
||||||
|
+ updateTimeoutPreferenceDescription(timeoutListPreference,
|
||||||
|
+ Long.parseLong(timeoutListPreference.getValue()));
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
|
+ try {
|
||||||
|
+ long value = Long.parseLong((String) newValue);
|
||||||
|
+ Settings.Global.putLong(mContext.getContentResolver(), Settings.Global.WIFI_OFF_TIMEOUT, value);
|
||||||
|
+ updateTimeoutPreferenceDescription((ListPreference) preference, value);
|
||||||
|
+ } catch (NumberFormatException e) {
|
||||||
|
+ Log.e(TAG, "could not persist wifi timeout setting", e);
|
||||||
|
+ }
|
||||||
|
+ return true;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public static CharSequence getTimeoutDescription(
|
||||||
|
+ long currentTimeout, CharSequence[] entries, CharSequence[] values) {
|
||||||
|
+ if (currentTimeout < 0 || entries == null || values == null
|
||||||
|
+ || values.length != entries.length) {
|
||||||
|
+ return null;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ for (int i = 0; i < values.length; i++) {
|
||||||
|
+ long timeout = Long.parseLong(values[i].toString());
|
||||||
|
+ if (currentTimeout == timeout) {
|
||||||
|
+ return entries[i];
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ return null;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private void updateTimeoutPreferenceDescription(ListPreference preference,
|
||||||
|
+ long currentTimeout) {
|
||||||
|
+ final CharSequence[] entries = preference.getEntries();
|
||||||
|
+ final CharSequence[] values = preference.getEntryValues();
|
||||||
|
+ final CharSequence timeoutDescription = getTimeoutDescription(
|
||||||
|
+ currentTimeout, entries, values);
|
||||||
|
+ String summary = "";
|
||||||
|
+ if (timeoutDescription != null) {
|
||||||
|
+ if (currentTimeout != 0)
|
||||||
|
+ summary = mContext.getString(R.string.wifi_timeout_summary, timeoutDescription);
|
||||||
|
+ else
|
||||||
|
+ summary = mContext.getString(R.string.wifi_timeout_summary2);
|
||||||
|
+ }
|
||||||
|
+ preference.setSummary(summary);
|
||||||
|
+ }
|
||||||
|
+}
|
@ -0,0 +1,151 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: anupritaisno1 <www.anuprita804@gmail.com>
|
||||||
|
Date: Mon, 7 Jun 2021 22:04:53 +0100
|
||||||
|
Subject: [PATCH] automatically reboot device after timeout if set
|
||||||
|
|
||||||
|
---
|
||||||
|
core/java/android/provider/Settings.java | 7 ++++
|
||||||
|
data/etc/com.android.systemui.xml | 1 +
|
||||||
|
packages/SystemUI/AndroidManifest.xml | 3 ++
|
||||||
|
.../keyguard/KeyguardViewMediator.java | 35 +++++++++++++++++++
|
||||||
|
4 files changed, 46 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
|
||||||
|
index fe61bc37d224..0ac089362b92 100755
|
||||||
|
--- a/core/java/android/provider/Settings.java
|
||||||
|
+++ b/core/java/android/provider/Settings.java
|
||||||
|
@@ -14473,6 +14473,13 @@ public final class Settings {
|
||||||
|
*/
|
||||||
|
public static final String NR_NSA_TRACKING_SCREEN_OFF_MODE =
|
||||||
|
"nr_nsa_tracking_screen_off_mode";
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Whether to automatically reboot the device after a user defined timeout
|
||||||
|
+ *
|
||||||
|
+ * @hide
|
||||||
|
+ */
|
||||||
|
+ public static final String SETTINGS_REBOOT_AFTER_TIMEOUT = "settings_reboot_after_timeout";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
diff --git a/data/etc/com.android.systemui.xml b/data/etc/com.android.systemui.xml
|
||||||
|
index 7af1de6a6cac..ef57436f4c45 100644
|
||||||
|
--- a/data/etc/com.android.systemui.xml
|
||||||
|
+++ b/data/etc/com.android.systemui.xml
|
||||||
|
@@ -49,6 +49,7 @@
|
||||||
|
<permission name="android.permission.READ_NETWORK_USAGE_HISTORY"/>
|
||||||
|
<permission name="android.permission.READ_PRIVILEGED_PHONE_STATE"/>
|
||||||
|
<permission name="android.permission.REAL_GET_TASKS"/>
|
||||||
|
+ <permission name="android.permission.REBOOT"/>
|
||||||
|
<permission name="android.permission.REQUEST_NETWORK_SCORES"/>
|
||||||
|
<permission name="android.permission.RECEIVE_MEDIA_RESOURCE_USAGE"/>
|
||||||
|
<permission name="android.permission.START_ACTIVITIES_FROM_BACKGROUND" />
|
||||||
|
diff --git a/packages/SystemUI/AndroidManifest.xml b/packages/SystemUI/AndroidManifest.xml
|
||||||
|
index cf0607449054..7bf662b86a52 100644
|
||||||
|
--- a/packages/SystemUI/AndroidManifest.xml
|
||||||
|
+++ b/packages/SystemUI/AndroidManifest.xml
|
||||||
|
@@ -275,6 +275,9 @@
|
||||||
|
<!-- Permission to make accessibility service access Bubbles -->
|
||||||
|
<uses-permission android:name="android.permission.ADD_TRUSTED_DISPLAY" />
|
||||||
|
|
||||||
|
+ <!-- Permission to allow rebooting the device after a user configurable amount of time -->
|
||||||
|
+ <uses-permission android:name="android.permission.REBOOT" />
|
||||||
|
+
|
||||||
|
|
||||||
|
<protected-broadcast android:name="com.android.settingslib.action.REGISTER_SLICE_RECEIVER" />
|
||||||
|
<protected-broadcast android:name="com.android.settingslib.action.UNREGISTER_SLICE_RECEIVER" />
|
||||||
|
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
|
||||||
|
index 3eb5de9289e7..2b1857364d57 100644
|
||||||
|
--- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
|
||||||
|
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
|
||||||
|
@@ -163,6 +163,8 @@ public class KeyguardViewMediator extends SystemUI implements Dumpable {
|
||||||
|
|
||||||
|
private final static String TAG = "KeyguardViewMediator";
|
||||||
|
|
||||||
|
+ private static final String DELAYED_REBOOT_ACTION =
|
||||||
|
+ "com.android.internal.policy.impl.PhoneWindowManager.DELAYED_REBOOT";
|
||||||
|
private static final String DELAYED_KEYGUARD_ACTION =
|
||||||
|
"com.android.internal.policy.impl.PhoneWindowManager.DELAYED_KEYGUARD";
|
||||||
|
private static final String DELAYED_LOCK_PROFILE_ACTION =
|
||||||
|
@@ -283,6 +285,11 @@ public class KeyguardViewMediator extends SystemUI implements Dumpable {
|
||||||
|
*/
|
||||||
|
private int mDelayedProfileShowingSequence;
|
||||||
|
|
||||||
|
+ /**
|
||||||
|
+ * Same as {@link #mDelayedProfileShowingSequence}, but used for our reboot implementation
|
||||||
|
+ */
|
||||||
|
+ private int mDelayedRebootSequence;
|
||||||
|
+
|
||||||
|
/**
|
||||||
|
* If the user has disabled the keyguard, then requests to exit, this is
|
||||||
|
* how we'll ultimately let them know whether it was successful. We use this
|
||||||
|
@@ -783,6 +790,7 @@ public class KeyguardViewMediator extends SystemUI implements Dumpable {
|
||||||
|
final IntentFilter delayedActionFilter = new IntentFilter();
|
||||||
|
delayedActionFilter.addAction(DELAYED_KEYGUARD_ACTION);
|
||||||
|
delayedActionFilter.addAction(DELAYED_LOCK_PROFILE_ACTION);
|
||||||
|
+ delayedActionFilter.addAction(DELAYED_REBOOT_ACTION);
|
||||||
|
mContext.registerReceiver(mDelayedLockBroadcastReceiver, delayedActionFilter,
|
||||||
|
SYSTEMUI_PERMISSION, null /* scheduler */);
|
||||||
|
|
||||||
|
@@ -1056,6 +1064,18 @@ public class KeyguardViewMediator extends SystemUI implements Dumpable {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
+ private void doRebootForOwnerAfterTimeoutIfEnabled(long rebootAfterTimeout) {
|
||||||
|
+ long when = SystemClock.elapsedRealtime() + rebootAfterTimeout;
|
||||||
|
+ Intent rebootIntent = new Intent(DELAYED_REBOOT_ACTION);
|
||||||
|
+ rebootIntent.putExtra("seq", mDelayedRebootSequence);
|
||||||
|
+ rebootIntent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
|
||||||
|
+ PendingIntent sender = PendingIntent.getBroadcast(mContext,
|
||||||
|
+ 0, rebootIntent, PendingIntent.FLAG_CANCEL_CURRENT);
|
||||||
|
+ mAlarmManager.setExactAndAllowWhileIdle(AlarmManager.ELAPSED_REALTIME_WAKEUP, when, sender);
|
||||||
|
+ if (DEBUG) Log.d(TAG, "setting alarm to reboot device, timeout = "
|
||||||
|
+ + String.valueOf(rebootAfterTimeout));
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
private void doKeyguardForChildProfilesLocked() {
|
||||||
|
UserManager um = UserManager.get(mContext);
|
||||||
|
for (int profileId : um.getEnabledProfileIds(UserHandle.myUserId())) {
|
||||||
|
@@ -1073,6 +1093,10 @@ public class KeyguardViewMediator extends SystemUI implements Dumpable {
|
||||||
|
mDelayedProfileShowingSequence++;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ private void cancelDoRebootForOwnerAfterTimeoutIfEnabled() {
|
||||||
|
+ mDelayedRebootSequence++;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
/**
|
||||||
|
* Let's us know when the device is waking up.
|
||||||
|
*/
|
||||||
|
@@ -1451,6 +1475,10 @@ public class KeyguardViewMediator extends SystemUI implements Dumpable {
|
||||||
|
|
||||||
|
if (DEBUG) Log.d(TAG, "doKeyguard: showing the lock screen");
|
||||||
|
showLocked(options);
|
||||||
|
+ final long rebootAfterTimeout = Settings.Global.getLong(mContext.getContentResolver(), Settings.Global.SETTINGS_REBOOT_AFTER_TIMEOUT, 0);
|
||||||
|
+ if (rebootAfterTimeout >= 1) {
|
||||||
|
+ doRebootForOwnerAfterTimeoutIfEnabled(rebootAfterTimeout);
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
|
||||||
|
private void lockProfile(int userId) {
|
||||||
|
@@ -1611,6 +1639,12 @@ public class KeyguardViewMediator extends SystemUI implements Dumpable {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
+ } else if (DELAYED_REBOOT_ACTION.equals(intent.getAction())) {
|
||||||
|
+ final int sequence = intent.getIntExtra("seq", 0);
|
||||||
|
+ if (sequence == mDelayedRebootSequence) {
|
||||||
|
+ PowerManager pm = mContext.getSystemService(PowerManager.class);
|
||||||
|
+ pm.reboot(null);
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
@@ -2041,6 +2075,7 @@ public class KeyguardViewMediator extends SystemUI implements Dumpable {
|
||||||
|
mHideAnimationRun = false;
|
||||||
|
adjustStatusBarLocked();
|
||||||
|
sendUserPresentBroadcast();
|
||||||
|
+ cancelDoRebootForOwnerAfterTimeoutIfEnabled();
|
||||||
|
}
|
||||||
|
Trace.endSection();
|
||||||
|
}
|
@ -0,0 +1,121 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: pratyush <codelab@pratyush.dev>
|
||||||
|
Date: Thu, 1 Jul 2021 12:26:49 +0530
|
||||||
|
Subject: [PATCH] Bluetooth auto turn off
|
||||||
|
|
||||||
|
---
|
||||||
|
core/java/android/provider/Settings.java | 6 ++
|
||||||
|
.../server/BluetoothManagerService.java | 76 +++++++++++++++++++
|
||||||
|
2 files changed, 82 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
|
||||||
|
index 0ac089362b92..d7e3e8f13acd 100755
|
||||||
|
--- a/core/java/android/provider/Settings.java
|
||||||
|
+++ b/core/java/android/provider/Settings.java
|
||||||
|
@@ -14474,6 +14474,12 @@ public final class Settings {
|
||||||
|
public static final String NR_NSA_TRACKING_SCREEN_OFF_MODE =
|
||||||
|
"nr_nsa_tracking_screen_off_mode";
|
||||||
|
|
||||||
|
+ /**
|
||||||
|
+ * The amount of time in milliseconds before bluetooth is turned off
|
||||||
|
+ * @hide
|
||||||
|
+ */
|
||||||
|
+ public static final String BLUETOOTH_OFF_TIMEOUT = "bluetooth_off_timeout";
|
||||||
|
+
|
||||||
|
/**
|
||||||
|
* Whether to automatically reboot the device after a user defined timeout
|
||||||
|
*
|
||||||
|
diff --git a/services/core/java/com/android/server/BluetoothManagerService.java b/services/core/java/com/android/server/BluetoothManagerService.java
|
||||||
|
index 9ce7cf27f9ff..9598faa3a667 100644
|
||||||
|
--- a/services/core/java/com/android/server/BluetoothManagerService.java
|
||||||
|
+++ b/services/core/java/com/android/server/BluetoothManagerService.java
|
||||||
|
@@ -21,6 +21,7 @@ import static android.os.UserHandle.USER_SYSTEM;
|
||||||
|
|
||||||
|
import android.Manifest;
|
||||||
|
import android.app.ActivityManager;
|
||||||
|
+import android.app.AlarmManager;
|
||||||
|
import android.app.AppGlobals;
|
||||||
|
import android.app.AppOpsManager;
|
||||||
|
import android.bluetooth.BluetoothAdapter;
|
||||||
|
@@ -512,6 +513,81 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
|
||||||
|
Slog.w(TAG, "Unable to resolve SystemUI's UID.");
|
||||||
|
}
|
||||||
|
mSystemUiUid = systemUiUid;
|
||||||
|
+
|
||||||
|
+ /*
|
||||||
|
+ * System sends ACTION_STATE_CHANGED broadcast soon as any state
|
||||||
|
+ * changes. what it means in action is we don't have to take care if
|
||||||
|
+ * device reboot while BT has not been turned off automatically.
|
||||||
|
+ *
|
||||||
|
+ * A word of warning though it does not check if device as been
|
||||||
|
+ * unlocked or not what it means in real life is if you have sometime
|
||||||
|
+ * like tile ble tracker configured it will turn off BT. As result tile
|
||||||
|
+ * tracking will fail because of auto timeout. this behaviour can be
|
||||||
|
+ * changed with UserManager.isUnlocked()
|
||||||
|
+ * */
|
||||||
|
+ IntentFilter btFilter = new IntentFilter();
|
||||||
|
+ btFilter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);
|
||||||
|
+ btFilter.addAction(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED);
|
||||||
|
+ btFilter.addAction(BluetoothAdapter.ACTION_LOCAL_NAME_CHANGED);
|
||||||
|
+ context.registerReceiver(new BroadcastReceiver() {
|
||||||
|
+ @Override
|
||||||
|
+ public void onReceive(Context broadcastContext, Intent intent) {
|
||||||
|
+ reconfigureBtTimeoutListener();
|
||||||
|
+ }
|
||||||
|
+ }, btFilter);
|
||||||
|
+
|
||||||
|
+ context.getContentResolver().registerContentObserver(
|
||||||
|
+ Settings.Global.getUriFor(Settings.Global.BLUETOOTH_OFF_TIMEOUT),
|
||||||
|
+ false,
|
||||||
|
+ new ContentObserver(new Handler(context.getMainLooper())) {
|
||||||
|
+ @Override
|
||||||
|
+ public void onChange(boolean selfChange) {
|
||||||
|
+ super.onChange(selfChange);
|
||||||
|
+ reconfigureBtTimeoutListener();
|
||||||
|
+ }
|
||||||
|
+ });
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private static final AlarmManager.OnAlarmListener listener = () -> {
|
||||||
|
+ BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
|
||||||
|
+ if (isBtOnAndDisconnected() && bluetoothAdapter != null) {
|
||||||
|
+ bluetoothAdapter.disable();
|
||||||
|
+ }
|
||||||
|
+ };
|
||||||
|
+
|
||||||
|
+ // If device is still connected cancel timeout for now and wait for disconnected signal
|
||||||
|
+ private void reconfigureBtTimeoutListener() {
|
||||||
|
+ AlarmManager alarmManager = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE);
|
||||||
|
+ if (isTimeoutEnabled(mContext) && isBtOnAndDisconnected()) {
|
||||||
|
+ final long timeout = SystemClock.elapsedRealtime() + btTimeoutDurationInMilli(mContext);
|
||||||
|
+ alarmManager.cancel(listener);
|
||||||
|
+ alarmManager.setExact(
|
||||||
|
+ AlarmManager.ELAPSED_REALTIME_WAKEUP,
|
||||||
|
+ timeout,
|
||||||
|
+ "BT Idle Timeout",
|
||||||
|
+ listener,
|
||||||
|
+ new Handler(mContext.getMainLooper())
|
||||||
|
+ );
|
||||||
|
+ } else {
|
||||||
|
+ alarmManager.cancel(listener);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private static boolean isBtOnAndDisconnected() {
|
||||||
|
+ BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
|
||||||
|
+ return bluetoothAdapter != null && bluetoothAdapter.getState() == BluetoothAdapter.STATE_ON
|
||||||
|
+ && bluetoothAdapter.getState() == BluetoothAdapter.STATE_ON &&
|
||||||
|
+ bluetoothAdapter.getConnectionState() == BluetoothAdapter.STATE_DISCONNECTED;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private static long btTimeoutDurationInMilli(Context context) {
|
||||||
|
+ return Settings.Global.getLong(context.getContentResolver(),
|
||||||
|
+ Settings.Global.BLUETOOTH_OFF_TIMEOUT, 0);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /** Zero is default and means disabled */
|
||||||
|
+ private static boolean isTimeoutEnabled(Context context) {
|
||||||
|
+ return 0 != btTimeoutDurationInMilli(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
@ -0,0 +1,124 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Pratyush <codelab@pratyush.dev>
|
||||||
|
Date: Tue, 6 Jul 2021 18:18:06 +0530
|
||||||
|
Subject: [PATCH] Wi-Fi auto turn off
|
||||||
|
|
||||||
|
---
|
||||||
|
core/java/android/provider/Settings.java | 6 ++
|
||||||
|
.../server/net/NetworkStatsService.java | 70 +++++++++++++++++++
|
||||||
|
2 files changed, 76 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
|
||||||
|
index d7e3e8f13acd..367c57526fe5 100755
|
||||||
|
--- a/core/java/android/provider/Settings.java
|
||||||
|
+++ b/core/java/android/provider/Settings.java
|
||||||
|
@@ -14480,6 +14480,12 @@ public final class Settings {
|
||||||
|
*/
|
||||||
|
public static final String BLUETOOTH_OFF_TIMEOUT = "bluetooth_off_timeout";
|
||||||
|
|
||||||
|
+ /**
|
||||||
|
+ * The amount of time in milliseconds before Wi-Fi is turned off
|
||||||
|
+ * @hide
|
||||||
|
+ */
|
||||||
|
+ public static final String WIFI_OFF_TIMEOUT = "wifi_off_timeout";
|
||||||
|
+
|
||||||
|
/**
|
||||||
|
* Whether to automatically reboot the device after a user defined timeout
|
||||||
|
*
|
||||||
|
diff --git a/services/core/java/com/android/server/net/NetworkStatsService.java b/services/core/java/com/android/server/net/NetworkStatsService.java
|
||||||
|
index ba9f486092f7..24cba592a59d 100644
|
||||||
|
--- a/services/core/java/com/android/server/net/NetworkStatsService.java
|
||||||
|
+++ b/services/core/java/com/android/server/net/NetworkStatsService.java
|
||||||
|
@@ -87,6 +87,7 @@ import android.content.Intent;
|
||||||
|
import android.content.IntentFilter;
|
||||||
|
import android.content.pm.ApplicationInfo;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
+import android.database.ContentObserver;
|
||||||
|
import android.net.DataUsageRequest;
|
||||||
|
import android.net.INetworkManagementEventObserver;
|
||||||
|
import android.net.INetworkStatsService;
|
||||||
|
@@ -106,8 +107,10 @@ import android.net.TrafficStats;
|
||||||
|
import android.net.netstats.provider.INetworkStatsProvider;
|
||||||
|
import android.net.netstats.provider.INetworkStatsProviderCallback;
|
||||||
|
import android.net.netstats.provider.NetworkStatsProvider;
|
||||||
|
+import android.net.wifi.WifiManager;
|
||||||
|
import android.os.BestClock;
|
||||||
|
import android.os.Binder;
|
||||||
|
+import android.os.Bundle;
|
||||||
|
import android.os.DropBoxManager;
|
||||||
|
import android.os.Environment;
|
||||||
|
import android.os.Handler;
|
||||||
|
@@ -438,6 +441,73 @@ public class NetworkStatsService extends INetworkStatsService.Stub {
|
||||||
|
mHandler = new NetworkStatsHandler(handlerThread.getLooper());
|
||||||
|
mNetworkStatsSubscriptionsMonitor = deps.makeSubscriptionsMonitor(mContext,
|
||||||
|
new HandlerExecutor(mHandler), this);
|
||||||
|
+
|
||||||
|
+ IntentFilter wifiFilter = new IntentFilter();
|
||||||
|
+ wifiFilter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
|
||||||
|
+ wifiFilter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION);
|
||||||
|
+
|
||||||
|
+ context.registerReceiver(
|
||||||
|
+ new BroadcastReceiver() {
|
||||||
|
+ @Override
|
||||||
|
+ public void onReceive(Context context, Intent intent) {
|
||||||
|
+ if (WifiManager.NETWORK_STATE_CHANGED_ACTION.equals(intent.getAction())) {
|
||||||
|
+ Bundle bundle = intent.getExtras();
|
||||||
|
+ NetworkInfo networkInfo = bundle.getParcelable(WifiManager.EXTRA_NETWORK_INFO);
|
||||||
|
+ isWifiConnected = networkInfo != null && networkInfo.isConnected();
|
||||||
|
+ }
|
||||||
|
+ reconfigureWiFiTimeoutListener();
|
||||||
|
+ }
|
||||||
|
+ }, wifiFilter
|
||||||
|
+ );
|
||||||
|
+
|
||||||
|
+ context.getContentResolver().registerContentObserver(
|
||||||
|
+ Global.getUriFor(Global.WIFI_OFF_TIMEOUT),
|
||||||
|
+ false,
|
||||||
|
+ new ContentObserver(new Handler(context.getMainLooper())) {
|
||||||
|
+ @Override
|
||||||
|
+ public void onChange(boolean selfChange) {
|
||||||
|
+ super.onChange(selfChange);
|
||||||
|
+ reconfigureWiFiTimeoutListener();
|
||||||
|
+ }
|
||||||
|
+ });
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private static boolean isWifiConnected = false;
|
||||||
|
+ private final AlarmManager.OnAlarmListener listener = this::turnOffWifi;
|
||||||
|
+
|
||||||
|
+ private void turnOffWifi() {
|
||||||
|
+ WifiManager wifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
|
||||||
|
+ if (isWifiTimeoutEnabled(mContext) && wifiManager.isWifiEnabled()) {
|
||||||
|
+ // setWifiEnabled(enabled) is deprecated, though AOSP still uses
|
||||||
|
+ // it internally and system apps/services are exempted
|
||||||
|
+ wifiManager.setWifiEnabled(false);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private void reconfigureWiFiTimeoutListener() {
|
||||||
|
+ if (isWifiTimeoutEnabled(mContext) && !isWifiConnected) {
|
||||||
|
+ final long timeout = SystemClock.elapsedRealtime() + wifiTimeoutDurationInMilli(mContext);
|
||||||
|
+ mAlarmManager.cancel(listener);
|
||||||
|
+ mAlarmManager.setExact(
|
||||||
|
+ AlarmManager.ELAPSED_REALTIME_WAKEUP,
|
||||||
|
+ timeout,
|
||||||
|
+ "Wi-Fi Idle Timeout",
|
||||||
|
+ listener,
|
||||||
|
+ new Handler(mContext.getMainLooper())
|
||||||
|
+ );
|
||||||
|
+ } else {
|
||||||
|
+ mAlarmManager.cancel(listener);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private static long wifiTimeoutDurationInMilli(Context mContext) {
|
||||||
|
+ return Settings.Global.getLong(mContext.getContentResolver(),
|
||||||
|
+ Global.WIFI_OFF_TIMEOUT, 0);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /** Zero is default and means disabled */
|
||||||
|
+ private static boolean isWifiTimeoutEnabled(Context mContext) {
|
||||||
|
+ return 0 != wifiTimeoutDurationInMilli(mContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
@ -16,7 +16,7 @@ Change-Id: I79c0ed4ab97494434edc6c308a8a54bd123c02ee
|
|||||||
create mode 100644 src/com/android/settings/applications/specialaccess/sensor/SensorAccess.java
|
create mode 100644 src/com/android/settings/applications/specialaccess/sensor/SensorAccess.java
|
||||||
|
|
||||||
diff --git a/res/values-de/strings.xml b/res/values-de/strings.xml
|
diff --git a/res/values-de/strings.xml b/res/values-de/strings.xml
|
||||||
index 14ea8dd84f..1bd3acf6c9 100644
|
index 4edd33d66b..a22b3de82c 100644
|
||||||
--- a/res/values-de/strings.xml
|
--- a/res/values-de/strings.xml
|
||||||
+++ b/res/values-de/strings.xml
|
+++ b/res/values-de/strings.xml
|
||||||
@@ -4945,6 +4945,9 @@
|
@@ -4945,6 +4945,9 @@
|
||||||
@ -30,7 +30,7 @@ index 14ea8dd84f..1bd3acf6c9 100644
|
|||||||
<string name="volte_5G_limited_title" msgid="5908052268836750629">"VoLTE deaktivieren?"</string>
|
<string name="volte_5G_limited_title" msgid="5908052268836750629">"VoLTE deaktivieren?"</string>
|
||||||
<string name="volte_5G_limited_text" msgid="7150583768725182345">"Dadurch wird auch deine 5G-Verbindung deaktiviert.\nWährend eines Sprachanrufs kannst du das Internet nicht nutzen und manche Apps funktionieren möglicherweise nicht."</string>
|
<string name="volte_5G_limited_text" msgid="7150583768725182345">"Dadurch wird auch deine 5G-Verbindung deaktiviert.\nWährend eines Sprachanrufs kannst du das Internet nicht nutzen und manche Apps funktionieren möglicherweise nicht."</string>
|
||||||
diff --git a/res/values-fr/strings.xml b/res/values-fr/strings.xml
|
diff --git a/res/values-fr/strings.xml b/res/values-fr/strings.xml
|
||||||
index 66c5e069ed..97cbc16b84 100644
|
index 005aa05953..7c2ad2eaf3 100644
|
||||||
--- a/res/values-fr/strings.xml
|
--- a/res/values-fr/strings.xml
|
||||||
+++ b/res/values-fr/strings.xml
|
+++ b/res/values-fr/strings.xml
|
||||||
@@ -4944,6 +4944,9 @@
|
@@ -4944,6 +4944,9 @@
|
||||||
@ -44,7 +44,7 @@ index 66c5e069ed..97cbc16b84 100644
|
|||||||
<string name="volte_5G_limited_title" msgid="5908052268836750629">"Désactiver VoLTE ?"</string>
|
<string name="volte_5G_limited_title" msgid="5908052268836750629">"Désactiver VoLTE ?"</string>
|
||||||
<string name="volte_5G_limited_text" msgid="7150583768725182345">"Cela désactive également votre connexion 5G.\nLorsque vous effectuez un appel vocal, vous n\'avez pas accès à Internet et certaines applications peuvent ne pas fonctionner."</string>
|
<string name="volte_5G_limited_text" msgid="7150583768725182345">"Cela désactive également votre connexion 5G.\nLorsque vous effectuez un appel vocal, vous n\'avez pas accès à Internet et certaines applications peuvent ne pas fonctionner."</string>
|
||||||
diff --git a/res/values/strings.xml b/res/values/strings.xml
|
diff --git a/res/values/strings.xml b/res/values/strings.xml
|
||||||
index b2a03f9a46..8eab241cd4 100644
|
index 0c6fe1a541..120e82f4dd 100644
|
||||||
--- a/res/values/strings.xml
|
--- a/res/values/strings.xml
|
||||||
+++ b/res/values/strings.xml
|
+++ b/res/values/strings.xml
|
||||||
@@ -12237,4 +12237,9 @@
|
@@ -12237,4 +12237,9 @@
|
||||||
|
@ -0,0 +1,196 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: pratyush <codelab@pratyush.dev>
|
||||||
|
Date: Mon, 7 Jun 2021 22:15:59 +0100
|
||||||
|
Subject: [PATCH] add auto-reboot setting
|
||||||
|
|
||||||
|
---
|
||||||
|
res/values/arrays.xml | 31 +++++++
|
||||||
|
res/values/strings.xml | 3 +
|
||||||
|
res/xml/security_dashboard_settings.xml | 10 ++-
|
||||||
|
.../AutoRebootPreferenceController.java | 82 +++++++++++++++++++
|
||||||
|
.../settings/security/SecuritySettings.java | 1 +
|
||||||
|
5 files changed, 126 insertions(+), 1 deletion(-)
|
||||||
|
create mode 100644 src/com/android/settings/security/AutoRebootPreferenceController.java
|
||||||
|
|
||||||
|
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
|
||||||
|
index 617548cadc..9caf926229 100644
|
||||||
|
--- a/res/values/arrays.xml
|
||||||
|
+++ b/res/values/arrays.xml
|
||||||
|
@@ -146,6 +146,37 @@
|
||||||
|
<item>1800000</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
+ <!-- Auto reboot settings -->
|
||||||
|
+ <string-array name="auto_reboot_entries">
|
||||||
|
+ <item>Off</item>
|
||||||
|
+ <item>10 minutes</item>
|
||||||
|
+ <item>30 minutes</item>
|
||||||
|
+ <item>1 hour</item>
|
||||||
|
+ <item>2 hours</item>
|
||||||
|
+ <item>4 hours</item>
|
||||||
|
+ <item>8 hours</item>
|
||||||
|
+ <item>12 hours</item>
|
||||||
|
+ <item>24 hours</item>
|
||||||
|
+ <item>36 hours</item>
|
||||||
|
+ <item>48 hours</item>
|
||||||
|
+ <item>72 hours</item>
|
||||||
|
+ </string-array>
|
||||||
|
+
|
||||||
|
+ <string-array name="auto_reboot_values" translatable="false">
|
||||||
|
+ <item>0</item> <!-- Disabled -->
|
||||||
|
+ <item>600000</item>
|
||||||
|
+ <item>1800000</item>
|
||||||
|
+ <item>3600000</item>
|
||||||
|
+ <item>7200000</item>
|
||||||
|
+ <item>14400000</item>
|
||||||
|
+ <item>28800000</item>
|
||||||
|
+ <item>43200000</item>
|
||||||
|
+ <item>86400000</item>
|
||||||
|
+ <item>129600000</item>
|
||||||
|
+ <item>172800000</item>
|
||||||
|
+ <item>259200000</item>
|
||||||
|
+ </string-array>
|
||||||
|
+
|
||||||
|
<string-array name="entries_font_size">
|
||||||
|
<item msgid="6490061470416867723">Small</item>
|
||||||
|
<item msgid="3579015730662088893">Default</item>
|
||||||
|
diff --git a/res/values/strings.xml b/res/values/strings.xml
|
||||||
|
index 120e82f4dd..6ff1f16fdf 100644
|
||||||
|
--- a/res/values/strings.xml
|
||||||
|
+++ b/res/values/strings.xml
|
||||||
|
@@ -647,6 +647,9 @@
|
||||||
|
<!-- Text shown for the description of the lockdown option -->
|
||||||
|
<string name="lockdown_settings_summary">Display power button option that turns off Smart Lock, biometric unlocking, and notifications on the lock screen</string>
|
||||||
|
|
||||||
|
+ <string name="auto_reboot_title">Auto reboot</string>
|
||||||
|
+ <string name="auto_reboot_summary">Automatically reboot the device, if the phone hasn\'t been unlocked within the selected number of hours.</string>
|
||||||
|
+
|
||||||
|
<!-- Text shown for the title of the lock when trust lost option [CHAR LIMIT=40] -->
|
||||||
|
<string name="trust_lost_locks_screen_title">Lock screen when trust is lost</string>
|
||||||
|
<!-- Text shown for the description of the lock when trust lost option [CHAR LIMIT=NONE -->
|
||||||
|
diff --git a/res/xml/security_dashboard_settings.xml b/res/xml/security_dashboard_settings.xml
|
||||||
|
index b5dcebf6d9..dfb0db65e5 100644
|
||||||
|
--- a/res/xml/security_dashboard_settings.xml
|
||||||
|
+++ b/res/xml/security_dashboard_settings.xml
|
||||||
|
@@ -55,6 +55,14 @@
|
||||||
|
android:title="@string/security_settings_face_preference_title"
|
||||||
|
android:summary="@string/summary_placeholder"
|
||||||
|
settings:keywords="@string/keywords_face_settings" />
|
||||||
|
+
|
||||||
|
+ <ListPreference
|
||||||
|
+ android:key="auto_reboot"
|
||||||
|
+ android:title="@string/auto_reboot_title"
|
||||||
|
+ android:summary="@string/auto_reboot_summary"
|
||||||
|
+ android:persistent="false"
|
||||||
|
+ android:entries="@array/auto_reboot_entries"
|
||||||
|
+ android:entryValues="@array/auto_reboot_values" />
|
||||||
|
</PreferenceCategory>
|
||||||
|
|
||||||
|
<!-- work profile security section -->
|
||||||
|
@@ -155,4 +163,4 @@
|
||||||
|
android:summary="@string/confirm_sim_deletion_description"
|
||||||
|
settings:controller="com.android.settings.security.ConfirmSimDeletionPreferenceController"/>
|
||||||
|
|
||||||
|
-</PreferenceScreen>
|
||||||
|
\ No newline at end of file
|
||||||
|
+</PreferenceScreen>
|
||||||
|
diff --git a/src/com/android/settings/security/AutoRebootPreferenceController.java b/src/com/android/settings/security/AutoRebootPreferenceController.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000..c7a75219a5
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/com/android/settings/security/AutoRebootPreferenceController.java
|
||||||
|
@@ -0,0 +1,82 @@
|
||||||
|
+package com.android.settings.security;
|
||||||
|
+
|
||||||
|
+import android.content.Context;
|
||||||
|
+import android.os.UserManager;
|
||||||
|
+import android.provider.Settings;
|
||||||
|
+import android.util.Log;
|
||||||
|
+
|
||||||
|
+import androidx.preference.ListPreference;
|
||||||
|
+import androidx.preference.Preference;
|
||||||
|
+import androidx.preference.PreferenceCategory;
|
||||||
|
+import androidx.preference.PreferenceScreen;
|
||||||
|
+
|
||||||
|
+import com.android.settings.core.PreferenceControllerMixin;
|
||||||
|
+import com.android.settingslib.core.AbstractPreferenceController;
|
||||||
|
+import com.android.settingslib.core.lifecycle.events.OnResume;
|
||||||
|
+
|
||||||
|
+public class AutoRebootPreferenceController extends AbstractPreferenceController
|
||||||
|
+ implements PreferenceControllerMixin, OnResume,
|
||||||
|
+ Preference.OnPreferenceChangeListener {
|
||||||
|
+
|
||||||
|
+ private static final String KEY_AUTO_REBOOT = "auto_reboot";
|
||||||
|
+ private static final String PREF_KEY_SECURITY_CATEGORY = "security_category";
|
||||||
|
+
|
||||||
|
+ private PreferenceCategory mSecurityCategory;
|
||||||
|
+ private boolean mIsAdmin;
|
||||||
|
+ private final UserManager mUm;
|
||||||
|
+
|
||||||
|
+ public AutoRebootPreferenceController(Context context) {
|
||||||
|
+ super(context);
|
||||||
|
+ mUm = UserManager.get(context);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public void displayPreference(PreferenceScreen screen) {
|
||||||
|
+ super.displayPreference(screen);
|
||||||
|
+ mSecurityCategory = screen.findPreference(PREF_KEY_SECURITY_CATEGORY);
|
||||||
|
+ updatePreferenceState();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public boolean isAvailable() {
|
||||||
|
+ mIsAdmin = mUm.isAdminUser();
|
||||||
|
+ return mIsAdmin;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public String getPreferenceKey() {
|
||||||
|
+ return KEY_AUTO_REBOOT;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ // TODO: should we use onCreatePreferences() instead?
|
||||||
|
+ private void updatePreferenceState() {
|
||||||
|
+ if (mSecurityCategory == null) {
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (mIsAdmin) {
|
||||||
|
+ ListPreference autoReboot =
|
||||||
|
+ (ListPreference) mSecurityCategory.findPreference(KEY_AUTO_REBOOT);
|
||||||
|
+ autoReboot.setValue(Long.toString(Settings.Global.getLong(
|
||||||
|
+ mContext.getContentResolver(), Settings.Global.SETTINGS_REBOOT_AFTER_TIMEOUT, 0)));
|
||||||
|
+ } else {
|
||||||
|
+ mSecurityCategory.removePreference(
|
||||||
|
+ mSecurityCategory.findPreference(KEY_AUTO_REBOOT));
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public void onResume() {
|
||||||
|
+ updatePreferenceState();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public boolean onPreferenceChange(Preference preference, Object value) {
|
||||||
|
+ final String key = preference.getKey();
|
||||||
|
+ if (KEY_AUTO_REBOOT.equals(key) && mIsAdmin) {
|
||||||
|
+ long timeout = Long.parseLong((String) value);
|
||||||
|
+ Settings.Global.putLong(mContext.getContentResolver(), Settings.Global.SETTINGS_REBOOT_AFTER_TIMEOUT, timeout);
|
||||||
|
+ }
|
||||||
|
+ return true;
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
diff --git a/src/com/android/settings/security/SecuritySettings.java b/src/com/android/settings/security/SecuritySettings.java
|
||||||
|
index 2f2b349c72..953012f9e7 100644
|
||||||
|
--- a/src/com/android/settings/security/SecuritySettings.java
|
||||||
|
+++ b/src/com/android/settings/security/SecuritySettings.java
|
||||||
|
@@ -118,6 +118,7 @@ public class SecuritySettings extends DashboardFragment {
|
||||||
|
securityPreferenceControllers.add(new FaceStatusPreferenceController(context));
|
||||||
|
securityPreferenceControllers.add(new FingerprintStatusPreferenceController(context));
|
||||||
|
securityPreferenceControllers.add(new ChangeScreenLockPreferenceController(context, host));
|
||||||
|
+ securityPreferenceControllers.add(new AutoRebootPreferenceController(context));
|
||||||
|
controllers.add(new PreferenceCategoryController(context, SECURITY_CATEGORY)
|
||||||
|
.setChildren(securityPreferenceControllers));
|
||||||
|
controllers.addAll(securityPreferenceControllers);
|
@ -0,0 +1,238 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Oliver Scott <olivercscott@gmail.com>
|
||||||
|
Date: Fri, 2 Oct 2020 12:37:30 -0400
|
||||||
|
Subject: [PATCH] add bluetooth auto-turn-off setting
|
||||||
|
|
||||||
|
---
|
||||||
|
res/values/arrays.xml | 44 +++++++
|
||||||
|
res/values/strings.xml | 19 +++
|
||||||
|
res/xml/connected_devices.xml | 8 ++
|
||||||
|
.../BluetoothTimeoutPreferenceController.java | 115 ++++++++++++++++++
|
||||||
|
4 files changed, 186 insertions(+)
|
||||||
|
create mode 100644 src/com/android/settings/bluetooth/BluetoothTimeoutPreferenceController.java
|
||||||
|
|
||||||
|
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
|
||||||
|
index 9caf926229..d40e65e536 100644
|
||||||
|
--- a/res/values/arrays.xml
|
||||||
|
+++ b/res/values/arrays.xml
|
||||||
|
@@ -39,6 +39,50 @@
|
||||||
|
<item>All</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
+ <!-- Bluetooth settings. The delay in inactivity before bluetooth is turned off. These are shown in a list dialog. -->
|
||||||
|
+ <string-array name="bluetooth_timeout_entries">
|
||||||
|
+ <item>@string/bluetooth_timeout_summary_never</item>
|
||||||
|
+ <item>@string/bluetooth_timeout_summary_15secs</item>
|
||||||
|
+ <item>@string/bluetooth_timeout_summary_30secs</item>
|
||||||
|
+ <item>@string/bluetooth_timeout_summary_1min</item>
|
||||||
|
+ <item>@string/bluetooth_timeout_summary_2mins</item>
|
||||||
|
+ <item>@string/bluetooth_timeout_summary_5mins</item>
|
||||||
|
+ <item>@string/bluetooth_timeout_summary_10mins</item>
|
||||||
|
+ <item>@string/bluetooth_timeout_summary_30mins</item>
|
||||||
|
+ <item>@string/bluetooth_timeout_summary_1hour</item>
|
||||||
|
+ <item>@string/bluetooth_timeout_summary_2hours</item>
|
||||||
|
+ <item>@string/bluetooth_timeout_summary_4hours</item>
|
||||||
|
+ <item>@string/bluetooth_timeout_summary_8hours</item>
|
||||||
|
+ </string-array>
|
||||||
|
+
|
||||||
|
+ <!-- Do not translate. -->
|
||||||
|
+ <string-array name="bluetooth_timeout_values" translatable="false">
|
||||||
|
+ <!-- Do not translate. -->
|
||||||
|
+ <item>0</item>
|
||||||
|
+ <!-- Do not translate. -->
|
||||||
|
+ <item>15000</item>
|
||||||
|
+ <!-- Do not translate. -->
|
||||||
|
+ <item>30000</item>
|
||||||
|
+ <!-- Do not translate. -->
|
||||||
|
+ <item>60000</item>
|
||||||
|
+ <!-- Do not translate. -->
|
||||||
|
+ <item>120000</item>
|
||||||
|
+ <!-- Do not translate. -->
|
||||||
|
+ <item>300000</item>
|
||||||
|
+ <!-- Do not translate. -->
|
||||||
|
+ <item>600000</item>
|
||||||
|
+ <!-- Do not translate. -->
|
||||||
|
+ <item>1800000</item>
|
||||||
|
+ <!-- Do not translate. -->
|
||||||
|
+ <item>3600000</item>
|
||||||
|
+ <!-- Do not translate. -->
|
||||||
|
+ <item>7200000</item>
|
||||||
|
+ <!-- Do not translate. -->
|
||||||
|
+ <item>14400000</item>
|
||||||
|
+ <!-- Do not translate. -->
|
||||||
|
+ <item>28800000</item>
|
||||||
|
+ </string-array>
|
||||||
|
+
|
||||||
|
<!-- Display settings. The delay in inactivity before the screen is turned off. These are shown in a list dialog. -->
|
||||||
|
<string-array name="screen_timeout_entries">
|
||||||
|
<item>15 seconds</item>
|
||||||
|
diff --git a/res/values/strings.xml b/res/values/strings.xml
|
||||||
|
index 6ff1f16fdf..3a7f3878bf 100644
|
||||||
|
--- a/res/values/strings.xml
|
||||||
|
+++ b/res/values/strings.xml
|
||||||
|
@@ -27,6 +27,25 @@
|
||||||
|
<!-- Used in confirmation dialogs as the action that the user will tap to turn on the feature. [CHAR LIMIT=40]-->
|
||||||
|
<string name="confirmation_turn_on">Turn on</string>
|
||||||
|
|
||||||
|
+ <!-- Connected devices screen, setting option name to change bluetooth timeout -->
|
||||||
|
+ <string name="bluetooth_timeout">Bluetooth timeout</string>
|
||||||
|
+
|
||||||
|
+ <!-- Connected devices screen, setting option summary to change bluetooth timeout -->
|
||||||
|
+ <string name="bluetooth_timeout_summary">Bluetooth will turn off after <xliff:g id="timeout_description">%1$s</xliff:g> if no devices connected</string>
|
||||||
|
+ <string name="bluetooth_timeout_summary2">Do not automatically turn off Bluetooth</string>
|
||||||
|
+ <string name="bluetooth_timeout_summary_never">Never</string>
|
||||||
|
+ <string name="bluetooth_timeout_summary_15secs">15 seconds</string>
|
||||||
|
+ <string name="bluetooth_timeout_summary_30secs">30 seconds</string>
|
||||||
|
+ <string name="bluetooth_timeout_summary_1min">1 minute</string>
|
||||||
|
+ <string name="bluetooth_timeout_summary_2mins">2 minutes</string>
|
||||||
|
+ <string name="bluetooth_timeout_summary_5mins">5 minutes</string>
|
||||||
|
+ <string name="bluetooth_timeout_summary_10mins">10 minutes</string>
|
||||||
|
+ <string name="bluetooth_timeout_summary_30mins">30 minutes</string>
|
||||||
|
+ <string name="bluetooth_timeout_summary_1hour">1 hour</string>
|
||||||
|
+ <string name="bluetooth_timeout_summary_2hours">2 hours</string>
|
||||||
|
+ <string name="bluetooth_timeout_summary_4hours">4 hours</string>
|
||||||
|
+ <string name="bluetooth_timeout_summary_8hours">8 hours</string>
|
||||||
|
+
|
||||||
|
<!-- Device Info screen. Used for a status item's value when the proper value is not known -->
|
||||||
|
<string name="device_info_default">Unknown</string>
|
||||||
|
<!-- [CHAR LIMIT=NONE] Device Info screen. Countdown for user taps to enable development settings -->
|
||||||
|
diff --git a/res/xml/connected_devices.xml b/res/xml/connected_devices.xml
|
||||||
|
index 644ce03299..039f253f9e 100644
|
||||||
|
--- a/res/xml/connected_devices.xml
|
||||||
|
+++ b/res/xml/connected_devices.xml
|
||||||
|
@@ -53,6 +53,14 @@
|
||||||
|
settings:useAdminDisabledSummary="true"
|
||||||
|
settings:controller="com.android.settings.connecteddevice.AddDevicePreferenceController"/>
|
||||||
|
|
||||||
|
+ <androidx.preference.ListPreference
|
||||||
|
+ android:key="bluetooth_timeout"
|
||||||
|
+ android:title="@string/bluetooth_timeout"
|
||||||
|
+ android:summary="@string/summary_placeholder"
|
||||||
|
+ android:entries="@array/bluetooth_timeout_entries"
|
||||||
|
+ android:entryValues="@array/bluetooth_timeout_values"
|
||||||
|
+ settings:controller="com.android.settings.bluetooth.BluetoothTimeoutPreferenceController"/>
|
||||||
|
+
|
||||||
|
<PreferenceCategory
|
||||||
|
android:key="previously_connected_devices"
|
||||||
|
android:title="@string/connected_device_previously_connected_title"
|
||||||
|
diff --git a/src/com/android/settings/bluetooth/BluetoothTimeoutPreferenceController.java b/src/com/android/settings/bluetooth/BluetoothTimeoutPreferenceController.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000..244147948a
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/com/android/settings/bluetooth/BluetoothTimeoutPreferenceController.java
|
||||||
|
@@ -0,0 +1,115 @@
|
||||||
|
+/*
|
||||||
|
+ * Copyright (C) 2020 The Calyx Institute
|
||||||
|
+ *
|
||||||
|
+ * 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.bluetooth;
|
||||||
|
+
|
||||||
|
+import android.bluetooth.BluetoothAdapter;
|
||||||
|
+import android.content.Context;
|
||||||
|
+import android.provider.Settings;
|
||||||
|
+import android.util.Log;
|
||||||
|
+
|
||||||
|
+import androidx.preference.ListPreference;
|
||||||
|
+import androidx.preference.Preference;
|
||||||
|
+
|
||||||
|
+import com.android.settings.R;
|
||||||
|
+import com.android.settings.core.BasePreferenceController;
|
||||||
|
+import com.android.settings.core.PreferenceControllerMixin;
|
||||||
|
+
|
||||||
|
+public class BluetoothTimeoutPreferenceController extends BasePreferenceController implements
|
||||||
|
+ PreferenceControllerMixin, Preference.OnPreferenceChangeListener {
|
||||||
|
+ private static final String TAG = "BluetoothTimeoutPrefCtrl";
|
||||||
|
+
|
||||||
|
+ public static final int FALLBACK_BLUETOOTH_TIMEOUT_VALUE = 0;
|
||||||
|
+
|
||||||
|
+ private final String mBluetoothTimeoutKey;
|
||||||
|
+
|
||||||
|
+ protected BluetoothAdapter mBluetoothAdapter;
|
||||||
|
+
|
||||||
|
+ public BluetoothTimeoutPreferenceController(Context context, String key) {
|
||||||
|
+ super(context, key);
|
||||||
|
+ mBluetoothTimeoutKey = key;
|
||||||
|
+
|
||||||
|
+ mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
|
||||||
|
+ if (mBluetoothAdapter == null) {
|
||||||
|
+ Log.e(TAG, "Bluetooth is not supported on this device");
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public int getAvailabilityStatus() {
|
||||||
|
+ return mBluetoothAdapter != null ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public String getPreferenceKey() {
|
||||||
|
+ return mBluetoothTimeoutKey;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public void updateState(Preference preference) {
|
||||||
|
+ final ListPreference timeoutListPreference = (ListPreference) preference;
|
||||||
|
+ final long currentTimeout = Settings.Global.getLong(mContext.getContentResolver(),
|
||||||
|
+ Settings.Global.BLUETOOTH_OFF_TIMEOUT, FALLBACK_BLUETOOTH_TIMEOUT_VALUE);
|
||||||
|
+ timeoutListPreference.setValue(String.valueOf(currentTimeout));
|
||||||
|
+ updateTimeoutPreferenceDescription(timeoutListPreference,
|
||||||
|
+ Long.parseLong(timeoutListPreference.getValue()));
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
|
+ try {
|
||||||
|
+ long value = Long.parseLong((String) newValue);
|
||||||
|
+ Settings.Global.putLong(mContext.getContentResolver(), Settings.Global.BLUETOOTH_OFF_TIMEOUT, value);
|
||||||
|
+ updateTimeoutPreferenceDescription((ListPreference) preference, value);
|
||||||
|
+ } catch (NumberFormatException e) {
|
||||||
|
+ Log.e(TAG, "could not persist bluetooth timeout setting", e);
|
||||||
|
+ }
|
||||||
|
+ return true;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public static CharSequence getTimeoutDescription(
|
||||||
|
+ long currentTimeout, CharSequence[] entries, CharSequence[] values) {
|
||||||
|
+ if (currentTimeout < 0 || entries == null || values == null
|
||||||
|
+ || values.length != entries.length) {
|
||||||
|
+ return null;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ for (int i = 0; i < values.length; i++) {
|
||||||
|
+ long timeout = Long.parseLong(values[i].toString());
|
||||||
|
+ if (currentTimeout == timeout) {
|
||||||
|
+ return entries[i];
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ return null;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private void updateTimeoutPreferenceDescription(ListPreference preference,
|
||||||
|
+ long currentTimeout) {
|
||||||
|
+ final CharSequence[] entries = preference.getEntries();
|
||||||
|
+ final CharSequence[] values = preference.getEntryValues();
|
||||||
|
+ final CharSequence timeoutDescription = getTimeoutDescription(
|
||||||
|
+ currentTimeout, entries, values);
|
||||||
|
+ String summary = "";
|
||||||
|
+ if (timeoutDescription != null) {
|
||||||
|
+ if (currentTimeout != 0)
|
||||||
|
+ summary = mContext.getString(R.string.bluetooth_timeout_summary, timeoutDescription);
|
||||||
|
+ else
|
||||||
|
+ summary = mContext.getString(R.string.bluetooth_timeout_summary2);
|
||||||
|
+ }
|
||||||
|
+ preference.setSummary(summary);
|
||||||
|
+ }
|
||||||
|
+}
|
@ -0,0 +1,238 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Oliver Scott <olivercscott@gmail.com>
|
||||||
|
Date: Thu, 25 Feb 2021 11:31:14 -0500
|
||||||
|
Subject: [PATCH] add Wi-Fi timeout feature
|
||||||
|
|
||||||
|
---
|
||||||
|
res/values/arrays.xml | 44 +++++++
|
||||||
|
res/values/strings.xml | 19 +++
|
||||||
|
res/xml/wifi_configure_settings.xml | 8 ++
|
||||||
|
.../wifi/WifiTimeoutPreferenceController.java | 115 ++++++++++++++++++
|
||||||
|
4 files changed, 186 insertions(+)
|
||||||
|
create mode 100644 src/com/android/settings/wifi/WifiTimeoutPreferenceController.java
|
||||||
|
|
||||||
|
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
|
||||||
|
index d40e65e536..6259f4d1a5 100644
|
||||||
|
--- a/res/values/arrays.xml
|
||||||
|
+++ b/res/values/arrays.xml
|
||||||
|
@@ -83,6 +83,50 @@
|
||||||
|
<item>28800000</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
+ <!-- Wifi settings. The delay in inactivity before wifi is turned off. These are shown in a list dialog. -->
|
||||||
|
+ <string-array name="wifi_timeout_entries">
|
||||||
|
+ <item>@string/wifi_timeout_summary_never</item>
|
||||||
|
+ <item>@string/wifi_timeout_summary_15secs</item>
|
||||||
|
+ <item>@string/wifi_timeout_summary_30secs</item>
|
||||||
|
+ <item>@string/wifi_timeout_summary_1min</item>
|
||||||
|
+ <item>@string/wifi_timeout_summary_2mins</item>
|
||||||
|
+ <item>@string/wifi_timeout_summary_5mins</item>
|
||||||
|
+ <item>@string/wifi_timeout_summary_10mins</item>
|
||||||
|
+ <item>@string/wifi_timeout_summary_30mins</item>
|
||||||
|
+ <item>@string/wifi_timeout_summary_1hour</item>
|
||||||
|
+ <item>@string/wifi_timeout_summary_2hours</item>
|
||||||
|
+ <item>@string/wifi_timeout_summary_4hours</item>
|
||||||
|
+ <item>@string/wifi_timeout_summary_8hours</item>
|
||||||
|
+ </string-array>
|
||||||
|
+
|
||||||
|
+ <!-- Do not translate. -->
|
||||||
|
+ <string-array name="wifi_timeout_values" translatable="false">
|
||||||
|
+ <!-- Do not translate. -->
|
||||||
|
+ <item>0</item>
|
||||||
|
+ <!-- Do not translate. -->
|
||||||
|
+ <item>15000</item>
|
||||||
|
+ <!-- Do not translate. -->
|
||||||
|
+ <item>30000</item>
|
||||||
|
+ <!-- Do not translate. -->
|
||||||
|
+ <item>60000</item>
|
||||||
|
+ <!-- Do not translate. -->
|
||||||
|
+ <item>120000</item>
|
||||||
|
+ <!-- Do not translate. -->
|
||||||
|
+ <item>300000</item>
|
||||||
|
+ <!-- Do not translate. -->
|
||||||
|
+ <item>600000</item>
|
||||||
|
+ <!-- Do not translate. -->
|
||||||
|
+ <item>1800000</item>
|
||||||
|
+ <!-- Do not translate. -->
|
||||||
|
+ <item>3600000</item>
|
||||||
|
+ <!-- Do not translate. -->
|
||||||
|
+ <item>7200000</item>
|
||||||
|
+ <!-- Do not translate. -->
|
||||||
|
+ <item>14400000</item>
|
||||||
|
+ <!-- Do not translate. -->
|
||||||
|
+ <item>28800000</item>
|
||||||
|
+ </string-array>
|
||||||
|
+
|
||||||
|
<!-- Display settings. The delay in inactivity before the screen is turned off. These are shown in a list dialog. -->
|
||||||
|
<string-array name="screen_timeout_entries">
|
||||||
|
<item>15 seconds</item>
|
||||||
|
diff --git a/res/values/strings.xml b/res/values/strings.xml
|
||||||
|
index 3a7f3878bf..dbbc4ba758 100644
|
||||||
|
--- a/res/values/strings.xml
|
||||||
|
+++ b/res/values/strings.xml
|
||||||
|
@@ -46,6 +46,25 @@
|
||||||
|
<string name="bluetooth_timeout_summary_4hours">4 hours</string>
|
||||||
|
<string name="bluetooth_timeout_summary_8hours">8 hours</string>
|
||||||
|
|
||||||
|
+ <!-- screen, setting option name to change wifi timeout -->
|
||||||
|
+ <string name="wifi_timeout">Turn off Wi-Fi automatically</string>
|
||||||
|
+
|
||||||
|
+ <!-- screen, setting option summary to change wifi timeout -->
|
||||||
|
+ <string name="wifi_timeout_summary">Wi-Fi will turn off after <xliff:g id="timeout_description">%1$s</xliff:g> if no network connected</string>
|
||||||
|
+ <string name="wifi_timeout_summary2">Disabled</string>
|
||||||
|
+ <string name="wifi_timeout_summary_never">Never</string>
|
||||||
|
+ <string name="wifi_timeout_summary_15secs">15 seconds</string>
|
||||||
|
+ <string name="wifi_timeout_summary_30secs">30 seconds</string>
|
||||||
|
+ <string name="wifi_timeout_summary_1min">1 minute</string>
|
||||||
|
+ <string name="wifi_timeout_summary_2mins">2 minutes</string>
|
||||||
|
+ <string name="wifi_timeout_summary_5mins">5 minutes</string>
|
||||||
|
+ <string name="wifi_timeout_summary_10mins">10 minutes</string>
|
||||||
|
+ <string name="wifi_timeout_summary_30mins">30 minutes</string>
|
||||||
|
+ <string name="wifi_timeout_summary_1hour">1 hour</string>
|
||||||
|
+ <string name="wifi_timeout_summary_2hours">2 hours</string>
|
||||||
|
+ <string name="wifi_timeout_summary_4hours">4 hours</string>
|
||||||
|
+ <string name="wifi_timeout_summary_8hours">8 hours</string>
|
||||||
|
+
|
||||||
|
<!-- Device Info screen. Used for a status item's value when the proper value is not known -->
|
||||||
|
<string name="device_info_default">Unknown</string>
|
||||||
|
<!-- [CHAR LIMIT=NONE] Device Info screen. Countdown for user taps to enable development settings -->
|
||||||
|
diff --git a/res/xml/wifi_configure_settings.xml b/res/xml/wifi_configure_settings.xml
|
||||||
|
index cc281fa876..98d28f053b 100644
|
||||||
|
--- a/res/xml/wifi_configure_settings.xml
|
||||||
|
+++ b/res/xml/wifi_configure_settings.xml
|
||||||
|
@@ -26,6 +26,14 @@
|
||||||
|
android:summary="@string/wifi_wakeup_summary"
|
||||||
|
settings:controller="com.android.settings.wifi.WifiWakeupPreferenceController"/>
|
||||||
|
|
||||||
|
+ <ListPreference
|
||||||
|
+ android:key="wifi_timeout"
|
||||||
|
+ android:title="@string/wifi_timeout"
|
||||||
|
+ android:summary="@string/wifi_timeout_summary"
|
||||||
|
+ android:entries="@array/wifi_timeout_entries"
|
||||||
|
+ android:entryValues="@array/wifi_timeout_values"
|
||||||
|
+ settings:controller="com.android.settings.wifi.WifiTimeoutPreferenceController"/>
|
||||||
|
+
|
||||||
|
<SwitchPreference
|
||||||
|
android:key="use_open_wifi_automatically"
|
||||||
|
android:icon="@drawable/ic_open_wifi_autoconnect"
|
||||||
|
diff --git a/src/com/android/settings/wifi/WifiTimeoutPreferenceController.java b/src/com/android/settings/wifi/WifiTimeoutPreferenceController.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000..7116c90519
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/com/android/settings/wifi/WifiTimeoutPreferenceController.java
|
||||||
|
@@ -0,0 +1,115 @@
|
||||||
|
+/*
|
||||||
|
+ * Copyright (C) 2020 The Calyx Institute
|
||||||
|
+ *
|
||||||
|
+ * 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.wifi;
|
||||||
|
+
|
||||||
|
+import android.content.Context;
|
||||||
|
+import android.net.wifi.WifiManager;
|
||||||
|
+import android.provider.Settings;
|
||||||
|
+import android.util.Log;
|
||||||
|
+
|
||||||
|
+import androidx.preference.ListPreference;
|
||||||
|
+import androidx.preference.Preference;
|
||||||
|
+
|
||||||
|
+import com.android.settings.R;
|
||||||
|
+import com.android.settings.core.BasePreferenceController;
|
||||||
|
+import com.android.settings.core.PreferenceControllerMixin;
|
||||||
|
+
|
||||||
|
+public class WifiTimeoutPreferenceController extends BasePreferenceController implements
|
||||||
|
+ PreferenceControllerMixin, Preference.OnPreferenceChangeListener {
|
||||||
|
+ private static final String TAG = "WifiTimeoutPrefCtrl";
|
||||||
|
+
|
||||||
|
+ public static final int FALLBACK_WIFI_TIMEOUT_VALUE = 0;
|
||||||
|
+
|
||||||
|
+ private final String mWifiTimeoutKey;
|
||||||
|
+
|
||||||
|
+ protected WifiManager mWifiManager;
|
||||||
|
+
|
||||||
|
+ public WifiTimeoutPreferenceController(Context context, String key) {
|
||||||
|
+ super(context, key);
|
||||||
|
+ mWifiTimeoutKey = key;
|
||||||
|
+
|
||||||
|
+ mWifiManager = context.getSystemService(WifiManager.class);
|
||||||
|
+ if (mWifiManager == null) {
|
||||||
|
+ Log.e(TAG, "Wifi is not supported on this device");
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public int getAvailabilityStatus() {
|
||||||
|
+ return mWifiManager != null ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public String getPreferenceKey() {
|
||||||
|
+ return mWifiTimeoutKey;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public void updateState(Preference preference) {
|
||||||
|
+ final ListPreference timeoutListPreference = (ListPreference) preference;
|
||||||
|
+ final long currentTimeout = Settings.Global.getLong(mContext.getContentResolver(),
|
||||||
|
+ Settings.Global.WIFI_OFF_TIMEOUT, FALLBACK_WIFI_TIMEOUT_VALUE);
|
||||||
|
+ timeoutListPreference.setValue(String.valueOf(currentTimeout));
|
||||||
|
+ updateTimeoutPreferenceDescription(timeoutListPreference,
|
||||||
|
+ Long.parseLong(timeoutListPreference.getValue()));
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
|
+ try {
|
||||||
|
+ long value = Long.parseLong((String) newValue);
|
||||||
|
+ Settings.Global.putLong(mContext.getContentResolver(), Settings.Global.WIFI_OFF_TIMEOUT, value);
|
||||||
|
+ updateTimeoutPreferenceDescription((ListPreference) preference, value);
|
||||||
|
+ } catch (NumberFormatException e) {
|
||||||
|
+ Log.e(TAG, "could not persist wifi timeout setting", e);
|
||||||
|
+ }
|
||||||
|
+ return true;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public static CharSequence getTimeoutDescription(
|
||||||
|
+ long currentTimeout, CharSequence[] entries, CharSequence[] values) {
|
||||||
|
+ if (currentTimeout < 0 || entries == null || values == null
|
||||||
|
+ || values.length != entries.length) {
|
||||||
|
+ return null;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ for (int i = 0; i < values.length; i++) {
|
||||||
|
+ long timeout = Long.parseLong(values[i].toString());
|
||||||
|
+ if (currentTimeout == timeout) {
|
||||||
|
+ return entries[i];
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ return null;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private void updateTimeoutPreferenceDescription(ListPreference preference,
|
||||||
|
+ long currentTimeout) {
|
||||||
|
+ final CharSequence[] entries = preference.getEntries();
|
||||||
|
+ final CharSequence[] values = preference.getEntryValues();
|
||||||
|
+ final CharSequence timeoutDescription = getTimeoutDescription(
|
||||||
|
+ currentTimeout, entries, values);
|
||||||
|
+ String summary = "";
|
||||||
|
+ if (timeoutDescription != null) {
|
||||||
|
+ if (currentTimeout != 0)
|
||||||
|
+ summary = mContext.getString(R.string.wifi_timeout_summary, timeoutDescription);
|
||||||
|
+ else
|
||||||
|
+ summary = mContext.getString(R.string.wifi_timeout_summary2);
|
||||||
|
+ }
|
||||||
|
+ preference.setSummary(summary);
|
||||||
|
+ }
|
||||||
|
+}
|
@ -103,11 +103,16 @@ applyPatch "$DOS_PATCHES/android_frameworks_base/0013-Network_Permission-5.patch
|
|||||||
applyPatch "$DOS_PATCHES/android_frameworks_base/0013-Network_Permission-6.patch";
|
applyPatch "$DOS_PATCHES/android_frameworks_base/0013-Network_Permission-6.patch";
|
||||||
applyPatch "$DOS_PATCHES/android_frameworks_base/0013-Network_Permission-7.patch";
|
applyPatch "$DOS_PATCHES/android_frameworks_base/0013-Network_Permission-7.patch";
|
||||||
fi;
|
fi;
|
||||||
|
applyPatch "$DOS_PATCHES/android_frameworks_base/0014-Automatic_Reboot.patch"; #Timeout for reboot (GrapheneOS)
|
||||||
|
applyPatch "$DOS_PATCHES/android_frameworks_base/0015-Bluetooth_Timeout.patch"; #Timeout for Bluetooth (GrapheneOS)
|
||||||
|
applyPatch "$DOS_PATCHES/android_frameworks_base/0016-WiFi_Timeout.patch"; #Timeout for Wi-Fi (GrapheneOS)
|
||||||
applyPatch "$DOS_PATCHES_COMMON/android_frameworks_base/0006-Do-not-throw-in-setAppOnInterfaceLocked.patch"; #Fix random reboots on broken kernels when an app has data restricted XXX: ugly
|
applyPatch "$DOS_PATCHES_COMMON/android_frameworks_base/0006-Do-not-throw-in-setAppOnInterfaceLocked.patch"; #Fix random reboots on broken kernels when an app has data restricted XXX: ugly
|
||||||
if [ "$DOS_MICROG_INCLUDED" = "FULL" ]; then applyPatch "$DOS_PATCHES/android_frameworks_base/0002-Signature_Spoofing.patch"; fi; #Allow packages to spoof their signature (microG)
|
if [ "$DOS_MICROG_INCLUDED" = "FULL" ]; then applyPatch "$DOS_PATCHES/android_frameworks_base/0002-Signature_Spoofing.patch"; fi; #Allow packages to spoof their signature (microG)
|
||||||
if [ "$DOS_MICROG_INCLUDED" = "FULL" ]; then applyPatch "$DOS_PATCHES/android_frameworks_base/0003-Harden_Sig_Spoofing.patch"; fi; #Restrict signature spoofing to system apps signed with the platform key
|
if [ "$DOS_MICROG_INCLUDED" = "FULL" ]; then applyPatch "$DOS_PATCHES/android_frameworks_base/0003-Harden_Sig_Spoofing.patch"; fi; #Restrict signature spoofing to system apps signed with the platform key
|
||||||
hardenLocationConf services/core/java/com/android/server/location/gps_debug.conf; #Harden the default GPS config
|
hardenLocationConf services/core/java/com/android/server/location/gps_debug.conf; #Harden the default GPS config
|
||||||
changeDefaultDNS; #Change the default DNS servers
|
changeDefaultDNS; #Change the default DNS servers
|
||||||
|
#sed -i 's/DEFAULT_USE_COMPACTION = false;/DEFAULT_USE_COMPACTION = true;/' services/core/java/com/android/server/am/CachedAppOptimizer.java; #Enable app compaction by default (GrapheneOS)
|
||||||
|
#sed -i 's/DEFAULT_USE_FREEZER = false;/DEFAULT_USE_FREEZER = true;/' services/core/java/com/android/server/am/CachedAppOptimizer.java; #Enable app freezer by default (GrapheneOS)
|
||||||
sed -i 's/DEFAULT_MAX_FILES = 1000;/DEFAULT_MAX_FILES = 0;/' services/core/java/com/android/server/DropBoxManagerService.java; #Disable DropBox internal logging service
|
sed -i 's/DEFAULT_MAX_FILES = 1000;/DEFAULT_MAX_FILES = 0;/' services/core/java/com/android/server/DropBoxManagerService.java; #Disable DropBox internal logging service
|
||||||
sed -i 's/DEFAULT_MAX_FILES_LOWRAM = 300;/DEFAULT_MAX_FILES_LOWRAM = 0;/' services/core/java/com/android/server/DropBoxManagerService.java;
|
sed -i 's/DEFAULT_MAX_FILES_LOWRAM = 300;/DEFAULT_MAX_FILES_LOWRAM = 0;/' services/core/java/com/android/server/DropBoxManagerService.java;
|
||||||
sed -i 's/(notif.needNotify)/(true)/' location/java/com/android/internal/location/GpsNetInitiatedHandler.java; #Notify the user if their location is requested via SUPL
|
sed -i 's/(notif.needNotify)/(true)/' location/java/com/android/internal/location/GpsNetInitiatedHandler.java; #Notify the user if their location is requested via SUPL
|
||||||
@ -217,6 +222,9 @@ applyPatch "$DOS_PATCHES/android_packages_apps_Settings/0001-Captive_Portal_Togg
|
|||||||
if [ "$DOS_SENSORS_PERM_NEW" = true ]; then applyPatch "$DOS_PATCHES/android_packages_apps_Settings/0002-Sensors.patch"; fi; #Permission for sensors access (MSe1969)
|
if [ "$DOS_SENSORS_PERM_NEW" = true ]; then applyPatch "$DOS_PATCHES/android_packages_apps_Settings/0002-Sensors.patch"; fi; #Permission for sensors access (MSe1969)
|
||||||
applyPatch "$DOS_PATCHES/android_packages_apps_Settings/0003-Remove_SensorsOff_Tile.patch"; #Remove the Sensors Off development tile
|
applyPatch "$DOS_PATCHES/android_packages_apps_Settings/0003-Remove_SensorsOff_Tile.patch"; #Remove the Sensors Off development tile
|
||||||
applyPatch "$DOS_PATCHES/android_packages_apps_Settings/0004-Private_DNS.patch"; #More 'Private DNS' options (CalyxOS)
|
applyPatch "$DOS_PATCHES/android_packages_apps_Settings/0004-Private_DNS.patch"; #More 'Private DNS' options (CalyxOS)
|
||||||
|
applyPatch "$DOS_PATCHES/android_packages_apps_Settings/0005-Automatic_Reboot.patch"; #Timeout for reboot (GrapheneOS)
|
||||||
|
applyPatch "$DOS_PATCHES/android_packages_apps_Settings/0006-Bluetooth_Timeout.patch"; #Timeout for Bluetooth (CalyxOS)
|
||||||
|
applyPatch "$DOS_PATCHES/android_packages_apps_Settings/0007-WiFi_Timeout.patch"; #Timeout for Wi-Fi (CalyxOS)
|
||||||
sed -i 's/if (isFullDiskEncrypted()) {/if (false) {/' src/com/android/settings/accessibility/*AccessibilityService*.java; #Never disable secure start-up when enabling an accessibility service
|
sed -i 's/if (isFullDiskEncrypted()) {/if (false) {/' src/com/android/settings/accessibility/*AccessibilityService*.java; #Never disable secure start-up when enabling an accessibility service
|
||||||
if [ "$DOS_MICROG_INCLUDED" = "FULL" ]; then sed -i 's/GSETTINGS_PROVIDER = "com.google.settings";/GSETTINGS_PROVIDER = "com.google.oQuae4av";/' src/com/android/settings/backup/PrivacySettingsUtils.java; fi; #microG doesn't support Backup, hide the options
|
if [ "$DOS_MICROG_INCLUDED" = "FULL" ]; then sed -i 's/GSETTINGS_PROVIDER = "com.google.settings";/GSETTINGS_PROVIDER = "com.google.oQuae4av";/' src/com/android/settings/backup/PrivacySettingsUtils.java; fi; #microG doesn't support Backup, hide the options
|
||||||
fi;
|
fi;
|
||||||
|
@ -69,7 +69,7 @@ export DOS_NON_COMMERCIAL_USE_PATCHES=false; #Set true to allow inclusion of non
|
|||||||
export DOS_OPTIMIZE_IMAGES=false; #Set true to apply lossless optimizations to image resources
|
export DOS_OPTIMIZE_IMAGES=false; #Set true to apply lossless optimizations to image resources
|
||||||
export DOS_SILENCE_INCLUDED=true; #Set false to disable inclusion of Silence SMS app
|
export DOS_SILENCE_INCLUDED=true; #Set false to disable inclusion of Silence SMS app
|
||||||
export DOS_SENSORS_PERM=false; #Set true to provide a per-app sensors permission #XXX: can break things like camera
|
export DOS_SENSORS_PERM=false; #Set true to provide a per-app sensors permission #XXX: can break things like camera
|
||||||
export DOS_SENSORS_PERM_NEW=false;
|
export DOS_SENSORS_PERM_NEW=true;
|
||||||
export DOS_STRONG_ENCRYPTION_ENABLED=false; #Set true to enable AES 256-bit FDE encryption on 14.1+15.1 XXX: THIS WILL **DESTROY** EXISTING INSTALLS!
|
export DOS_STRONG_ENCRYPTION_ENABLED=false; #Set true to enable AES 256-bit FDE encryption on 14.1+15.1 XXX: THIS WILL **DESTROY** EXISTING INSTALLS!
|
||||||
export DOS_WEBVIEW_LFS=true; #Whether to `git lfs pull` in the WebView repository
|
export DOS_WEBVIEW_LFS=true; #Whether to `git lfs pull` in the WebView repository
|
||||||
#alias DOS_WEBVIEW_CHERRYPICK='git pull "https://github.com/LineageOS/android_external_chromium-webview" refs/changes/00/316600/2';
|
#alias DOS_WEBVIEW_CHERRYPICK='git pull "https://github.com/LineageOS/android_external_chromium-webview" refs/changes/00/316600/2';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user