• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

system/corennnnn


Commit MetaInfo

Revision8cca0a3855239e3503f861d35ab9ec108ac66123 (tree)
Time2010-02-27 16:12:48
AuthorChih-Wei Huang <cwhuang@linu...>
CommiterChih-Wei Huang

Log Message

patch from Yi Sun to fix power status issue

Change Summary

Incremental Difference

--- a/include/cutils/properties.h
+++ b/include/cutils/properties.h
@@ -28,7 +28,7 @@ extern "C" {
2828 ** WARNING: system/bionic/include/sys/system_properties.h also defines
2929 ** these, but with different names. (TODO: fix that)
3030 */
31-#define PROPERTY_KEY_MAX 32
31+#define PROPERTY_KEY_MAX 128
3232 #define PROPERTY_VALUE_MAX 92
3333
3434 /* property_get: returns the length of the value which will never be
--- a/vold/uevent.c
+++ b/vold/uevent.c
@@ -21,6 +21,7 @@
2121
2222 #include <sys/types.h>
2323 #include <sys/socket.h>
24+#include <cutils/properties.h>
2425
2526 #include "vold.h"
2627 #include "uevent.h"
@@ -214,16 +215,31 @@ static void free_uevent(struct uevent *event)
214215 }
215216 free(event);
216217 }
218+/*
219+ * This function can not find correct parameter for certain cases
220+ * for example, if you have xxx_bla and xxx, you will have no way
221+ * to know whether xxx_bla or xxx will be matched.
222+ * So to solve this issue, try to match with "="
223+ */
224+
217225
218226 static char *get_uevent_param(struct uevent *event, char *param_name)
219227 {
220228 int i;
229+ char buf[MAX_UEVENT_NAME_LEN];
221230
222231 for (i = 0; i < UEVENT_PARAMS_MAX; i++) {
223232 if (!event->param[i])
224233 break;
225- if (!strncmp(event->param[i], param_name, strlen(param_name)))
226- return &event->param[i][strlen(param_name) + 1];
234+ if (strlen(param_name) >= (MAX_UEVENT_NAME_LEN-1)) {
235+ LOGE("%s: the size of %s is to big\n", __FUNCTION__, param_name);
236+ break;
237+ }
238+ memcpy(buf,param_name,strlen(param_name));
239+ buf[strlen(param_name)] = '=';
240+ buf[strlen(param_name)+1] = '\0';
241+ if (!strncmp(event->param[i], buf, strlen(buf)))
242+ return &event->param[i][strlen(buf)];
227243 }
228244
229245 LOGE("get_uevent_param(): No parameter '%s' found", param_name);
@@ -239,11 +255,26 @@ static char *get_uevent_param(struct uevent *event, char *param_name)
239255 static int handle_powersupply_event(struct uevent *event)
240256 {
241257 char *ps_type = get_uevent_param(event, "POWER_SUPPLY_TYPE");
258+ char name[PROPERTY_VALUE_MAX];
259+ int nlen ;
260+ int ps_cap;
261+ int ps_cap_full = 0;
262+ float cap;
263+ int capacity;
242264
243265 if (!strcasecmp(ps_type, "battery")) {
244- char *ps_cap = get_uevent_param(event, "POWER_SUPPLY_CAPACITY");
245- int capacity = atoi(ps_cap);
246-
266+ property_get(POWER_UEVENT_NAME_CHARGE_NOW,name, "POWER_SUPPLY_CAPACITY");
267+ ps_cap = atoi(get_uevent_param(event, name));
268+ nlen = property_get(POWER_UEVENT_NAME_CHARGE_FULL, name, NULL);
269+ if (nlen > 0)
270+ ps_cap_full = atoi(get_uevent_param(event, name));
271+ if (ps_cap_full) {
272+ cap = (ps_cap/ps_cap_full)*100;
273+ capacity = (int)cap;
274+ } else
275+ capacity = ps_cap; /* G1 battery */
276+
277+ LOGE("%s: current cap:%d\n", __FUNCTION__, capacity);
247278 if (capacity < 5)
248279 low_batt = true;
249280 else
--- a/vold/uevent.h
+++ b/vold/uevent.h
@@ -18,4 +18,8 @@
1818 #ifndef _UEVENT_MSG_H
1919 #define _UEVENT_MSG_H
2020
21+#define MAX_UEVENT_NAME_LEN 512
22+#define POWER_UEVENT_NAME_CHARGE_NOW "ro.power_supply.uevent.name.capacity.now"
23+#define POWER_UEVENT_NAME_CHARGE_FULL "ro.power_supply.uevent.name.capacity.full"
24+
2125 #endif