Android教程網
  1. 首頁
  2. Android 技術
  3. Android 手機
  4. Android 系統教程
  5. Android 游戲
 Android教程網 >> Android技術 >> Android開發 >> 關於android開發 >> MSM8909+Android5---DC無法喚醒系統、無法充電和充電指示不正常問題

MSM8909+Android5---DC無法喚醒系統、無法充電和充電指示不正常問題

編輯:關於android開發

MSM8909+Android5---DC無法喚醒系統、無法充電和充電指示不正常問題


DC充電器:只有5V和GND兩根線,也就是說接入DC,USB檢測的D+和D-是懸空的。

1. 接入DC充電器顯示充電圖標,但沒有閃電標識問題

/frameworks/base/services/core/java/com/android/server/BatteryService.java下sendIntentLocked()函數
//intent.putExtra(BatteryManager.EXTRA_PLUGGED,mPlugType);//kandi mark
//kandi add
       if( mBatteryProps.batteryStatus == BatteryManager.BATTERY_STATUS_CHARGING ||
            mBatteryProps.batteryStatus ==  BatteryManager.BATTERY_STATUS_FULL ){
               intent.putExtra(BatteryManager.EXTRA_PLUGGED, mPlugType |BatteryManager.BATTERY_PLUGGED_AC
                                                                       |BatteryManager.BATTERY_PLUGGED_USB
                                                                       | BatteryManager.BATTERY_PLUGGED_WIRELESS);
           }else {
               intent.putExtra(BatteryManager.EXTRA_PLUGGED, BATTERY_PLUGGED_NONE);
        }

此函數是發ACTION_BATTERY_CHANGED廣播的。上面解決版本是我們核心板廠家給出來的,但存在幾個問題:

(1) 不管是AC、USB、WIRELESS還是DC,設備Battery status顯示的都是Charging

因為mPlugType或AC或USB或WIRELESS,以至於APP層判斷為unknown類型,見\packages\apps\Settings\src\com\android\setting\Utils.java的onReceive()相關代碼

public static String getBatteryStatus(Resources res, IntentbatteryChangedIntent) {
       final Intent intent = batteryChangedIntent;
 
       int plugType = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, 0);
       int status = intent.getIntExtra(BatteryManager.EXTRA_STATUS,
               BatteryManager.BATTERY_STATUS_UNKNOWN);
       String statusString;
       if (status == BatteryManager.BATTERY_STATUS_CHARGING) {
           int resId;
           if (plugType == BatteryManager.BATTERY_PLUGGED_AC) {
                resId =R.string.battery_info_status_charging_ac;
           } else if (plugType == BatteryManager.BATTERY_PLUGGED_USB) {
                resId =R.string.battery_info_status_charging_usb;
           } else if (plugType == BatteryManager.BATTERY_PLUGGED_WIRELESS) {
                resId =R.string.battery_info_status_charging_wireless;
           } else {
                resId =R.string.battery_info_status_charging;//Charging
           }
           statusString = res.getString(resId);
       } else if (status == BatteryManager.BATTERY_STATUS_DISCHARGING) {
           statusString = res.getString(R.string.battery_info_status_discharging);
       } else if (status == BatteryManager.BATTERY_STATUS_NOT_CHARGING) {
           statusString =res.getString(R.string.battery_info_status_not_charging);
       } else if (status == BatteryManager.BATTERY_STATUS_FULL) {
           statusString = res.getString(R.string.battery_info_status_full);
       } else {
           statusString = res.getString(R.string.battery_info_status_unknown);
       }
 
       return statusString;
    }

(2) 充滿的情況下,還顯示閃電標識,見if裡面的條件。

2. DC無法充電問題

雖然顯示充電,但是實際不能充電,廠家給出的解決方案是在kernel\drivers\power\qpnp-linear-charger.c下的

qpnp_batt_external_power_changed函數增加下面的代碼

if (qpnp_lbc_is_usb_chg_plugged_in(chip)) {
              chip->usb_psy->get_property(chip->usb_psy,
                            POWER_SUPPLY_PROP_CURRENT_MAX,&ret);
              current_ma= ret.intval / 1000;
 
              pr_debug("simcomcurent ma =%d \n",current_ma);
              //kandiadd start
              chip->usb_psy->get_property(chip->usb_psy,
                            POWER_SUPPLY_PROP_TYPE,&ret);
              pr_debug("simcomusb type =%d \n",ret.intval);
             
              if(USB_SDP_CHARGER== ret.intval ){    // already checked asusb
                     current_ma=500;
              }elseif (USB_DCP_CHARGER == ret.intval ||  USB_CDP_CHARGER == ret.intval){   // checked as AC
                     current_ma=1500;
              }else{
                     current_ma=1500;   //charging and can't  be reginazed, type as DC,
              }
              //kandiadd end

3. 休眠狀態接入DC無法喚醒系統問題

\kernel\drivers\usb\phy\ phy-msm-usb.c把floated_charger_enable賦值為1就可以解決此問題,也就是:

static bool floated_charger_enable =1;

相關的代碼見msm_chg_detect_work()的USB_CHG_STATE_DCD_DONE這個case下的:

if (line_state) /* DP > VLGC or/and DM> VLGC */
                            motg->chg_type= USB_PROPRIETARY_CHARGER;
                     elseif (!dcd && floated_charger_enable)
                            motg->chg_type= USB_FLOATED_CHARGER;
                     else
                            motg->chg_type= USB_SDP_CHARGER;
 
                     motg->chg_state= USB_CHG_STATE_DETECTED;
                     delay= 0;

使能floated charger,對應的chg_type為USB_FLOATED_CHARGER,如果是此類型,通過msm_otg_notify_chg_type()重新映射為POWER_SUPPLY_TYPE_USB_DCP,/* Dedicated Charging Port */,然後再發給用戶層。

解決了此問題後,上面第1和第2部分代碼都不需要增加也都正常。

  1. 上一頁:
  2. 下一頁:
熱門文章
閱讀排行版
Copyright © Android教程網 All Rights Reserved