-
Notifications
You must be signed in to change notification settings - Fork 11
/
android-gpii.sh
executable file
·114 lines (100 loc) · 3.57 KB
/
android-gpii.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/bash
# GPII Android Install Script
#
# Copyright 2012 OCAD University
#
# Licensed under the New BSD license. You may not use this file except in
# compliance with this License.
#
# The research leading to these results has received funding from the European Union's
# Seventh Framework Programme (FP7/2007-2013)
# under grant agreement no. 289016.
#
# You may obtain a copy of the License at
# https://github.com/GPII/universal/blob/master/LICENSE.txt
gpii_dir="$(pwd)/.."
node_modules="$(pwd)/../node_modules"
universal="$(pwd)/../node_modules/universal"
repoURL="git://github.com/GPII/universal.git"
android_gpii_dir=$(pwd)
function gpii-start {
adb shell am start -W -c android.intent.category.LAUNCHER -a android.intent.action.MAIN -c android.intent.category.LAUNCHER 'net.gpii.app/net.gpii.app.GpiiActivity'
adb shell am broadcast -a org.meshpoint.anode.START -e cmdline '/sdcard/gpii/android/gpii.js'
}
function gpii-stopall {
adb shell am broadcast -a org.meshpoint.anode.STOPALL
}
function gpii-help {
echo "android-gpii utilities
Commands:
start - Starting gpii on the device
stop - Stop all node.js instances on device
help - Show this help
get-universal - clone the universal code and install it's dependencies
install-js - Install the gpii node.js code to the sdcard
install-privileged-apk - Installs the GpiiActivity in /system/app and then restarts the Android device
"
}
function gpii-get-universal-code {
if [ -d $node_modules ]; then
echo "$node_modules already exists"
else
echo "$node_modules does not exist"
echo "creating $node_modules"
mkdir -p "$node_modules"
fi
if [ -d $universal ]; then
echo "$universal already exists"
else
echo "$universal does not exist"
echo "cloning universal"
git clone "$repoURL" "$universal"
fi
cd $universal
npm install
cd $android_gpii_dir
}
function gpii-install-gpii {
cd $gpii_dir
if [ -d $node_modules ]; then
rm -fR build
fi
mkdir -p build/gpii/android
mkdir -p build/gpii/node_modules
cd build
cp -R $android_gpii_dir/gpii/node_modules ./gpii/android/
cp -R $universal ./gpii/node_modules/
cp $android_gpii_dir/gpii.js ./gpii/android/
cp $android_gpii_dir/index.js ./gpii/android/
cp $android_gpii_dir/package.json ./gpii/android/
tar czf gpii-android.tar.gz gpii
adb shell 'cd /sdcard; rm gpii-android.tar.gz; rm gpii-android.tar'
adb push gpii-android.tar.gz /sdcard/gpii-android.tar.gz
cd $android_gpii_dir
adb shell 'cd /sdcard; gunzip gpii-android.tar.gz; tar xvf gpii-android.tar'
}
function gpii-install-privileged-apk {
# Remount the /system filesystem as read/write. It is usually read only.
system_dev=$(adb shell 'mount | grep /system | awk '"'"'BEGIN{FS=" "} {print $1}'"'")
adb shell 'su -c "mount -o rw,remount -t yaffs2 $system_dev /system; chmod 777 /system/app"'
# Push the apk.
adb push platform/app/bin/GpiiApp-debug.apk /sdcard/
adb shell 'su -c "cp /sdcard/GpiiApp-debug.apk /system/app/; chmod 644 /system/app/GpiiApp-debug.apk"; rm /sdcard/GpiiApp-debug.apk'
# Remount again as read only.
adb shell 'su -c "chmod 755 /system/app; mount -o ro,remount -t yaffs2 $system_dev /system"'
echo "Restarting the Android device..."
adb reboot
}
if [ $1 = stop ]; then
gpii-stopall
elif [ $1 = start ]; then
gpii-start
elif [ $1 = get-universal ]; then
gpii-get-universal-code
elif [ $1 = install-js ]; then
gpii-install-gpii
elif [ $1 = install-privileged-apk ]; then
gpii-install-privileged-apk
else
gpii-help
fi