blob: e91a19054e6aac3f9e58efc0e2f11fb3c584153a [file] [log] [blame]
Zvikomborero VIncent Zvikarambae1d00612016-07-25 19:51:44 -04001#!/system/xbin/bash
2
3MODE=`getprop debug.rilswitch`
4
5SEC_PATH=/system/rilswitch/sec/
6CAF_PATH=/system/rilswitch/caf/
7
8RILD_PATH=bin/rild
9REF_RIL_PATH=lib/libreference-ril.so
10LIBRIL_PATH=lib/libril.so
11LIBRILUTIL_PATH=lib/librilutils.so
12SECRIL_C_PATH=lib/libsecril-client.so
13
14#remount the system
15mount -o remount,rw /system
16
17#make the directories if they don't already exist
18mkdir -p $CAF_PATH
19
20
21if [ $MODE == "sec" ]; then
22 #make directories
23 mkdir -p $CAF_PATH/lib
24 mkdir -p $CAF_PATH/bin
25 #backup the caf files
26 cp -p /system/$RILD_PATH $CAF_PATH/$RILD_PATH
27 cp -p /system/$REF_RIL_PATH $CAF_PATH/$REF_RIL_PATH
28 cp -p /system/$LIBRIL_PATH $CAF_PATH/$LIBRIL_PATH
29 cp -p /system/$LIBRILUTIL_PATH $CAF_PATH/$LIBRILUTIL_PATH
30 cp -p /system/$SECRIL_C_PATH $CAF_PATH/$SECRIL_C_PATH
31
32 #kill rild
33 kill `pidof rild`
34 mv /system/$RILD_PATH /system/$RILD_PATH.old
35 cp $SEC_PATH/$RILD_PATH /system/$RILD_PATH
36 cp $SEC_PATH/$REF_RIL_PATH /system/$REF_RIL_PATH
37 cp $SEC_PATH/$LIBRIL_PATH /system/$LIBRIL_PATH
38 cp $SEC_PATH/$LIBRILUTIL_PATH /system/$LIBRILUTIL_PATH
39 cp $SEC_PATH/$SECRIL_C_PATH /system/$SECRIL_C_PATH
40 rm /system/$RILD_PATH.old
41 #check if we copied successfully
42 if [ $? != 0 ]; then
43 #kill rild again for good measure
44 kill `pidof rild`
45 #copy again
46 mv /system/$RILD_PATH /system/$RILD_PATH.old
47 cp $SEC_PATH/$RILD_PATH /system/$RILD_PATH
48 rm /system/$RILD_PATH.old
49 fi
50fi
51if [ $MODE == "caf" ]; then
52 #kill rild
53 kill `pidof rild`
54 mv /system/$RILD_PATH /system/$RILD_PATH.old
55 cp $CAF_PATH/$RILD_PATH /system/$RILD_PATH
56 cp $CAF_PATH/$REF_RIL_PATH /system/$REF_RIL_PATH
57 cp $CAF_PATH/$LIBRIL_PATH /system/$LIBRIL_PATH
58 cp $CAF_PATH/$LIBRILUTIL_PATH /system/$LIBRILUTIL_PATH
59 cp $CAF_PATH/$SECRIL_C_PATH /system/$SECRIL_C_PATH
60 rm /system/$RILD_PATH.old
61
62 #check if we copied successfully
63 if [ $? != 0 ]; then
64 #kill rild again for good measure
65 kill `pidof rild`
66 #copy again
67 mv /system/$RILD_PATH /system/$RILD_PATH.old
68 cp $CAF_PATH/$RILD_PATH /system/$RILD_PATH
69 rm /system/$RILD_PATH.old
70 fi
71fi
72#set permissions
73chmod 0655 /system/$RILD_PATH
74chmod 0644 /system/$REF_RIL_PATH
75chmod 0644 /system/$LIBRIL_PATH
76chmod 0644 /system/$LIBRILUTIL_PATH
77chmod 0644 /system/$SECRIL_C_PATH
78
79#unset the property
80setprop debug.rilswitch none
81
82#remount the system
83mount -o remount,ro /system
84
85
86
87
88
89
90