OSDN Git Service

init.sh: set camera properties for Microtech e-tab Pro
[android-x86/device-generic-common.git] / nativebridge / bin / enable_nativebridge
1 #!/system/bin/sh
2
3 PATH=/system/bin:/system/xbin
4
5 houdini_bin=0
6 dest_dir=/system/lib$1/arm$1
7 binfmt_misc_dir=/proc/sys/fs/binfmt_misc
8
9 if [ -z "$1" ]; then
10         if [ "`uname -m`" = "x86_64" ]; then
11                 v=7_y
12                 url=http://goo.gl/SBU3is
13         else
14                 v=7_x
15                 url=http://goo.gl/0IJs40
16         fi
17 else
18         v=7_z
19         url=http://goo.gl/FDrxVN
20 fi
21
22 if [ -s /system/lib$1/libhoudini.so ]; then
23         log -pi -thoudini "found /system/lib$1/libhoudini.so"
24 elif [ -e /system/etc/houdini$v.sfs ]; then
25         mount /system/etc/houdini$v.sfs $dest_dir
26 else
27         if mountpoint -q $dest_dir; then
28                 kill -9 `fuser -m $dest_dir`
29                 umount -f $dest_dir
30         fi
31         mkdir -p /data/arm
32         cd /data/arm
33         while ! mount houdini$v.sfs $dest_dir; do
34                 while [ "$(getprop net.dns1)" = "" ]; do
35                         sleep 10
36                 done
37                 wget $url -cO houdini$v.sfs && continue
38                 rm -f houdini$v.sfs
39                 sleep 30
40         done
41 fi
42
43 [ -s /system/lib$1/libhoudini.so ] || mount --bind $dest_dir/libhoudini.so /system/lib$1/libhoudini.so
44
45 # this is to add the supported binary formats via binfmt_misc
46
47 if [ ! -e $binfmt_misc_dir/register ]; then
48         mount -t binfmt_misc none $binfmt_misc_dir
49 fi
50
51 cd $binfmt_misc_dir
52 if [ -e register ]; then
53         [ -e /system/bin/houdini$1 ] && dest_dir=/system/bin
54         # register Houdini for arm binaries
55         if [ -z "$1" ]; then
56                 echo ':arm_exe:M::\\x7f\\x45\\x4c\\x46\\x01\\x01\\x01\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x02\\x00\\x28::'"$dest_dir/houdini:P" > register
57                 echo ':arm_dyn:M::\\x7f\\x45\\x4c\\x46\\x01\\x01\\x01\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x03\\x00\\x28::'"$dest_dir/houdini:P" > register
58         else
59                 echo ':arm64_exe:M::\\x7f\\x45\\x4c\\x46\\x02\\x01\\x01\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x02\\x00\\xb7::'"$dest_dir/houdini64:P" > register
60                 echo ':arm64_dyn:M::\\x7f\\x45\\x4c\\x46\\x02\\x01\\x01\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x03\\x00\\xb7::'"$dest_dir/houdini64:P" > register
61         fi
62         if [ -e arm${1}_exe ]; then
63                 houdini_bin=1
64         fi
65 else
66         log -pe -thoudini "No binfmt_misc support"
67 fi
68
69 if [ $houdini_bin -eq 0 ]; then
70         log -pe -thoudini "houdini$1 enabling failed!"
71 else
72         log -pi -thoudini "houdini$1 enabled"
73 fi
74
75 [ "$(getprop ro.zygote)" = "zygote64_32" -a -z "$1" ] && exec $0 64
76
77 exit 0