@@ -18,7 +18,6 @@ function atexit()
1818
1919log=$( mktemp)
2020trap " atexit" EXIT
21- failures=0
2221
2322function compile_module()
2423{
@@ -38,6 +37,37 @@ function wait_for_boot_completed()
3837 $adb wait-for-device logcat | grep -m 1 -e ' PowerManagerService.*bootCompleted' > /dev/null
3938}
4039
40+ function mkdir_if_needed()
41+ {
42+ local path=" $1 "
43+
44+ if [[ " ${path: 0: 1} " != " /" ]]; then
45+ echo " mkdir_if_needed: error: path '$path ' does not begin with /" | tee -a $log
46+ exit 1
47+ fi
48+
49+ local basename=$( basename " $path " )
50+ local dirname=$( dirname " $path " )
51+ local t=$( $adb shell ls -l $dirname | tr -d ' \r' | grep -e " ${basename} $" | grep -oe ' ^.' )
52+
53+ case " $t " in
54+ d) # File exists, and is a directory ...
55+ # do nothing
56+ ;;
57+ l) # ... (or symbolic link possibly to a directory).
58+ # do nothing
59+ ;;
60+ " " ) # File does not exist.
61+ mkdir_if_needed " $dirname "
62+ $adb shell mkdir " $path "
63+ ;;
64+ * ) # File exists, but is not a directory.
65+ echo " mkdir_if_needed: file '$path ' exists, but is not a directory" | tee -a $log
66+ exit 1
67+ ;;
68+ esac
69+ }
70+
4171function disable_overlay()
4272{
4373 echo " Disabling overlay"
@@ -48,6 +78,8 @@ function disable_overlay()
4878function enable_overlay()
4979{
5080 echo " Enabling overlay"
81+ mkdir_if_needed " /system/vendor"
82+ mkdir_if_needed " /vendor/overlay/framework"
5183 $adb shell ln -s /data/app/com.android.overlaytest.overlay.apk /vendor/overlay/framework/framework-res.apk
5284}
5385
@@ -59,13 +91,21 @@ function instrument()
5991 $adb shell am instrument -w -e class $class com.android.overlaytest/android.test.InstrumentationTestRunner | tee -a $log
6092}
6193
94+ function remount()
95+ {
96+ echo " Remounting file system writable"
97+ $adb remount | tee -a $log
98+ }
99+
62100function sync()
63101{
64102 echo " Syncing to device"
65- $adb remount | tee -a $log
66103 $adb sync data | tee -a $log
67104}
68105
106+ # some commands require write access, remount once and for all
107+ remount
108+
69109# build and sync
70110compile_module " $PWD /OverlayTest/Android.mk"
71111compile_module " $PWD /OverlayTestOverlay/Android.mk"
0 commit comments