This can be convenient when using the shell.

Alternatively it could also help users with broken power buttons.

Signed-off-by: Denis 'GNUtoo' Carikli <gnu...@cyberdimension.org>
---
 power/Android.mk               | 14 ++++++++++++++
 power/device-files/reboot.sh   |  5 +++++
 power/device-files/shutdown.sh |  5 +++++
 power/setup.sh                 | 12 ++++++++++++
 4 files changed, 36 insertions(+)
 create mode 100644 power/Android.mk
 create mode 100755 power/device-files/reboot.sh
 create mode 100755 power/device-files/shutdown.sh
 create mode 100755 power/setup.sh

diff --git a/power/Android.mk b/power/Android.mk
new file mode 100644
index 0000000..8e7671f
--- /dev/null
+++ b/power/Android.mk
@@ -0,0 +1,14 @@
+# Ship the scripts on the device
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := reboot.sh
+LOCAL_SRC_FILES := device-files/reboot.sh
+LOCAL_MODULE_CLASS := EXECUTABLES
+include $(BUILD_PREBUILT)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := shutdown.sh
+LOCAL_SRC_FILES := device-files/shutdown.sh
+LOCAL_MODULE_CLASS := EXECUTABLES
+include $(BUILD_PREBUILT)
diff --git a/power/device-files/reboot.sh b/power/device-files/reboot.sh
new file mode 100755
index 0000000..f03b36d
--- /dev/null
+++ b/power/device-files/reboot.sh
@@ -0,0 +1,5 @@
+#!/system/xbin/bash
+# References:
+# 
https://android.googlesource.com/platform/frameworks/base/+/android-4.1.1_r1/core/res/AndroidManifest.xml#1723
+# 
https://android.stackexchange.com/questions/43706/whats-the-best-way-to-restart-android-via-command-line-remotely/139139#139139
+am start -a android.intent.action.REBOOT
diff --git a/power/device-files/shutdown.sh b/power/device-files/shutdown.sh
new file mode 100755
index 0000000..2875b6a
--- /dev/null
+++ b/power/device-files/shutdown.sh
@@ -0,0 +1,5 @@
+#!/system/xbin/bash
+# References:
+# 
https://android.googlesource.com/platform/frameworks/base/+/android-4.1.1_r1/core/res/AndroidManifest.xml#1723
+# 
https://android.stackexchange.com/questions/43706/whats-the-best-way-to-restart-android-via-command-line-remotely/139139#139139
+am start -a android.intent.action.ACTION_REQUEST_SHUTDOWN
diff --git a/power/setup.sh b/power/setup.sh
new file mode 100755
index 0000000..90a8be2
--- /dev/null
+++ b/power/setup.sh
@@ -0,0 +1,12 @@
+#!/bin/sh
+topdir=$(dirname $0)
+adb root | grep "^root access"
+ret="$?"
+if [ "${ret}" -ne 0 ] ; then
+       adb wait-for-device
+       adb remount
+       adb push "${topdir}/device-files/reboot.sh"   /system/bin/
+       adb push "${topdir}/device-files/shutdown.sh" /system/bin/
+       adb shell "mount -o remount,ro /system"
+       adb shell "sync"
+fi
-- 
2.30.1

_______________________________________________
Replicant mailing list
Replicant@osuosl.org
https://lists.osuosl.org/mailman/listinfo/replicant

Reply via email to