[DESCRIPTION]
根据运营商的不同,开关机时播放不同的开关机动画
[SOLUTION]
目前没有patch,不过平台的代码已经实现了这个功能:
在Bootanimation.cpp里有函数void BootAnimation::initBootanimationZip()
void BootAnimation::initBootanimationZip() {
ZipFileRO* zipFile = NULL;
#ifdef MTK_TER_SERVICE
if ((access(CUSTOM_REGIONALPHONE_DB, F_OK) == 0)||(access(SYSTEM_REGIONALPHONE_DB, F_OK) == 0)) {
XLOGD("regionalphone.db check OK");
char BootanimFileName[PROPERTY_VALUE_MAX];
// use property to set resource zip
if (property_get(REGIONAL_BOOTANIM_FILE_NAME, BootanimFileName, NULL) <= 0) {
XLOGD("[BootAnimation %s %d]need get the bootanimation zip path for regional phone",__FUNCTION__,__LINE__);
// get the terservice for regional phone
sp<ITerService> terService = 0;
const String16 serviceName("terservice");
sp<IBinder> service = defaultServiceManager()->checkService(serviceName);
if(service != NULL) {
status_t terService_err = getService(serviceName,&terService);
if (terService_err == NO_ERROR && terService->isEarlyReadServiceEnabled()) {
while(true) {
if(!terService->isEarlyDataReady()) {
usleep(100000);
continue;
}
if (property_get(REGIONAL_BOOTANIM_FILE_NAME, BootanimFileName,
NULL) > 0) {
//只需要在properties文件中不设置persist.bootanim.logopath的值即可转入else语句
XLOGD("[BootAnimation %s %d]use the bootanimation zip path = %s",__FUNCTION__,__LINE__, BootanimFileName);
if ((access(BootanimFileName, R_OK) == 0) &&
((zipFile = ZipFileRO::open(BootanimFileName)) != NULL)) {
mZip = zipFile;
}
break;
} else { //在以下代码段根据不同的运营商使用不同的index,即获取不同的动画包.zip。
String8 mncStr("");
status_t mnc_err = terService->getSimMccMnc(&mncStr); //获取运营商名称
XLOGD("[BootAnimation %s %d]mnc_err= %d",__FUNCTION__,__LINE__,mnc_err);
if (mnc_err == NO_ERROR) {
XLOGD("[BootAnimation %s %d]mncStr= %d",__FUNCTION__,__LINE__,atoi(mncStr));
property_set(REGIONAL_BOOTANIM_GET_MNC, mncStr);
int index = -1;
switch (atoi(mncStr)) {
case MNC_VODAFONE: //沃达丰
index = 0;
break;
case MNC_CHNIAUNICOM1: //联通1
case MNC_CHNIAUNICOM2: //联通2
index = 1;
break;
default :
XLOGD("[BootAnimation %s %d]get mnc invalid: not 46692 or 46001, quit get mnc",__FUNCTION__,__LINE__);
break;
}
if (index >= 0) {
for (int i = 0; i < PATH_COUNT; i++) {
if ((access(mResourcePath[index][i], F_OK) == 0) &&
((zipFile = ZipFileRO::open(mResourcePath[index][i])) != NULL)) {
mZip = zipFile;
property_set(REGIONAL_BOOTANIM_FILE_NAME, mResourcePath[index][i]);
XLOGD("[BootAnimation %s %d]logopath= %s", __FUNCTION__, __LINE__, mResourcePath[index][i]);
break;
}
}
}
} else {
XLOGD("[BootAnimation %s %d]get mnc error, quit get mnc",__FUNCTION__,__LINE__);
}
break;
}
}
}
}
} else {
XLOGD("[BootAnimation %s %d]use the bootanimation zip path = %s",__FUNCTION__,__LINE__, BootanimFileName);
if ((access(BootanimFileName, R_OK) == 0) &&
((zipFile = ZipFileRO::open(BootanimFileName)) != NULL)) {
mZip = zipFile;
}
}
}
#endif
if (zipFile == NULL) {
if (((access(SYSTEM_BOOTANIMATION_FILE, R_OK) == 0) &&
((zipFile = ZipFileRO::open(SYSTEM_BOOTANIMATION_FILE)) != NULL)) ||
((access(CUSTOM_BOOTANIMATION_FILE, R_OK) == 0) &&
((zipFile = ZipFileRO::open(CUSTOM_BOOTANIMATION_FILE)) != NULL)) ||
((access(USER_BOOTANIMATION_FILE, R_OK) == 0) &&
((zipFile = ZipFileRO::open(USER_BOOTANIMATION_FILE)) != NULL))) {
mZip = zipFile;
}
}
}
需要在前面定义运营商枚举值:
enum MNC
{
MNC_VODAFONE = 46692,
MNC_HUTCH = 40411,
MNC_CHINAUNICOM1 = 46001,
MNC_CHINAUNICOM2 = 46009,
MNC_COUNT = 2
};