%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
# 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)
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)
--- /dev/null
+#! /bin/bash
+
+PATH=/usr/bin:/bin/usr/sbin:/sbin
+
+DB_PATH="/opt/dbspace/.dpm.db"
+
+usage()
+{
+ /bin/cat << EOF
+usage:
+ $1 [-a|--admin=<pkgid>]
+
+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);"