设为首页 加入收藏

TOP

在Android中加入充电指示(三)
2014-11-24 07:48:44 来源: 作者: 【 】 浏览:6
Tags:Android 加入 充电 指示
ile(BATTERY_PRESENT_PATH, buf, SIZE) > 0) {


if (buf[0] == '1') {


return 1;


}


}


return 0;


}



int battery_capacity()


{


char buf[SIZE];



if (readFromFile(BATTERY_CAPACITY_PATH, buf, SIZE) > 0) {


return atoi(buf);


}


return 0;


}



int battery_voltage()


{


char buf[SIZE];



if (readFromFile(BATTERY_VOLTAGE_PATH, buf, SIZE) > 0) {


return atoi(buf);


}


return 0;


}




int battery_temperature()


{


char buf[SIZE];



if (readFromFile(BATTERY_TEMPERATURE_PATH, buf, SIZE) > 0) {


return atoi(buf);


}


return 0;


}



int capacity_full()


{


char buf[SIZE];


if (readFromFile(BATTERY_STATUS_PATH, buf, SIZE) > 0)


{


return getBatteryStatus(buf);


}



}



void do_nothing() //don't commnet it before fix zip error. shuaiwen


{


ZipArchive zip;


mzOpenZipArchive(NULL, &zip);



}


int main(int argc, char **argv)


{


int index=0;


#define CIRCLE 100 //1000x1000 microsecond


int circle=0;//interval to update battery status.


struct input_event ev;



//is AC power charging


if(!power_ac())


{


printf("battery supply,don't enter charge mode.\n\r");


return 0; //continue runing.


}


printf("entern charge mode\n\r");


//powerio_low(); //fixme,set power io low to shutdown system when unplug the power.


ui_init();


while(1)


{


circle=0;


ui_set_background(capacity_full()==STATUSCHARGING index++%BACKGROUND_ICON_END:BACKGROUND_ICON_END-1);//todo:more condition must be considered.


// ui_set_background(index++%BACKGROUND_ICON_END);


while(circle++

{


usleep(1000);


ev_get(&ev, 10);


if((ev.type == EV_KEY)&&(ev.code==62))


{


// powerio_high(); //fixme


ev_exit();


gr_exit();


return 0;//the system will continue running


}


//debug


if(ev.type==EV_KEY)printf("key:%d pressed\n",ev.code);


//


}



}


ev_exit();


gr_exit();


return 0;


}




对应的andriod.mk文件如下:


LOCAL_PATH :=$(call my-dir)



include $(CLEAR_VARS)



charge_local_path := $(LOCAL_PATH)


LOCAL_SRC_FILES :=main.c


LOCAL_MODULE := charge


LOCAL_FORCE_STATIC_EXECUTABLE := true


# This binary is in the recovery ramdisk, which is otherwise a copy of root.


# It gets copied there in config/Makefile. LOCAL_MODULE_TAGS suppresses


# a (redundant) copy of the binary in /system/bin for user builds.


# TODO: Build the ramdisk image in a more principled way.



LOCAL_MODULE_TAGS := eng



LOCAL_STATIC_LIBRARIES := libminzip libunz libminui libpixelflinger_static libpng libcutils libstdc++ libc



include $(BUILD_EXECUTABLE)



include $(charge_local_path)/minzip/Android.mk



PRODUCT_COPY_FILES += \


$(charge_local_path)/res/images/battery001.PNG:system/res/images/battery001.png \


$(charge_local_path)/res/images/battery002.PNG:system/res/images/battery002.png \


$(charge_local_path)/res/images/battery003.PNG:system/res/images/battery003.png \


$(charge_local_path)/res/images/battery004.PNG:system/res/images/battery004.png \


$(charge_local_path)/res/images/battery005.PNG:system/res/images/battery005.png \


$(charge_local_path)/res/images/battery006.PNG:system/res/images/battery006.png


首页 上一页 1 2 3 下一页 尾页 3/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇利用BLCR加快Android的启动过程 下一篇Android上拔出sd卡导致flash上媒..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·C++ Lambda表达式保 (2025-12-26 05:49:45)
·C++ Lambda表达式的 (2025-12-26 05:49:42)
·深入浅出 C++ Lambda (2025-12-26 05:49:40)
·C语言指针从入门到基 (2025-12-26 05:21:36)
·【C语言指针初阶】C (2025-12-26 05:21:33)