android4.4中,將字體設置爲超大字體後,圖庫詳情中某些項格式不正確。如下圖
爲什麼小字體沒問題,大字體有問題呢?
這些值都是通過讀取exif信息得到的,那就只有一種可能,製造商和模型的製造商兩項的exif信息有問題。
通過看hal層代碼camera_exif.h發現一段代碼:
char exif_str_maker[128]="K-TOUCH";
char exif_str_model[128]="K-Touch Kis 7";
exif_str_maker[127]=0;
exif_str_model[127]=0;
static customExifInfo_t exifTag={0};
memcpy(exifTag.strMake,exif_str_maker,31);
memcpy(exifTag.strModel,exif_str_model,31);
strcpy((char *)exifTag.strSoftware,"custom software");
其中memcpy的時候第三個參數爲31,引入了過多的空格。第一反應是改爲strlen(exif_str_maker)+1,但是可能涉及很多問題。
爲何不把問題想簡單點,從gallery獲取exif值時將過多空格去掉,
所以最終的解法是在gallery的MediaDetails.java中將setexifdata()修改爲:
private static void setExifData(MediaDetails details, ExifTag tag,
int key) {
if (tag != null) {
String value = null;
int type = tag.getDataType();
if (type == ExifTag.TYPE_UNSIGNED_RATIONAL || type == ExifTag.TYPE_RATIONAL) {
value = String.valueOf(tag.getValueAsRational(0).toDouble());
} else if (type == ExifTag.TYPE_ASCII) {
value = tag.getValueAsString();
} else {
value = String.valueOf(tag.forceGetValueAsLong(0));
}
if (key == MediaDetails.INDEX_FLASH) {
MediaDetails.FlashState state = new MediaDetails.FlashState(
Integer.valueOf(value.toString()));
details.addDetail(key, state);
} else {
//modify start
//details.addDetail(key, value);
if (key == MediaDetails.INDEX_MODEL || key == MediaDetails.INDEX_MAKE){
details.addDetail(key, value.trim());
} else {
details.addDetail(key, value);
}
//modify end
}
}
}
在將新編出的Gallery程序push到手機,一切正常。