forked from aosp-mirror/platform_frameworks_base
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAaptAssets.cpp
More file actions
2953 lines (2589 loc) · 85.9 KB
/
AaptAssets.cpp
File metadata and controls
2953 lines (2589 loc) · 85.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//
// Copyright 2006 The Android Open Source Project
//
#include "AaptAssets.h"
#include "ResourceFilter.h"
#include "Main.h"
#include <utils/misc.h>
#include <utils/SortedVector.h>
#include <ctype.h>
#include <dirent.h>
#include <errno.h>
static const char* kDefaultLocale = "default";
static const char* kWildcardName = "any";
static const char* kAssetDir = "assets";
static const char* kResourceDir = "res";
static const char* kValuesDir = "values";
static const char* kMipmapDir = "mipmap";
static const char* kInvalidChars = "/\\:";
static const size_t kMaxAssetFileName = 100;
static const String8 kResString(kResourceDir);
/*
* Names of asset files must meet the following criteria:
*
* - the filename length must be less than kMaxAssetFileName bytes long
* (and can't be empty)
* - all characters must be 7-bit printable ASCII
* - none of { '/' '\\' ':' }
*
* Pass in just the filename, not the full path.
*/
static bool validateFileName(const char* fileName)
{
const char* cp = fileName;
size_t len = 0;
while (*cp != '\0') {
if ((*cp & 0x80) != 0)
return false; // reject high ASCII
if (*cp < 0x20 || *cp >= 0x7f)
return false; // reject control chars and 0x7f
if (strchr(kInvalidChars, *cp) != NULL)
return false; // reject path sep chars
cp++;
len++;
}
if (len < 1 || len > kMaxAssetFileName)
return false; // reject empty or too long
return true;
}
// The default to use if no other ignore pattern is defined.
const char * const gDefaultIgnoreAssets =
"!.svn:!.git:!.ds_store:!*.scc:.*:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~";
// The ignore pattern that can be passed via --ignore-assets in Main.cpp
const char * gUserIgnoreAssets = NULL;
static bool isHidden(const char *root, const char *path)
{
// Patterns syntax:
// - Delimiter is :
// - Entry can start with the flag ! to avoid printing a warning
// about the file being ignored.
// - Entry can have the flag "<dir>" to match only directories
// or <file> to match only files. Default is to match both.
// - Entry can be a simplified glob "<prefix>*" or "*<suffix>"
// where prefix/suffix must have at least 1 character (so that
// we don't match a '*' catch-all pattern.)
// - The special filenames "." and ".." are always ignored.
// - Otherwise the full string is matched.
// - match is not case-sensitive.
if (strcmp(path, ".") == 0 || strcmp(path, "..") == 0) {
return true;
}
const char *delim = ":";
const char *p = gUserIgnoreAssets;
if (!p || !p[0]) {
p = getenv("ANDROID_AAPT_IGNORE");
}
if (!p || !p[0]) {
p = gDefaultIgnoreAssets;
}
char *patterns = strdup(p);
bool ignore = false;
bool chatty = true;
char *matchedPattern = NULL;
String8 fullPath(root);
fullPath.appendPath(path);
FileType type = getFileType(fullPath);
int plen = strlen(path);
// Note: we don't have strtok_r under mingw.
for(char *token = strtok(patterns, delim);
!ignore && token != NULL;
token = strtok(NULL, delim)) {
chatty = token[0] != '!';
if (!chatty) token++; // skip !
if (strncasecmp(token, "<dir>" , 5) == 0) {
if (type != kFileTypeDirectory) continue;
token += 5;
}
if (strncasecmp(token, "<file>", 6) == 0) {
if (type != kFileTypeRegular) continue;
token += 6;
}
matchedPattern = token;
int n = strlen(token);
if (token[0] == '*') {
// Match *suffix
token++;
n--;
if (n <= plen) {
ignore = strncasecmp(token, path + plen - n, n) == 0;
}
} else if (n > 1 && token[n - 1] == '*') {
// Match prefix*
ignore = strncasecmp(token, path, n - 1) == 0;
} else {
ignore = strcasecmp(token, path) == 0;
}
}
if (ignore && chatty) {
fprintf(stderr, " (skipping %s '%s' due to ANDROID_AAPT_IGNORE pattern '%s')\n",
type == kFileTypeDirectory ? "dir" : "file",
path,
matchedPattern ? matchedPattern : "");
}
free(patterns);
return ignore;
}
// =========================================================================
// =========================================================================
// =========================================================================
/* static */ void AaptLocaleValue::splitAndLowerCase(const char* const chars,
Vector<String8>* parts, const char separator) {
const char *p = chars;
const char *q;
while (NULL != (q = strchr(p, separator))) {
String8 val(p, q - p);
val.toLower();
parts->add(val);
p = q+1;
}
if (p < chars + strlen(chars)) {
String8 val(p);
val.toLower();
parts->add(val);
}
}
/* static */
inline bool isAlpha(const String8& string) {
const size_t length = string.length();
for (size_t i = 0; i < length; ++i) {
if (!isalpha(string[i])) {
return false;
}
}
return true;
}
/* static */
inline bool isNumber(const String8& string) {
const size_t length = string.length();
for (size_t i = 0; i < length; ++i) {
if (!isdigit(string[i])) {
return false;
}
}
return true;
}
void AaptLocaleValue::setLanguage(const char* languageChars) {
size_t i = 0;
while ((*languageChars) != '\0') {
language[i++] = tolower(*languageChars);
languageChars++;
}
}
void AaptLocaleValue::setRegion(const char* regionChars) {
size_t i = 0;
while ((*regionChars) != '\0') {
region[i++] = toupper(*regionChars);
regionChars++;
}
}
void AaptLocaleValue::setScript(const char* scriptChars) {
size_t i = 0;
while ((*scriptChars) != '\0') {
if (i == 0) {
script[i++] = toupper(*scriptChars);
} else {
script[i++] = tolower(*scriptChars);
}
scriptChars++;
}
}
void AaptLocaleValue::setVariant(const char* variantChars) {
size_t i = 0;
while ((*variantChars) != '\0') {
variant[i++] = *variantChars;
variantChars++;
}
}
bool AaptLocaleValue::initFromFilterString(const String8& str) {
// A locale (as specified in the filter) is an underscore separated name such
// as "en_US", "en_Latn_US", or "en_US_POSIX".
Vector<String8> parts;
splitAndLowerCase(str.string(), &parts, '_');
const int numTags = parts.size();
bool valid = false;
if (numTags >= 1) {
const String8& lang = parts[0];
if (isAlpha(lang) && (lang.length() == 2 || lang.length() == 3)) {
setLanguage(lang.string());
valid = true;
}
}
if (!valid || numTags == 1) {
return valid;
}
// At this point, valid == true && numTags > 1.
const String8& part2 = parts[1];
if ((part2.length() == 2 && isAlpha(part2)) ||
(part2.length() == 3 && isNumber(part2))) {
setRegion(part2.string());
} else if (part2.length() == 4 && isAlpha(part2)) {
setScript(part2.string());
} else if (part2.length() >= 5 && part2.length() <= 8) {
setVariant(part2.string());
} else {
valid = false;
}
if (!valid || numTags == 2) {
return valid;
}
// At this point, valid == true && numTags > 1.
const String8& part3 = parts[2];
if (((part3.length() == 2 && isAlpha(part3)) ||
(part3.length() == 3 && isNumber(part3))) && script[0]) {
setRegion(part3.string());
} else if (part3.length() >= 5 && part3.length() <= 8) {
setVariant(part3.string());
} else {
valid = false;
}
if (!valid || numTags == 3) {
return valid;
}
const String8& part4 = parts[3];
if (part4.length() >= 5 && part4.length() <= 8) {
setVariant(part4.string());
} else {
valid = false;
}
if (!valid || numTags > 4) {
return false;
}
return true;
}
int AaptLocaleValue::initFromDirName(const Vector<String8>& parts, const int startIndex) {
const int size = parts.size();
int currentIndex = startIndex;
String8 part = parts[currentIndex];
if (part[0] == 'b' && part[1] == '+') {
// This is a "modified" BCP-47 language tag. Same semantics as BCP-47 tags,
// except that the separator is "+" and not "-".
Vector<String8> subtags;
AaptLocaleValue::splitAndLowerCase(part.string(), &subtags, '+');
subtags.removeItemsAt(0);
if (subtags.size() == 1) {
setLanguage(subtags[0]);
} else if (subtags.size() == 2) {
setLanguage(subtags[0]);
// The second tag can either be a region, a variant or a script.
switch (subtags[1].size()) {
case 2:
case 3:
setRegion(subtags[1]);
break;
case 4:
setScript(subtags[1]);
break;
case 5:
case 6:
case 7:
case 8:
setVariant(subtags[1]);
break;
default:
fprintf(stderr, "ERROR: Invalid BCP-47 tag in directory name %s\n",
part.string());
return -1;
}
} else if (subtags.size() == 3) {
// The language is always the first subtag.
setLanguage(subtags[0]);
// The second subtag can either be a script or a region code.
// If its size is 4, it's a script code, else it's a region code.
bool hasRegion = false;
if (subtags[1].size() == 4) {
setScript(subtags[1]);
} else if (subtags[1].size() == 2 || subtags[1].size() == 3) {
setRegion(subtags[1]);
hasRegion = true;
} else {
fprintf(stderr, "ERROR: Invalid BCP-47 tag in directory name %s\n", part.string());
return -1;
}
// The third tag can either be a region code (if the second tag was
// a script), else a variant code.
if (subtags[2].size() > 4) {
setVariant(subtags[2]);
} else {
setRegion(subtags[2]);
}
} else if (subtags.size() == 4) {
setLanguage(subtags[0]);
setScript(subtags[1]);
setRegion(subtags[2]);
setVariant(subtags[3]);
} else {
fprintf(stderr, "ERROR: Invalid BCP-47 tag in directory name: %s\n", part.string());
return -1;
}
return ++currentIndex;
} else {
if ((part.length() == 2 || part.length() == 3) && isAlpha(part)) {
setLanguage(part);
if (++currentIndex == size) {
return size;
}
} else {
return currentIndex;
}
part = parts[currentIndex];
if (part.string()[0] == 'r' && part.length() == 3) {
setRegion(part.string() + 1);
if (++currentIndex == size) {
return size;
}
}
}
return currentIndex;
}
String8 AaptLocaleValue::toDirName() const {
String8 dirName("");
if (language[0]) {
dirName += language;
} else {
return dirName;
}
if (script[0]) {
dirName += "-s";
dirName += script;
}
if (region[0]) {
dirName += "-r";
dirName += region;
}
if (variant[0]) {
dirName += "-v";
dirName += variant;
}
return dirName;
}
void AaptLocaleValue::initFromResTable(const ResTable_config& config) {
config.unpackLanguage(language);
config.unpackRegion(region);
if (config.localeScript[0]) {
memcpy(script, config.localeScript, sizeof(config.localeScript));
}
if (config.localeVariant[0]) {
memcpy(variant, config.localeVariant, sizeof(config.localeVariant));
}
}
void AaptLocaleValue::writeTo(ResTable_config* out) const {
out->packLanguage(language);
out->packRegion(region);
if (script[0]) {
memcpy(out->localeScript, script, sizeof(out->localeScript));
}
if (variant[0]) {
memcpy(out->localeVariant, variant, sizeof(out->localeVariant));
}
}
/* static */ bool
AaptGroupEntry::parseFilterNamePart(const String8& part, int* axis, AxisValue* value)
{
ResTable_config config;
memset(&config, 0, sizeof(ResTable_config));
// IMSI - MCC
if (getMccName(part.string(), &config)) {
*axis = AXIS_MCC;
value->intValue = config.mcc;
return true;
}
// IMSI - MNC
if (getMncName(part.string(), &config)) {
*axis = AXIS_MNC;
value->intValue = config.mnc;
return true;
}
// locale - language
if (value->localeValue.initFromFilterString(part)) {
*axis = AXIS_LOCALE;
return true;
}
// layout direction
if (getLayoutDirectionName(part.string(), &config)) {
*axis = AXIS_LAYOUTDIR;
value->intValue = (config.screenLayout&ResTable_config::MASK_LAYOUTDIR);
return true;
}
// smallest screen dp width
if (getSmallestScreenWidthDpName(part.string(), &config)) {
*axis = AXIS_SMALLESTSCREENWIDTHDP;
value->intValue = config.smallestScreenWidthDp;
return true;
}
// screen dp width
if (getScreenWidthDpName(part.string(), &config)) {
*axis = AXIS_SCREENWIDTHDP;
value->intValue = config.screenWidthDp;
return true;
}
// screen dp height
if (getScreenHeightDpName(part.string(), &config)) {
*axis = AXIS_SCREENHEIGHTDP;
value->intValue = config.screenHeightDp;
return true;
}
// screen layout size
if (getScreenLayoutSizeName(part.string(), &config)) {
*axis = AXIS_SCREENLAYOUTSIZE;
value->intValue = (config.screenLayout&ResTable_config::MASK_SCREENSIZE);
return true;
}
// screen layout long
if (getScreenLayoutLongName(part.string(), &config)) {
*axis = AXIS_SCREENLAYOUTLONG;
value->intValue = (config.screenLayout&ResTable_config::MASK_SCREENLONG);
return true;
}
// orientation
if (getOrientationName(part.string(), &config)) {
*axis = AXIS_ORIENTATION;
value->intValue = config.orientation;
return true;
}
// ui mode type
if (getUiModeTypeName(part.string(), &config)) {
*axis = AXIS_UIMODETYPE;
value->intValue = (config.uiMode&ResTable_config::MASK_UI_MODE_TYPE);
return true;
}
// ui mode night
if (getUiModeNightName(part.string(), &config)) {
*axis = AXIS_UIMODENIGHT;
value->intValue = (config.uiMode&ResTable_config::MASK_UI_MODE_NIGHT);
return true;
}
// density
if (getDensityName(part.string(), &config)) {
*axis = AXIS_DENSITY;
value->intValue = config.density;
return true;
}
// touchscreen
if (getTouchscreenName(part.string(), &config)) {
*axis = AXIS_TOUCHSCREEN;
value->intValue = config.touchscreen;
return true;
}
// keyboard hidden
if (getKeysHiddenName(part.string(), &config)) {
*axis = AXIS_KEYSHIDDEN;
value->intValue = config.inputFlags;
return true;
}
// keyboard
if (getKeyboardName(part.string(), &config)) {
*axis = AXIS_KEYBOARD;
value->intValue = config.keyboard;
return true;
}
// navigation hidden
if (getNavHiddenName(part.string(), &config)) {
*axis = AXIS_NAVHIDDEN;
value->intValue = config.inputFlags;
return 0;
}
// navigation
if (getNavigationName(part.string(), &config)) {
*axis = AXIS_NAVIGATION;
value->intValue = config.navigation;
return true;
}
// screen size
if (getScreenSizeName(part.string(), &config)) {
*axis = AXIS_SCREENSIZE;
value->intValue = config.screenSize;
return true;
}
// version
if (getVersionName(part.string(), &config)) {
*axis = AXIS_VERSION;
value->intValue = config.version;
return true;
}
return false;
}
AxisValue
AaptGroupEntry::getConfigValueForAxis(const ResTable_config& config, int axis)
{
AxisValue value;
switch (axis) {
case AXIS_MCC:
value.intValue = config.mcc;
break;
case AXIS_MNC:
value.intValue = config.mnc;
break;
case AXIS_LOCALE:
value.localeValue.initFromResTable(config);
break;
case AXIS_LAYOUTDIR:
value.intValue = config.screenLayout&ResTable_config::MASK_LAYOUTDIR;
break;
case AXIS_SCREENLAYOUTSIZE:
value.intValue = config.screenLayout&ResTable_config::MASK_SCREENSIZE;
break;
case AXIS_ORIENTATION:
value.intValue = config.orientation;
break;
case AXIS_UIMODETYPE:
value.intValue = (config.uiMode&ResTable_config::MASK_UI_MODE_TYPE);
break;
case AXIS_UIMODENIGHT:
value.intValue = (config.uiMode&ResTable_config::MASK_UI_MODE_NIGHT);
break;
case AXIS_DENSITY:
value.intValue = config.density;
break;
case AXIS_TOUCHSCREEN:
value.intValue = config.touchscreen;
break;
case AXIS_KEYSHIDDEN:
value.intValue = config.inputFlags;
break;
case AXIS_KEYBOARD:
value.intValue = config.keyboard;
break;
case AXIS_NAVIGATION:
value.intValue = config.navigation;
break;
case AXIS_SCREENSIZE:
value.intValue = config.screenSize;
break;
case AXIS_SMALLESTSCREENWIDTHDP:
value.intValue = config.smallestScreenWidthDp;
break;
case AXIS_SCREENWIDTHDP:
value.intValue = config.screenWidthDp;
break;
case AXIS_SCREENHEIGHTDP:
value.intValue = config.screenHeightDp;
break;
case AXIS_VERSION:
value.intValue = config.version;
break;
}
return value;
}
bool
AaptGroupEntry::configSameExcept(const ResTable_config& config,
const ResTable_config& otherConfig, int axis)
{
for (int i=AXIS_START; i<=AXIS_END; i++) {
if (i == axis) {
continue;
}
if (getConfigValueForAxis(config, i) != getConfigValueForAxis(otherConfig, i)) {
return false;
}
}
return true;
}
bool
AaptGroupEntry::initFromDirName(const char* dir, String8* resType)
{
mParamsChanged = true;
Vector<String8> parts;
AaptLocaleValue::splitAndLowerCase(dir, &parts, '-');
String8 mcc, mnc, layoutsize, layoutlong, orient, den;
String8 touch, key, keysHidden, nav, navHidden, size, layoutDir, vers;
String8 uiModeType, uiModeNight, smallestwidthdp, widthdp, heightdp;
AaptLocaleValue locale;
int numLocaleComponents = 0;
const int N = parts.size();
int index = 0;
String8 part = parts[index];
// resource type
if (!isValidResourceType(part)) {
return false;
}
*resType = part;
index++;
if (index == N) {
goto success;
}
part = parts[index];
// imsi - mcc
if (getMccName(part.string())) {
mcc = part;
index++;
if (index == N) {
goto success;
}
part = parts[index];
} else {
//printf("not mcc: %s\n", part.string());
}
// imsi - mnc
if (getMncName(part.string())) {
mnc = part;
index++;
if (index == N) {
goto success;
}
part = parts[index];
} else {
//printf("not mnc: %s\n", part.string());
}
index = locale.initFromDirName(parts, index);
if (index == -1) {
return false;
}
if (index >= N){
goto success;
}
part = parts[index];
if (getLayoutDirectionName(part.string())) {
layoutDir = part;
index++;
if (index == N) {
goto success;
}
part = parts[index];
} else {
//printf("not layout direction: %s\n", part.string());
}
if (getSmallestScreenWidthDpName(part.string())) {
smallestwidthdp = part;
index++;
if (index == N) {
goto success;
}
part = parts[index];
} else {
//printf("not smallest screen width dp: %s\n", part.string());
}
if (getScreenWidthDpName(part.string())) {
widthdp = part;
index++;
if (index == N) {
goto success;
}
part = parts[index];
} else {
//printf("not screen width dp: %s\n", part.string());
}
if (getScreenHeightDpName(part.string())) {
heightdp = part;
index++;
if (index == N) {
goto success;
}
part = parts[index];
} else {
//printf("not screen height dp: %s\n", part.string());
}
if (getScreenLayoutSizeName(part.string())) {
layoutsize = part;
index++;
if (index == N) {
goto success;
}
part = parts[index];
} else {
//printf("not screen layout size: %s\n", part.string());
}
if (getScreenLayoutLongName(part.string())) {
layoutlong = part;
index++;
if (index == N) {
goto success;
}
part = parts[index];
} else {
//printf("not screen layout long: %s\n", part.string());
}
// orientation
if (getOrientationName(part.string())) {
orient = part;
index++;
if (index == N) {
goto success;
}
part = parts[index];
} else {
//printf("not orientation: %s\n", part.string());
}
// ui mode type
if (getUiModeTypeName(part.string())) {
uiModeType = part;
index++;
if (index == N) {
goto success;
}
part = parts[index];
} else {
//printf("not ui mode type: %s\n", part.string());
}
// ui mode night
if (getUiModeNightName(part.string())) {
uiModeNight = part;
index++;
if (index == N) {
goto success;
}
part = parts[index];
} else {
//printf("not ui mode night: %s\n", part.string());
}
// density
if (getDensityName(part.string())) {
den = part;
index++;
if (index == N) {
goto success;
}
part = parts[index];
} else {
//printf("not density: %s\n", part.string());
}
// touchscreen
if (getTouchscreenName(part.string())) {
touch = part;
index++;
if (index == N) {
goto success;
}
part = parts[index];
} else {
//printf("not touchscreen: %s\n", part.string());
}
// keyboard hidden
if (getKeysHiddenName(part.string())) {
keysHidden = part;
index++;
if (index == N) {
goto success;
}
part = parts[index];
} else {
//printf("not keysHidden: %s\n", part.string());
}
// keyboard
if (getKeyboardName(part.string())) {
key = part;
index++;
if (index == N) {
goto success;
}
part = parts[index];
} else {
//printf("not keyboard: %s\n", part.string());
}
// navigation hidden
if (getNavHiddenName(part.string())) {
navHidden = part;
index++;
if (index == N) {
goto success;
}
part = parts[index];
} else {
//printf("not navHidden: %s\n", part.string());
}
if (getNavigationName(part.string())) {
nav = part;
index++;
if (index == N) {
goto success;
}
part = parts[index];
} else {
//printf("not navigation: %s\n", part.string());
}
if (getScreenSizeName(part.string())) {
size = part;
index++;
if (index == N) {
goto success;
}
part = parts[index];
} else {
//printf("not screen size: %s\n", part.string());
}
if (getVersionName(part.string())) {
vers = part;
index++;
if (index == N) {
goto success;
}
part = parts[index];
} else {
//printf("not version: %s\n", part.string());
}
// if there are extra parts, it doesn't match
return false;
success:
this->mcc = mcc;
this->mnc = mnc;
this->locale = locale;
this->screenLayoutSize = layoutsize;
this->screenLayoutLong = layoutlong;
this->smallestScreenWidthDp = smallestwidthdp;
this->screenWidthDp = widthdp;
this->screenHeightDp = heightdp;
this->orientation = orient;
this->uiModeType = uiModeType;
this->uiModeNight = uiModeNight;
this->density = den;
this->touchscreen = touch;
this->keysHidden = keysHidden;
this->keyboard = key;
this->navHidden = navHidden;
this->navigation = nav;
this->screenSize = size;
this->layoutDirection = layoutDir;
this->version = vers;
// what is this anyway?
this->vendor = "";
return true;
}
String8
AaptGroupEntry::toString() const
{
String8 s = this->mcc;
s += ",";
s += this->mnc;
s += ",";
s += locale.toDirName();
s += ",";
s += layoutDirection;
s += ",";
s += smallestScreenWidthDp;
s += ",";
s += screenWidthDp;
s += ",";
s += screenHeightDp;
s += ",";
s += screenLayoutSize;
s += ",";
s += screenLayoutLong;
s += ",";
s += this->orientation;
s += ",";