trim min possible config size

This commit is contained in:
REAndroid 2023-04-12 15:32:56 +02:00
parent 10016e68ad
commit a1b44908a9

View File

@ -108,6 +108,11 @@
setConfigSize(size);
return true;
}
public void trimToMinimumSize(){
int size = ByteArray.trimTrailZeros(mValuesContainer.getBytes()).length + 4;
size = nearestSize(size);
trimToSize(size);
}
public void setMcc(int value){
if(getConfigSize()<SIZE_16){
@ -882,6 +887,30 @@
resConfig.parseQualifiers(qualifiers);
return resConfig;
}
public static int nearestSize(int size){
if(size <= SIZE_16){
return SIZE_16;
}
if(size <= SIZE_28){
return SIZE_28;
}
if(size <= SIZE_32){
return SIZE_32;
}
if(size <= SIZE_36){
return SIZE_36;
}
if(size <= SIZE_48){
return SIZE_48;
}
if(size <= SIZE_52){
return SIZE_52;
}
if(size <= SIZE_56){
return SIZE_56;
}
return SIZE_64;
}
private static char[] unPackLanguage(byte in0, byte in1) {