MTK平台在通话时降低充电电流

            整体逻辑:通话时,通话进程下发一个标志位,然后内核的充电进程读取该标志位,标志位为1时降低电流到450ma,标志位为0时恢复到800ma。

             注意点:4种状态判断,1、[通话,插充电器]----------0ma转成450ma

                                                    2、[非通话,充电器]--------0ma转成800ma

                                                    3、[充电,拨打电话]----------800ma转成450ma

                                                    4、[充电,挂断电话]----------450ma转成800ma


代码中需要的地方

1、通话下发标志位需要添加的地方


#	modified:   device/mediatek/common/sepolicy/file.te
#	modified:   device/mediatek/common/sepolicy/file_contexts
#	modified:   device/mediatek/common/sepolicy/system_server.te
#	modified:   device/mediatek/common/sepolicy/file.te
#	modified:   device/mediatek/common/sepolicy/file_contexts
#	modified:   device/mediatek/common/sepolicy/system_server.te

diff --git a/device/mediatek/common/sepolicy/file.te b/device/mediatek/common/sepolicy/file.te
index c9b7a91..f13ebba 100644
--- a/device/mediatek/common/sepolicy/file.te
+++ b/device/mediatek/common/sepolicy/file.te
@@ -16,7 +16,7 @@ type radvd_data_file, file_type, data_file_type;
 # Operation : Migration
 # Purpose : SF rtt dump
 type sf_rtt_file, file_type, data_file_type;
-
+type sys_charging_callstate_file, fs_type, sysfs_type;
 type dfo_socket, file_type;
 type rild2_socket, file_type;
 type rild3_socket, file_type;

diff --git a/device/mediatek/common/sepolicy/file_contexts b/device/mediatek/common/sepolicy/file_contexts
index 3a4fdd1..387abe8 100644
--- a/device/mediatek/common/sepolicy/file_contexts
+++ b/device/mediatek/common/sepolicy/file_contexts
@@ -295,7 +295,7 @@
 /sys/devices/platform/msensor/driver(/.*)?     u:object_r:sysfs_msensor_file:s0
 /sys/bus/platform/drivers/mtk-kpd(/.*)?        u:object_r:sysfs_keypad_file:s0
 /sys/power/vcorefs/pwr_ctrl -- u:object_r:sysfs_vcorefs_pwrctrl:s0
-
+/sys/device/platform/battery/Charging_CallState u:object_r:sys_charging_callstate_file:s0
 
 #############################
 # System files

diff --git a/device/mediatek/common/sepolicy/system_server.te b/device/mediatek/common/sepolicy/system_server.te
index e2b61f5..e2636ee 100755
--- a/device/mediatek/common/sepolicy/system_server.te
+++ b/device/mediatek/common/sepolicy/system_server.te
@@ -42,7 +42,7 @@ allow system_server mnld_data_file:sock_file create_file_perms;
 allow system_server mnld_data_file:sock_file rw_file_perms;
 allow system_server mnld_data_file:dir create_file_perms;
 allow system_server mnld_data_file:dir rw_dir_perms;
-
+allow system_server sys_charging_callstate_file:file {open write getattr};
 # Date : WK14.37
 # Operation : Migration 
 # Purpose : for idling on homescreen

diff --git a/packages/services/Telecomm/src/com/android/server/telecom/CallAudioManager.java b/packages/services/Telecomm/src/com/android/serv
index 20e9cd4..8cc4a39 100644
--- a/packages/services/Telecomm/src/com/android/server/telecom/CallAudioManager.java
+++ b/packages/services/Telecomm/src/com/android/server/telecom/CallAudioManager.java
@@ -904,6 +904,17 @@ final class CallAudioManager extends CallsManagerListenerBase
                 // Owner : yucong Xiong
                 // Set kpd as wake up source
                 // so that kpd can wak up Sysytem by Vol. key when phone suspend when talking
+               String callStateFilePath3 = String.format("/sys/devices/platform/battery/Charging_CallState"); 
+                 try { 
+                        int call_existed = (value == 2) ? 1 : 0; 
+                        String state3 = String.valueOf(call_existed); 
+                        FileWriter fw3 = new FileWriter(callStateFilePath3); 
+                        fw3.write(state3); 
+                        fw3.close(); 
+                        Log.v(this, "Call state for charging battery (call_existed =1, else = 0) is %s" + state3); 
+                 }catch(Exception e){ 
+                        Log.v(this, "", e); 
+                 } 
                 String callStateFilePath2 = String.format("/sys/bus/platform/mtk-kpd/driver/kpd_call_state");
                 try {
                     String state2 = String.valueOf(value);
@@ -914,6 +925,7 @@ final class CallAudioManager extends CallsManagerListenerBase
                 } catch (Exception e) {
                     Log.v(this, "" , e);
                 }
+
             }
         }).start();
     }

2、降低背光

#	modified:   frameworks/base/core/res/res/values/config.xml
#	modified:   frameworks/base/packages/SettingsProvider/res/values/defaults.xml

diff --git a/frameworks/base/core/res/res/values/config.xml b/frameworks/base/core/res/res/values/config.xml
index e6dfbd5..060371b 100644
--- a/frameworks/base/core/res/res/values/config.xml
+++ b/frameworks/base/core/res/res/values/config.xml
@@ -869,11 +869,11 @@
 
     <!-- Maximum screen brightness allowed by the power manager.
          The user is forbidden from setting the brightness above this level. -->
-    <integer name="config_screenBrightnessSettingMaximum">255</integer>
+    <integer name="config_screenBrightnessSettingMaximum">125</integer>
 
     <!-- Default screen brightness setting.
          Must be in the range specified by minimum and maximum. -->
-    <integer name="config_screenBrightnessSettingDefault">195</integer>
+    <integer name="config_screenBrightnessSettingDefault">95</integer>
 
     <!-- Screen brightness used to dim the screen while dozing in a very low power state.
          May be less than the minimum allowed brightness setting

diff --git a/frameworks/base/packages/SettingsProvider/res/values/defaults.xml b/frameworks/base/packages/SettingsProvider/res/values/defaults
index 4fa499e..4669f2f 100644
--- a/frameworks/base/packages/SettingsProvider/res/values/defaults.xml
+++ b/frameworks/base/packages/SettingsProvider/res/values/defaults.xml
@@ -32,7 +32,7 @@
 <!-- Modified by menglingqiang for [platform] default accelerometer rotation-->
     <bool name="def_accelerometer_rotation">false</bool>
     <!-- Default screen brightness, from 0 to 255.  102 is 40%. -->
-    <integer name="def_screen_brightness">195</integer>
+    <integer name="def_screen_brightness">95</integer>
     <bool name="def_screen_brightness_automatic_mode">false</bool>
     <fraction name="def_window_animation_scale">100%</fraction>
     <fraction name="def_window_transition_scale">100%</fraction>

3、降低充电电流

#	modified:   kernel-3.10/drivers/power/mediatek/al712_32bit_battery_common.c
#	modified:   kernel-3.10/drivers/power/mediatek/linear_charging.c

diff --git a/kernel-3.10/drivers/power/mediatek/al712_32bit_battery_common.c b/kernel-3.10/drivers/power/mediatek/al712_32bit_battery_common.c
index 5216fb1..344e3da 100644
--- a/kernel-3.10/drivers/power/mediatek/al712_32bit_battery_common.c
+++ b/kernel-3.10/drivers/power/mediatek/al712_32bit_battery_common.c
@@ -2770,7 +2770,7 @@ void mt_battery_notify_check(void)
                        //mark by chenlei2
                //mt_battery_notify_VBatTemp_check();
 
-               //mt_battery_notify_VBatTemp_check();
+               mt_battery_notify_VBatTemp_check();
 
                mt_battery_notify_ICharging_check();
 
@@ -3105,7 +3105,7 @@ void do_chrdet_int_task(void)
 
 }
 
-
+unsigned int flag_call = 1;
 void BAT_thread(void)
 {
        static kal_bool battery_meter_initilized = KAL_FALSE;
@@ -3122,9 +3122,32 @@ void BAT_thread(void)
        }
        mt_battery_thermal_check();
        mt_battery_notify_check();
-    if(upmu_is_chr_det() == KAL_TRUE) //only for charge by chenlei2
+   if(upmu_is_chr_det() == KAL_TRUE) //only for charge by chenlei2
     { 
-       set_lenovo_charger_status();//add by chenlei2
+       if(g_call_state == 1)
+       {
+               if(flag_call == 1)
+               {
+                       set_bat_charging_current_limit(450);
+                       flag_call=2;
+               }
+       }
+       else{
+               if(flag_call == 2)
+               {
+                       flag_call = 1;
+                       set_bat_charging_current_limit(800);
+               }
+       }
+       //set_lenovo_charger_status();//add by chenlei2
+    }else{
+         if(g_call_state == 1)
+       {
+                       flag_call=1;
+       }
+       else{
+                       flag_call = 2;
+       }
     }
        if (BMT_status.charger_exist == KAL_TRUE) {     
                mt_battery_CheckBatteryStatus();

diff --git a/kernel-3.10/drivers/power/mediatek/linear_charging.c b/kernel-3.10/drivers/power/mediatek/linear_charging.c
index 94fc30c..e712772 100644
--- a/kernel-3.10/drivers/power/mediatek/linear_charging.c
+++ b/kernel-3.10/drivers/power/mediatek/linear_charging.c
@@ -811,7 +811,9 @@ void select_charging_curret(void)
                } else if (BMT_status.charger_type == NONSTANDARD_CHARGER) {
                        g_temp_CC_value = NON_STD_AC_CHARGER_CURRENT;
                } else if (BMT_status.charger_type == STANDARD_CHARGER) {
+                       if(g_call_state == 0)
                        g_temp_CC_value = AC_CHARGER_CURRENT;
+                       else g_temp_CC_value = CHARGE_CURRENT_450_00_MA;
 #if defined(CONFIG_MTK_PUMP_EXPRESS_SUPPORT)
                        if(is_ta_connect == KAL_TRUE && ta_vchr_tuning == KAL_TRUE)
                                g_temp_CC_value = CHARGE_CURRENT_1500_00_MA;
@@ -1074,11 +1076,11 @@ PMU_STATUS BAT_PreChargeModeAction(void)
        // no disable charging
 #else
        {
-               //kal_bool charging_enable = KAL_FALSE;
+               kal_bool charging_enable = KAL_FALSE;
 
                /*Charging 9s and discharging 1s : start */
-               //battery_charging_control(CHARGING_CMD_ENABLE, &charging_enable);
-               //msleep(1000);
+               battery_charging_control(CHARGING_CMD_ENABLE, &charging_enable);
+               msleep(4000);//充6停4
        }
 #endif
 
@@ -1110,11 +1112,11 @@ PMU_STATUS BAT_ConstantCurrentModeAction(void)
        // no disable charging#else
 #else
        {
-               //kal_bool charging_enable = KAL_FALSE;
+               kal_bool charging_enable = KAL_FALSE;
 
                /* Charging 9s and discharging 1s : start */
-               //battery_charging_control(CHARGING_CMD_ENABLE, &charging_enable);
-               //msleep(1000);
+               battery_charging_control(CHARGING_CMD_ENABLE, &charging_enable);
+               msleep(4000);//充6停4
        }       
 #endif

4、修改版本号

adbremount

adbpull /system/build.prop

修改build.prop中的版本号和时间点

adbpush build.prop /system/build.prop






你可能感兴趣的:(MTK平台在通话时降低充电电流)