From a93e48719433a32aab3b39c6b40a0fd7827d85bc Mon Sep 17 00:00:00 2001 From: Seok Hong Date: Fri, 23 Dec 2016 16:21:15 +0900 Subject: [PATCH] Add preferences/settings management script Change-Id: Idf6adb04b376a454fc965c135e4dcefadd329342 Signed-off-by: Seok Hong Signed-off-by: Jaemin Ryu --- packaging/device-policy-manager.spec | 1 + tools/cli/CMakeLists.txt | 4 ++- tools/cli/dpm-preference | 56 ++++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 1 deletion(-) create mode 100755 tools/cli/dpm-preference diff --git a/packaging/device-policy-manager.spec b/packaging/device-policy-manager.spec index c9e3dbb..6a23b6c 100755 --- a/packaging/device-policy-manager.spec +++ b/packaging/device-policy-manager.spec @@ -56,6 +56,7 @@ managing device policies. %attr(755,root,root) %{_bindir}/device-policy-manager %attr(700,root,root) %{_bindir}/dpm-admin-cli %attr(755,root,root) %{_bindir}/dpm-syspopup +%attr(755,root,root) %{_bindir}/dpm-preference %{_unitdir}/device-policy-manager.service %{_unitdir}/multi-user.target.wants/device-policy-manager.service diff --git a/tools/cli/CMakeLists.txt b/tools/cli/CMakeLists.txt index 17c9f29..6c40d16 100644 --- a/tools/cli/CMakeLists.txt +++ b/tools/cli/CMakeLists.txt @@ -14,7 +14,8 @@ # limitations under the License. # SET(DPM_ADMIN_CLI_TARGET "dpm-admin-cli") -SET(DPM_SYSPOPUP_TARGET "dpm-syspopup") +SET(DPM_SYSPOPUP_TARGET "dpm-syspopup") +SET(DPM_PREFERENCE_TARGET "dpm-preference") SET(DPM_ADMIN_CLI_SOURCES dpm-admin-cli.cpp) @@ -24,5 +25,6 @@ INCLUDE_DIRECTORIES(SYSTEM ${DPM_LIBS}) TARGET_LINK_LIBRARIES(${DPM_ADMIN_CLI_TARGET} dpm) +INSTALL(FILES ${DPM_PREFERENCE_TARGET} DESTINATION bin) INSTALL(FILES ${DPM_SYSPOPUP_TARGET} DESTINATION bin) INSTALL(TARGETS ${DPM_ADMIN_CLI_TARGET} DESTINATION bin) diff --git a/tools/cli/dpm-preference b/tools/cli/dpm-preference new file mode 100755 index 0000000..9fcdf9b --- /dev/null +++ b/tools/cli/dpm-preference @@ -0,0 +1,56 @@ +#! /bin/bash + +PATH=/usr/bin:/bin/usr/sbin:/sbin + +DB_PATH="/opt/dbspace/.dpm.db" + +usage() +{ + /bin/cat << EOF +usage: + $1 [-a|--admin=] + +Options: + -a,--admin Declare device policy admin package + -u,--user Admin package owner id(must be uid) + -h,--help print this help +EOF + return 0 +} + +options=$(getopt -o ha:u: -l help,admin:,user: -- "$@") +if [ $? -ne 0 ]; then + usage $(basename $0) + exit 1 +fi +eval set -- "$options" + +while true +do + case "$1" in + -h|--help) usage $0 && exit 0;; + -a|--admin) admin=$2; shift 2;; + -u|--user) uid=$2; shift 2;; + --) shift 1; break ;; + *) break ;; + esac +done + +if [ -z "$admin" ]; then + echo "'admin' parameter is required" +fi + +if [ -z "$uid" ]; then + echo "'user' parameter is required" +fi + +# Execution +sqlite3 ${DB_PATH} \ +"CREATE TABLE IF NOT EXISTS admin ( \ + id INTEGER PRIMARY KEY AUTOINCREMENT, \ + pkg TEXT NOT NULL, \ + uid INTEGER, \ + key TEXT, \ + removable INTEGER \ +); \ +INSERT INTO admin (pkg, uid, key, removable) VALUES ('$admin', $uid, '', 0);" -- 2.7.4