summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSpiritCroc <dev@spiritcroc.de>2023-08-04 12:24:15 +0200
committerJulian Veit <claymore1298@gmail.com>2025-06-17 22:42:07 +0200
commitfdf24a1c84a6fba066457c07c4e37fe9d085ea8d (patch)
tree51e60da4f1b408855daeb95f8358ac948bc26c55
parentb8fd53d1a72fdb868cb7e57f2d39c846b34a044a (diff)
ae: automatically reboot device after timeout if set [2/2]
Implement using AICP preference types. Entry values and strings from original commit commit 8a468359ce24d85b8646b6f93409d2be798c12f9 Author: Dmitry Muhomor <muhomor.dmitry@gmail.com> Date: Tue Feb 14 11:23:29 2023 +0200 add auto-reboot setting Change-Id: I059f1f5c0eafccfd80fe3eb1a2822c584061a702
-rw-r--r--res/values/arrays.xml32
-rw-r--r--res/values/strings.xml18
-rw-r--r--res/xml/system_behaviour.xml15
-rwxr-xr-xtools/power_off_after_timeout_values.py38
4 files changed, 103 insertions, 0 deletions
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
index 32cb73382..8cb01b1df 100644
--- a/res/values/arrays.xml
+++ b/res/values/arrays.xml
@@ -1475,4 +1475,36 @@
<item>2</item>
<item>3</item>
</string-array>
+
+ <!-- Reboot after timeout without unlocking the device.
+ Use tools/power_off_after_timeout_values.py to generate without having to worry about miscalculations. -->
+ <string-array name="reboot_after_timeout_entries" translatable="false">
+ <item>@string/reboot_after_timeout_off</item>
+ <item>@string/reboot_after_timeout_minutes_10</item>
+ <item>@string/reboot_after_timeout_minutes_30</item>
+ <item>@string/reboot_after_timeout_hours_1</item>
+ <item>@string/reboot_after_timeout_hours_2</item>
+ <item>@string/reboot_after_timeout_hours_4</item>
+ <item>@string/reboot_after_timeout_hours_8</item>
+ <item>@string/reboot_after_timeout_hours_12</item>
+ <item>@string/reboot_after_timeout_hours_24</item>
+ <item>@string/reboot_after_timeout_hours_36</item>
+ <item>@string/reboot_after_timeout_hours_48</item>
+ <item>@string/reboot_after_timeout_hours_72</item>
+ </string-array>
+ <!-- values in milliseconds -->
+ <string-array name="reboot_after_timeout_values" translatable="false">
+ <item>0</item>
+ <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>
</resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 4efb0981f..b84bd715f 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -2016,4 +2016,22 @@
<!-- Ignore window secure -->
<string name="ignore_window_secure_title">Ignore window secure flags</string>
<string name="ignore_window_secure_summary">Removes the screenshots and screenrecords limits for all applicatications, restart applications for the change to take effect.</string>
+
+ <string name="system_security_category_title">Security</string>
+
+ <!-- Reboot after timeout without unlocking the device -->
+ <string name="auto_reboot_title">Auto reboot</string>
+ <string name="auto_reboot_summary">Automatically reboot the device if it hasn\'t been unlocked within the selected duration of time.</string>
+ <string name="reboot_after_timeout_off">Off</string>
+ <string name="reboot_after_timeout_minutes_10">10 minutes</string>
+ <string name="reboot_after_timeout_minutes_30">30 minutes</string>
+ <string name="reboot_after_timeout_hours_1">1 hour</string>
+ <string name="reboot_after_timeout_hours_2">2 hours</string>
+ <string name="reboot_after_timeout_hours_4">4 hours</string>
+ <string name="reboot_after_timeout_hours_8">8 hours</string>
+ <string name="reboot_after_timeout_hours_12">12 hours</string>
+ <string name="reboot_after_timeout_hours_24">24 hours</string>
+ <string name="reboot_after_timeout_hours_36">36 hours</string>
+ <string name="reboot_after_timeout_hours_48">48 hours</string>
+ <string name="reboot_after_timeout_hours_72">72 hours</string>
</resources>
diff --git a/res/xml/system_behaviour.xml b/res/xml/system_behaviour.xml
index dd0d7be4e..3793d9509 100644
--- a/res/xml/system_behaviour.xml
+++ b/res/xml/system_behaviour.xml
@@ -156,6 +156,21 @@ android:persistent="false" />-->
android:defaultValue="false"/>
</PreferenceCategory>
+
+ <PreferenceCategory
+ android:key="system_security_category"
+ android:title="@string/system_security_category_title">
+
+ <com.aicp.gear.preference.GlobalSettingIntListPreference
+ android:key="settings_reboot_after_timeout"
+ android:title="@string/auto_reboot_title"
+ android:summary="@string/auto_reboot_summary"
+ android:entries="@array/reboot_after_timeout_entries"
+ android:entryValues="@array/reboot_after_timeout_values"
+ android:defaultValue="0" />
+
+ </PreferenceCategory>
+
<!--
<PreferenceCategory
android:title="@string/audio_panel_view">
diff --git a/tools/power_off_after_timeout_values.py b/tools/power_off_after_timeout_values.py
new file mode 100755
index 000000000..e30ae4874
--- /dev/null
+++ b/tools/power_off_after_timeout_values.py
@@ -0,0 +1,38 @@
+#!/usr/bin/env python3
+
+# Helper script to calculate reboot_after_timeout_values
+
+collect_e = ["off"]
+collect_v = [0]
+
+def minutes(x):
+ return 60*1000*x
+
+def hours(x):
+ return 60*minutes(x)
+
+def show(x, fun):
+ v = fun(x)
+ print(f"{x} {fun.__name__} -> {v}")
+ collect_v.append(v)
+ collect_e.append(f"{fun.__name__}_{x}")
+
+show(10, minutes)
+show(30, minutes)
+show(1, hours)
+show(2, hours)
+show(4, hours)
+show(8, hours)
+show(12, hours)
+show(24, hours)
+show(36, hours)
+show(48, hours)
+show(72, hours)
+
+print("Entries:")
+for e in collect_e:
+ print(f" <item>@string/reboot_after_timeout_{e}</item>")
+
+print("Values:")
+for v in collect_v:
+ print(f" <item>{v}</item>")