Advertisement
Guest User

btwalncoex

a guest
Jul 29th, 2014
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.68 KB | None | 0 0
  1. #!/system/bin/sh
  2. # Copyright (c) 2009-2010, 2012, The Linux Foundation. All rights reserved.
  3. #
  4. # Redistribution and use in source and binary forms, with or without
  5. # modification, are permitted provided that the following conditions are met:
  6. #     * Redistributions of source code must retain the above copyright
  7. #       notice, this list of conditions and the following disclaimer.
  8. #     * Redistributions in binary form must reproduce the above copyright
  9. #       notice, this list of conditions and the following disclaimer in the
  10. #       documentation and/or other materials provided with the distribution.
  11. #     * Neither the name of The Linux Foundation nor
  12. #       the names of its contributors may be used to endorse or promote
  13. #       products derived from this software without specific prior written
  14. #       permission.
  15. #
  16. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  17. # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  18. # IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  19. # NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  20. # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  21. # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  22. # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  23. # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  24. # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  25. # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  26. # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27.  
  28. LOG_TAG="qcom-bt-wlan-coex"
  29. LOG_NAME="${0}:"
  30.  
  31. coex_pid=""
  32. ath_wlan_supported=`getprop wlan.driver.ath`
  33.  
  34. loge ()
  35. {
  36.   /system/bin/log -t $LOG_TAG -p e "$LOG_NAME $@"
  37. }
  38.  
  39. logi ()
  40. {
  41.   /system/bin/log -t $LOG_TAG -p i "$LOG_NAME $@"
  42. }
  43.  
  44. failed ()
  45. {
  46.   loge "$1: exit code $2"
  47.   exit $2
  48. }
  49.  
  50. start_coex ()
  51. {
  52.   case "$ath_wlan_supported" in
  53.       "2")
  54.        echo "ATH WLAN Chip ID AR6004 is enabled"
  55.        /system/bin/abtfilt -d -z -n -m -a -w wlan0 &
  56.       ;;
  57.       "1")
  58.        echo "ATH WLAN Chip ID is enabled"
  59.        # Must have -d -z -n -v -s -w wlan0 parameters for atheros btfilter.
  60.        /system/bin/abtfilt -d -z -n -v -q -s -w wlan0 &
  61.       ;;
  62.       "0")
  63.        echo "WCN WLAN Chip ID is enabled"
  64.        # Must have -o turned on to avoid daemon (otherwise we cannot get pid)
  65.        /system/bin/btwlancoex -o $opt_flags &
  66.       ;;
  67.       *)
  68.        echo "NO WLAN Chip ID is enabled, so enabling ATH as default"
  69.        # Must have -d -z -n -v -s -w wlan0 parameters for atheros btfilter.
  70.        /system/bin/abtfilt -d -z -n -v -q -s -w wlan0 &
  71.       ;;
  72.   esac
  73.   coex_pid=$!
  74.   logi "start_coex: pid = $coex_pid"
  75. }
  76.  
  77. kill_coex ()
  78. {
  79.   logi "kill_coex: pid = $coex_pid"
  80.   kill -TERM $coex_pid
  81.   # this shell doesn't exit now -- wait returns for normal exit
  82. }
  83.  
  84. # mimic coex options parsing -- maybe a waste of effort
  85. USAGE="${0} [-o] [-c] [-r] [-i] [-h]"
  86.  
  87. while getopts "ocrih" f
  88. do
  89.   case $f in
  90.   o | c | r | i | h)  opt_flags="$opt_flags -$f" ;;
  91.   \?)     echo $USAGE; exit 1;;
  92.   esac
  93. done
  94.  
  95. # init does SIGTERM on ctl.stop for service
  96. trap "kill_coex" TERM INT
  97.  
  98. #Selectively start coex module
  99. target=`getprop ro.board.platform`
  100.  
  101. if [ "$target" == "msm8960" ] && [ "$ath_wlan_supported" != "2" ]; then
  102.      logi "btwlancoex/abtfilt is not needed"
  103. else
  104.      # Build settings may not produce the coex executable
  105.      if ls /system/bin/btwlancoex || ls /system/bin/abtfilt
  106.      then
  107.          start_coex
  108.          wait $coex_pid
  109.          logi "Coex stopped"
  110.      else
  111.          logi "btwlancoex/abtfilt not available"
  112.      fi
  113. fi
  114. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement