Android Addon.d脚本无法正常运行

时间:2018-09-12 06:21:40

标签: android bash shell sh custom-rom

我有一个addon.d script,它在每次更新后都会删除不需要的应用程序,以使它们不会再次出现,但是似乎每当我更新设备时,不会执行引起该问题的代码。是否没有执行恢复功能,这就是为什么也没有执行恢复后功能的原因?我不知道怎么了。

#!/sbin/sh
#
# /system/addon.d/74-brs.sh
#
. /tmp/backuptool.functions

list_files() {
cat <<EOF
EOF
}

case "$1" in
  backup)
    list_files | while read FILE DUMMY; do
      backup_file $S/$FILE
    done
  ;;
  restore)
    list_files | while read FILE REPLACEMENT; do
      R=""
      [ -n "$REPLACEMENT" ] && R="$S/$REPLACEMENT"
      [ -f "$C/$S/$FILE" ] && restore_file $S/$FILE $R
    done
  ;;
  pre-backup)
    # Stub
  ;;
  post-backup)
    # Stub
  ;;
  pre-restore)
    # Stub
  ;;
  post-restore)
   rm -rf /system/app/Calendar
   rm -rf /system/app/Jelly
   rm -rf /system/app/messaging
  ;;
esac

新功能:

#!/sbin/sh
. /tmp/backuptool.functions

list_files() {
cat <<EOF
/system/app/Calendar/Calendar.apk
/system/app/Jelly/Jelly.apk
/system/app/messaging/messaging.apk
EOF
}

case "$1" in
  backup)
    list_files | while read FILE DUMMY; do
      backup_file $S/$FILE
    done
  ;;
  restore)
    list_files | while read FILE REPLACEMENT; do
      R=""
      [ -n "$REPLACEMENT" ] && R="$S/$REPLACEMENT"
      [ -f "$C/$S/$FILE" ] && restore_file $S/$FILE $R
    done
  ;;
  pre-backup)
    # Stub
  ;;
  post-backup)
    # Stub
  ;;
  pre-restore)
    # Stub
  ;;
  post-restore)
   rm -rf /system/app/Calendar
   rm -rf /system/app/Jelly
   rm -rf /system/app/messaging
  ;;
esac

1 个答案:

答案 0 :(得分:0)

虽然list_files()未返回受影响文件的列表,但这将无法正常工作...

list_files() {
cat <<EOF

# add all the files into here, directories do not matter. 

EOF
}

仅仅因为list_files | while read FILE DUMMY; do

list_files | while read FILE REPLACEMENT; do完全不起作用。

为了获得相关的文件名,您可以使用ls

ls -la /system/app/Calendar
ls -la /system/app/Jelly
ls -la /system/app/messaging

还要确保已以read/write模式重新安装了系统分区。