Zvikomborero VIncent Zvikaramba | e1d0061 | 2016-07-25 19:51:44 -0400 | [diff] [blame^] | 1 | #!/system/xbin/bash |
| 2 | |
| 3 | MODE=`getprop debug.rilswitch` |
| 4 | |
| 5 | SEC_PATH=/system/rilswitch/sec/ |
| 6 | CAF_PATH=/system/rilswitch/caf/ |
| 7 | |
| 8 | RILD_PATH=bin/rild |
| 9 | REF_RIL_PATH=lib/libreference-ril.so |
| 10 | LIBRIL_PATH=lib/libril.so |
| 11 | LIBRILUTIL_PATH=lib/librilutils.so |
| 12 | SECRIL_C_PATH=lib/libsecril-client.so |
| 13 | |
| 14 | #remount the system |
| 15 | mount -o remount,rw /system |
| 16 | |
| 17 | #make the directories if they don't already exist |
| 18 | mkdir -p $CAF_PATH |
| 19 | |
| 20 | |
| 21 | if [ $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 |
| 50 | fi |
| 51 | if [ $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 |
| 71 | fi |
| 72 | #set permissions |
| 73 | chmod 0655 /system/$RILD_PATH |
| 74 | chmod 0644 /system/$REF_RIL_PATH |
| 75 | chmod 0644 /system/$LIBRIL_PATH |
| 76 | chmod 0644 /system/$LIBRILUTIL_PATH |
| 77 | chmod 0644 /system/$SECRIL_C_PATH |
| 78 | |
| 79 | #unset the property |
| 80 | setprop debug.rilswitch none |
| 81 | |
| 82 | #remount the system |
| 83 | mount -o remount,ro /system |
| 84 | |
| 85 | |
| 86 | |
| 87 | |
| 88 | |
| 89 | |
| 90 | |