修改Recovery中的文字提示(二)

上一篇博文提到,如果把轉換格式後的圖片替換掉原來的圖片,你會發現,顯示的竟然是繁體中文。這到底是發生了什麼?

分析

在res_create_localized_alpha_surface()函數中,匹配到本地化信息之後,會打印日誌。

printf(" %20s: %s (%d x %d @ %d)\n", name, loc, w, h, y);

那麼,我們修改一下打印日誌的位置,把匹配的過程都打印出來:

int res_create_localized_alpha_surface(const char* name,
                                       const char* locale,
                                       GRSurface** pSurface) {
    GRSurface* surface = NULL;
    int result = 0;
    png_structp png_ptr = NULL;
    png_infop info_ptr = NULL;
    png_uint_32 width, height;
    png_byte channels;
    png_uint_32 y;
    std::vector<unsigned char> row;

    *pSurface = NULL;

    if (locale == NULL) {
        return result;
    }

    result = open_png(name, &png_ptr, &info_ptr, &width, &height, &channels);
    if (result < 0) return result;

    if (channels != 1) {
        result = -7;
        goto exit;
    }

    row.resize(width);
    for (y = 0; y < height; ++y) {
        png_read_row(png_ptr, row.data(), NULL);
        int w = (row[1] << 8) | row[0];
        int h = (row[3] << 8) | row[2];
        __unused int len = row[4];
        char* loc = reinterpret_cast<char*>(&row[5]);
        printf("  %20s: %s (%d x %d @ %d)\n", name, loc, w, h, y); // 把打印日誌放到了匹配之前
        if (y+1+h >= height || matches_locale(loc, locale)) {
            // printf("  %20s: %s (%d x %d @ %d)\n", name, loc, w, h, y);

            surface = malloc_surface(w*h);
            if (surface == NULL) {
                result = -8;
                goto exit;
            }
            surface->width = w;
            surface->height = h;
            surface->row_bytes = w;
            surface->pixel_bytes = 1;

            int i;
            for (i = 0; i < h; ++i, ++y) {
                png_read_row(png_ptr, row.data(), NULL);
                memcpy(surface->data + i*w, row.data(), w);
            }

            *pSurface = surface;
            break;
        } else {
            int i;
            for (i = 0; i < h; ++i, ++y) {
                png_read_row(png_ptr, row.data(), NULL);
            }
        }
    }

exit:
    png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
    if (result < 0 && surface != NULL) free(surface);
    return result;
}

這裏貼一下我打印出來的日誌:

[ 0.325852] Timothy: erasing_text: af (76 x 19 @ 0)
[ 0.325968] Timothy: erasing_text: am (80 x 19 @ 20)
[ 0.326038] Timothy: erasing_text: ar-EG (83 x 19 @ 40)
[ 0.326165] Timothy: erasing_text: ar-IL (83 x 19 @ 60)
[ 0.326273] Timothy: erasing_text: ar-XB (48 x 19 @ 80)
[ 0.326364] Timothy: erasing_text: ar (83 x 19 @ 100)
[ 0.326414] Timothy: erasing_text: az (37 x 19 @ 120)
[ 0.326477] Timothy: erasing_text: bg-BG (73 x 19 @ 140)
[ 0.326585] Timothy: erasing_text: bg (73 x 19 @ 160)
[ 0.326629] Timothy: erasing_text: bn (61 x 19 @ 180)
[ 0.326714] Timothy: erasing_text: ca-ES (102 x 19 @ 200)
[ 0.326810] Timothy: erasing_text: ca (102 x 19 @ 220)
[ 0.326855] Timothy: erasing_text: cs-CZ (46 x 19 @ 240)
[ 0.326936] Timothy: erasing_text: cs (46 x 19 @ 260)
[ 0.326980] Timothy: erasing_text: da-DK (43 x 19 @ 280)
[ 0.327056] Timothy: erasing_text: da (43 x 19 @ 300)
[ 0.327100] Timothy: erasing_text: de-AT (87 x 19 @ 320)
[ 0.327203] Timothy: erasing_text: de-CH (87 x 19 @ 340)
[ 0.327267] Timothy: erasing_text: de-DE (87 x 19 @ 360)
[ 0.327330] Timothy: erasing_text: de-LI (87 x 19 @ 380)
[ 0.327393] Timothy: erasing_text: de (87 x 19 @ 400)
[ 0.327436] Timothy: erasing_text: el-GR (64 x 19 @ 420)
[ 0.327538] Timothy: erasing_text: el (64 x 19 @ 440)
[ 0.327581] Timothy: erasing_text: en-AU (47 x 19 @ 460)
[ 0.327663] Timothy: erasing_text: en-CA (47 x 19 @ 480)
[ 0.327726] Timothy: erasing_text: en-GB (47 x 19 @ 500)
[ 0.327789] Timothy: erasing_text: en-IE (47 x 19 @ 520)
[ 0.327852] Timothy: erasing_text: en-IN (47 x 19 @ 540)
[ 0.327915] Timothy: erasing_text: en-NZ (47 x 19 @ 560)
[ 0.327979] Timothy: erasing_text: en-SG (47 x 19 @ 580)
[ 0.328042] Timothy: erasing_text: en-US (47 x 19 @ 600)
[ 0.328106] Timothy: erasing_text: en-XA (108 x 19 @ 620)
[ 0.328207] Timothy: erasing_text: en-ZA (47 x 19 @ 640)
[ 0.328270] Timothy: erasing_text: en (47 x 19 @ 660)
[ 0.328315] Timothy: erasing_text: es-ES (58 x 19 @ 680)
[ 0.328396] Timothy: erasing_text: es-US (58 x 19 @ 700)
[ 0.328460] Timothy: erasing_text: es (58 x 19 @ 720)
[ 0.328505] Timothy: erasing_text: et (81 x 19 @ 740)
[ 0.328573] Timothy: erasing_text: eu (146 x 19 @ 760)
[ 0.328655] Timothy: erasing_text: fa (85 x 19 @ 780)
[ 0.328743] Timothy: erasing_text: fi-FI (87 x 19 @ 800)
[ 0.328835] Timothy: erasing_text: fil-PH (56 x 19 @ 820)
[ 0.328911] Timothy: erasing_text: fil (56 x 19 @ 840)
[ 0.328955] Timothy: erasing_text: fi (87 x 19 @ 860)
[ 0.328999] Timothy: erasing_text: fr-BE (89 x 19 @ 880)
[ 0.329143] Timothy: erasing_text: fr-CA (147 x 19 @ 900)
[ 0.329223] Timothy: erasing_text: fr-CH (89 x 19 @ 920)
[ 0.329286] Timothy: erasing_text: fr-FR (89 x 19 @ 940)
[ 0.329349] Timothy: erasing_text: fr (89 x 19 @ 960)
[ 0.329392] Timothy: erasing_text: gl (58 x 19 @ 980)
[ 0.329451] Timothy: erasing_text: gu (84 x 19 @ 1000)
[ 0.329546] Timothy: erasing_text: hi-IN (82 x 19 @ 1020)
[ 0.329649] Timothy: erasing_text: hi (82 x 19 @ 1040)
[ 0.329692] Timothy: erasing_text: hr-HR (52 x 19 @ 1060)
[ 0.329774] Timothy: erasing_text: hr (52 x 19 @ 1080)
[ 0.329818] Timothy: erasing_text: hu-HU (40 x 19 @ 1100)
[ 0.329894] Timothy: erasing_text: hu (40 x 19 @ 1120)
[ 0.329939] Timothy: erasing_text: hy (46 x 19 @ 1140)
[ 0.330012] Timothy: erasing_text: id (74 x 19 @ 1160)
[ 0.330086] Timothy: erasing_text: in (74 x 19 @ 1180)
[ 0.330130] Timothy: erasing_text: is (31 x 19 @ 1200)
[ 0.330192] Timothy: erasing_text: it-CH (101 x 19 @ 1220)
[ 0.330289] Timothy: erasing_text: it-IT (101 x 19 @ 1240)
[ 0.330352] Timothy: erasing_text: it (101 x 19 @ 1260)
[ 0.330396] Timothy: erasing_text: iw (30 x 19 @ 1280)
[ 0.330457] Timothy: erasing_text: ja-JP (98 x 19 @ 1300)
[ 0.330586] Timothy: erasing_text: ja (98 x 19 @ 1320)
[ 0.330628] Timothy: erasing_text: ka (173 x 19 @ 1340)
[ 0.330757] Timothy: erasing_text: kk (69 x 19 @ 1360)
[ 0.330833] Timothy: erasing_text: km (20 x 19 @ 1380)
[ 0.330891] Timothy: erasing_text: kn (84 x 19 @ 1400)
[ 0.330994] Timothy: erasing_text: ko-KR (55 x 19 @ 1420)
[ 0.331093] Timothy: erasing_text: ko (55 x 19 @ 1440)
[ 0.331136] Timothy: erasing_text: ky (85 x 19 @ 1460)
[ 0.331205] Timothy: erasing_text: lo (47 x 19 @ 1480)
[ 0.331276] Timothy: erasing_text: lt-LT (59 x 19 @ 1500)
[ 0.331410] Timothy: erasing_text: lt (59 x 19 @ 1520)
[ 0.331455] Timothy: erasing_text: lv-LV (97 x 19 @ 1540)
[ 0.331559] Timothy: erasing_text: lv (97 x 19 @ 1560)
[ 0.331603] Timothy: erasing_text: mk (63 x 19 @ 1580)
[ 0.331678] Timothy: erasing_text: ml (71 x 19 @ 1600)
[ 0.331764] Timothy: erasing_text: mn (89 x 19 @ 1620)
[ 0.331839] Timothy: erasing_text: mr (59 x 19 @ 1640)
[ 0.331917] Timothy: erasing_text: ms (67 x 19 @ 1660)
[ 0.331977] Timothy: erasing_text: my (77 x 19 @ 1680)
[ 0.332068] Timothy: erasing_text: nb-NO (53 x 19 @ 1700)
[ 0.332146] Timothy: erasing_text: nb (53 x 19 @ 1720)
[ 0.332192] Timothy: erasing_text: ne (34 x 19 @ 1740)
[ 0.332257] Timothy: erasing_text: nl-BE (45 x 19 @ 1760)
[ 0.332344] Timothy: erasing_text: nl-NL (45 x 19 @ 1780)
[ 0.332408] Timothy: erasing_text: nl (45 x 19 @ 1800)
[ 0.332452] Timothy: erasing_text: pa (83 x 19 @ 1820)
[ 0.332538] Timothy: erasing_text: pl-PL (43 x 19 @ 1840)
[ 0.332623] Timothy: erasing_text: pl (43 x 19 @ 1860)
[ 0.332667] Timothy: erasing_text: pt-BR (65 x 19 @ 1880)
[ 0.332765] Timothy: erasing_text: pt-PT (57 x 19 @ 1900)
[ 0.332838] Timothy: erasing_text: pt (65 x 19 @ 1920)
[ 0.332883] Timothy: erasing_text: ro-RO (60 x 19 @ 1940)
[ 0.332970] Timothy: erasing_text: ro (60 x 19 @ 1960)
[ 0.333013] Timothy: erasing_text: ru-RU (75 x 19 @ 1980)
[ 0.333107] Timothy: erasing_text: ru (75 x 19 @ 2000)
[ 0.333152] Timothy: erasing_text: si (51 x 19 @ 2020)
[ 0.333237] Timothy: erasing_text: sk-SK (144 x 19 @ 2040)
[ 0.333349] Timothy: erasing_text: sk (144 x 19 @ 2060)
[ 0.333394] Timothy: erasing_text: sl-SI (52 x 19 @ 2080)
[ 0.333476] Timothy: erasing_text: sl (52 x 19 @ 2100)
[ 0.333520] Timothy: erasing_text: sq (74 x 19 @ 2120)
[ 0.333588] Timothy: erasing_text: sr-Latn (50 x 19 @ 2140)
[ 0.333662] Timothy: erasing_text: sr-RS (62 x 19 @ 2160)
[ 0.333775] Timothy: erasing_text: sr (62 x 19 @ 2180)
[ 0.333821] Timothy: erasing_text: sv-SE (44 x 19 @ 2200)
[ 0.333896] Timothy: erasing_text: sv (44 x 19 @ 2220)
[ 0.333941] Timothy: erasing_text: sw (44 x 19 @ 2240)
[ 0.333999] Timothy: erasing_text: ta (75 x 19 @ 2260)
[ 0.334087] Timothy: erasing_text: te (106 x 19 @ 2280)
[ 0.334201] Timothy: erasing_text: th-TH (49 x 19 @ 2300)
[ 0.334290] Timothy: erasing_text: th (49 x 19 @ 2320)
[ 0.334335] Timothy: erasing_text: tr-TR (52 x 19 @ 2340)
[ 0.334423] Timothy: erasing_text: tr (52 x 19 @ 2360)
[ 0.334468] Timothy: erasing_text: uk-UA (63 x 19 @ 2380)
[ 0.334559] Timothy: erasing_text: uk (63 x 19 @ 2400)
[ 0.334603] Timothy: erasing_text: ur (71 x 19 @ 2420)
[ 0.334680] Timothy: erasing_text: uz (105 x 19 @ 2440)
[ 0.334758] Timothy: erasing_text: vi-VN (58 x 19 @ 2460)
[ 0.334846] Timothy: erasing_text: vi (58 x 19 @ 2480)
[ 0.334893] Timothy: erasing_text: zh-CN (56 x 19 @ 2500)
[ 0.334903] erasing_text: zh-CN (56 x 19 @ 2500)
[ 0.335193] Timothy: no_command_text: af (105 x 19 @ 0)
[ 0.335297] Timothy: no_command_text: am (100 x 19 @ 20)
[ 0.335390] Timothy: no_command_text: ar-EG (80 x 19 @ 40)
[ 0.335507] Timothy: no_command_text: ar-IL (80 x 19 @ 60)
[ 0.335577] Timothy: no_command_text: ar-XB (83 x 19 @ 80)
[ 0.335673] Timothy: no_command_text: ar (80 x 19 @ 100)
[ 0.335722] Timothy: no_command_text: az (73 x 19 @ 120)
[ 0.335800] Timothy: no_command_text: bg-BG (86 x 19 @ 140)
[ 0.335910] Timothy: no_command_text: bg (86 x 19 @ 160)
[ 0.335957] Timothy: no_command_text: bn (101 x 19 @ 180)
[ 0.336053] Timothy: no_command_text: ca-ES (114 x 19 @ 200)
[ 0.336151] Timothy: no_command_text: ca (114 x 19 @ 220)
[ 0.336235] Timothy: no_command_text: cs-CZ (81 x 19 @ 240)
[ 0.336329] Timothy: no_command_text: cs (81 x 19 @ 260)
[ 0.336374] Timothy: no_command_text: da-DK (109 x 19 @ 280)
[ 0.336466] Timothy: no_command_text: da (109 x 19 @ 300)
[ 0.336512] Timothy: no_command_text: de-AT (72 x 19 @ 320)
[ 0.336603] Timothy: no_command_text: de-CH (72 x 19 @ 340)
[ 0.336671] Timothy: no_command_text: de-DE (72 x 19 @ 360)
[ 0.336736] Timothy: no_command_text: de-LI (72 x 19 @ 380)
[ 0.336803] Timothy: no_command_text: de (72 x 19 @ 400)
[ 0.336850] Timothy: no_command_text: el-GR (86 x 19 @ 420)
[ 0.336954] Timothy: no_command_text: el (86 x 19 @ 440)
[ 0.337000] Timothy: no_command_text: en-AU (83 x 19 @ 460)
[ 0.337081] Timothy: no_command_text: en-CA (83 x 19 @ 480)
[ 0.337147] Timothy: no_command_text: en-GB (83 x 19 @ 500)
[ 0.337214] Timothy: no_command_text: en-IE (83 x 19 @ 520)
[ 0.337279] Timothy: no_command_text: en-IN (83 x 19 @ 540)
[ 0.337345] Timothy: no_command_text: en-NZ (83 x 19 @ 560)
[ 0.337410] Timothy: no_command_text: en-SG (83 x 19 @ 580)
[ 0.337477] Timothy: no_command_text: en-US (83 x 19 @ 600)
[ 0.337544] Timothy: no_command_text: en-XA (144 x 19 @ 620)
[ 0.337651] Timothy: no_command_text: en-ZA (83 x 19 @ 640)
[ 0.337717] Timothy: no_command_text: en (83 x 19 @ 660)
[ 0.337765] Timothy: no_command_text: es-ES (89 x 19 @ 680)
[ 0.337853] Timothy: no_command_text: es-US (107 x 19 @ 700)
[ 0.337935] Timothy: no_command_text: es (89 x 19 @ 720)
[ 0.337981] Timothy: no_command_text: et (81 x 19 @ 740)
[ 0.338056] Timothy: no_command_text: eu (112 x 19 @ 760)
[ 0.338128] Timothy: no_command_text: fa (95 x 19 @ 780)
[ 0.338268] Timothy: no_command_text: fi-FI (77 x 19 @ 800)
[ 0.338358] Timothy: no_command_text: fil-PH (114 x 19 @ 820)
[ 0.338442] Timothy: no_command_text: fil (114 x 19 @ 840)
[ 0.338488] Timothy: no_command_text: fi (77 x 19 @ 860)
[ 0.338535] Timothy: no_command_text: fr-BE (122 x 19 @ 880)
[ 0.338621] Timothy: no_command_text: fr-CA (122 x 19 @ 900)
[ 0.338688] Timothy: no_command_text: fr-CH (122 x 19 @ 920)
[ 0.338755] Timothy: no_command_text: fr-FR (122 x 19 @ 940)
[ 0.338821] Timothy: no_command_text: fr (122 x 19 @ 960)
[ 0.338868] Timothy: no_command_text: gl (157 x 19 @ 980)
[ 0.338942] Timothy: no_command_text: gu (79 x 19 @ 1000)
[ 0.339037] Timothy: no_command_text: hi-IN (78 x 19 @ 1020)
[ 0.339151] Timothy: no_command_text: hi (78 x 19 @ 1040)
[ 0.339198] Timothy: no_command_text: hr-HR (93 x 19 @ 1060)
[ 0.339287] Timothy: no_command_text: hr (93 x 19 @ 1080)
[ 0.339335] Timothy: no_command_text: hu-HU (89 x 19 @ 1100)
[ 0.339423] Timothy: no_command_text: hu (89 x 19 @ 1120)
[ 0.339470] Timothy: no_command_text: hy (141 x 19 @ 1140)
[ 0.339566] Timothy: no_command_text: id (119 x 19 @ 1160)
[ 0.339641] Timothy: no_command_text: in (119 x 19 @ 1180)
[ 0.339687] Timothy: no_command_text: is (79 x 19 @ 1200)
[ 0.339756] Timothy: no_command_text: it-CH (109 x 19 @ 1220)
[ 0.339844] Timothy: no_command_text: it-IT (109 x 19 @ 1240)
[ 0.339911] Timothy: no_command_text: it (109 x 19 @ 1260)
[ 0.339958] Timothy: no_command_text: iw (57 x 19 @ 1280)
[ 0.340030] Timothy: no_command_text: ja-JP (194 x 19 @ 1300)
[ 0.340216] Timothy: no_command_text: ja (194 x 19 @ 1320)
[ 0.340261] Timothy: no_command_text: ka (133 x 19 @ 1340)
[ 0.340365] Timothy: no_command_text: kk (82 x 19 @ 1360)
[ 0.340443] Timothy: no_command_text: km (85 x 19 @ 1380)
[ 0.340572] Timothy: no_command_text: kn (121 x 19 @ 1400)
[ 0.340691] Timothy: no_command_text: ko-KR (67 x 19 @ 1420)
[ 0.340804] Timothy: no_command_text: ko (67 x 19 @ 1440)
[ 0.340850] Timothy: no_command_text: ky (142 x 19 @ 1460)
[ 0.340935] Timothy: no_command_text: lo (47 x 19 @ 1480)
[ 0.341013] Timothy: no_command_text: lt-LT (125 x 19 @ 1500)
[ 0.341128] Timothy: no_command_text: lt (125 x 19 @ 1520)
[ 0.341174] Timothy: no_command_text: lv-LV (154 x 19 @ 1540)
[ 0.341267] Timothy: no_command_text: lv (154 x 19 @ 1560)
[ 0.341314] Timothy: no_command_text: mk (95 x 19 @ 1580)
[ 0.341389] Timothy: no_command_text: ml (110 x 19 @ 1600)
[ 0.341497] Timothy: no_command_text: mn (105 x 19 @ 1620)
[ 0.341571] Timothy: no_command_text: mr (108 x 19 @ 1640)
[ 0.341669] Timothy: no_command_text: ms (93 x 19 @ 1660)
[ 0.341735] Timothy: no_command_text: my (155 x 19 @ 1680)
[ 0.341857] Timothy: no_command_text: nb-NO (122 x 19 @ 1700)
[ 0.341943] Timothy: no_command_text: nb (122 x 19 @ 1720)
[ 0.341989] Timothy: no_command_text: ne (74 x 19 @ 1740)
[ 0.342058] Timothy: no_command_text: nl-BE (94 x 19 @ 1760)
[ 0.342210] Timothy: no_command_text: nl-NL (94 x 19 @ 1780)
[ 0.342265] Timothy: no_command_text: nl (94 x 19 @ 1800)
[ 0.342311] Timothy: no_command_text: pa (75 x 19 @ 1820)
[ 0.342400] Timothy: no_command_text: pl-PL (93 x 19 @ 1840)
[ 0.342491] Timothy: no_command_text: pl (93 x 19 @ 1860)
[ 0.342538] Timothy: no_command_text: pt-BR (115 x 19 @ 1880)
[ 0.342624] Timothy: no_command_text: pt-PT (115 x 19 @ 1900)
[ 0.342690] Timothy: no_command_text: pt (115 x 19 @ 1920)
[ 0.342737] Timothy: no_command_text: ro-RO (93 x 19 @ 1940)
[ 0.342821] Timothy: no_command_text: ro (93 x 19 @ 1960)
[ 0.342868] Timothy: no_command_text: ru-RU (89 x 19 @ 1980)
[ 0.342967] Timothy: no_command_text: ru (89 x 19 @ 2000)
[ 0.343014] Timothy: no_command_text: si (125 x 19 @ 2020)
[ 0.343139] Timothy: no_command_text: sk-SK (85 x 19 @ 2040)
[ 0.343244] Timothy: no_command_text: sk (85 x 19 @ 2060)
[ 0.343290] Timothy: no_command_text: sl-SI (53 x 19 @ 2080)
[ 0.343368] Timothy: no_command_text: sl (53 x 19 @ 2100)
[ 0.343414] Timothy: no_command_text: sq (103 x 19 @ 2120)
[ 0.343471] Timothy: no_command_text: sr-Latn (99 x 19 @ 2140)
[ 0.343548] Timothy: no_command_text: sr-RS (99 x 19 @ 2160)
[ 0.343628] Timothy: no_command_text: sr (99 x 19 @ 2180)
[ 0.343675] Timothy: no_command_text: sv-SE (106 x 19 @ 2200)
[ 0.343760] Timothy: no_command_text: sv (106 x 19 @ 2220)
[ 0.343807] Timothy: no_command_text: sw (79 x 19 @ 2240)
[ 0.343868] Timothy: no_command_text: ta (113 x 19 @ 2260)
[ 0.343963] Timothy: no_command_text: te (64 x 19 @ 2280)
[ 0.344051] Timothy: no_command_text: th-TH (54 x 19 @ 2300)
[ 0.344151] Timothy: no_command_text: th (54 x 19 @ 2320)
[ 0.344197] Timothy: no_command_text: tr-TR (66 x 19 @ 2340)
[ 0.344283] Timothy: no_command_text: tr (66 x 19 @ 2360)
[ 0.344329] Timothy: no_command_text: uk-UA (106 x 19 @ 2380)
[ 0.344429] Timothy: no_command_text: uk (106 x 19 @ 2400)
[ 0.344476] Timothy: no_command_text: ur (97 x 19 @ 2420)
[ 0.344565] Timothy: no_command_text: uz (71 x 19 @ 2440)
[ 0.344635] Timothy: no_command_text: vi-VN (116 x 19 @ 2460)
[ 0.344754] Timothy: no_command_text: vi (116 x 19 @ 2480)
[ 0.344801] Timothy: no_command_text: zh-CN (42 x 19 @ 2500)
[ 0.344810] no_command_text: zh-CN (42 x 19 @ 2500)
[ 0.345104] Timothy: error_text: af (31 x 19 @ 0)
[ 0.345171] Timothy: error_text: am (38 x 19 @ 20)
[ 0.345232] Timothy: error_text: ar-EG (25 x 19 @ 40)
[ 0.345321] Timothy: error_text: ar-IL (25 x 19 @ 60)
[ 0.345390] Timothy: error_text: ar-XB (34 x 19 @ 80)
[ 0.345472] Timothy: error_text: ar (25 x 19 @ 100)
[ 0.345521] Timothy: error_text: az (32 x 19 @ 120)
[ 0.345581] Timothy: error_text: bg-BG (52 x 19 @ 140)
[ 0.345669] Timothy: error_text: bg (52 x 19 @ 160)
[ 0.345718] Timothy: error_text: bn (29 x 19 @ 180)
[ 0.345791] Timothy: error_text: ca-ES (128 x 19 @ 200)
[ 0.345895] Timothy: error_text: ca (128 x 19 @ 220)
[ 0.345937] Timothy: error_text: cs-CZ (43 x 19 @ 240)
[ 0.346020] Timothy: error_text: cs (43 x 19 @ 260)
[ 0.346064] Timothy: error_text: da-DK (26 x 19 @ 280)
[ 0.346139] Timothy: error_text: da (26 x 19 @ 300)
[ 0.346199] Timothy: error_text: de-AT (40 x 19 @ 320)
[ 0.346270] Timothy: error_text: de-CH (40 x 19 @ 340)
[ 0.346333] Timothy: error_text: de-DE (40 x 19 @ 360)
[ 0.346396] Timothy: error_text: de-LI (40 x 19 @ 380)
[ 0.346458] Timothy: error_text: de (40 x 19 @ 400)
[ 0.346502] Timothy: error_text: el-GR (53 x 19 @ 420)
[ 0.346595] Timothy: error_text: el (53 x 19 @ 440)
[ 0.346637] Timothy: error_text: en-AU (33 x 19 @ 460)
[ 0.346714] Timothy: error_text: en-CA (33 x 19 @ 480)
[ 0.346776] Timothy: error_text: en-GB (33 x 19 @ 500)
[ 0.346839] Timothy: error_text: en-IE (33 x 19 @ 520)
[ 0.346901] Timothy: error_text: en-IN (33 x 19 @ 540)
[ 0.346964] Timothy: error_text: en-NZ (33 x 19 @ 560)
[ 0.347027] Timothy: error_text: en-SG (33 x 19 @ 580)
[ 0.347089] Timothy: error_text: en-US (33 x 19 @ 600)
[ 0.347153] Timothy: error_text: en-XA (95 x 19 @ 620)
[ 0.347250] Timothy: error_text: en-ZA (33 x 19 @ 640)
[ 0.347313] Timothy: error_text: en (33 x 19 @ 660)
[ 0.347356] Timothy: error_text: es-ES (30 x 19 @ 680)
[ 0.347421] Timothy: error_text: es-US (30 x 19 @ 700)
[ 0.347483] Timothy: error_text: es (30 x 19 @ 720)
[ 0.347526] Timothy: error_text: et (32 x 19 @ 740)
[ 0.347590] Timothy: error_text: eu (45 x 19 @ 760)
[ 0.347637] Timothy: error_text: fa (25 x 19 @ 780)
[ 0.347698] Timothy: error_text: fi-FI (37 x 19 @ 800)
[ 0.347770] Timothy: error_text: fil-PH (33 x 19 @ 820)
[ 0.347835] Timothy: error_text: fil (33 x 19 @ 840)
[ 0.347878] Timothy: error_text: fi (37 x 19 @ 860)
[ 0.347922] Timothy: error_text: fr-BE (44 x 19 @ 880)
[ 0.347994] Timothy: error_text: fr-CA (41 x 19 @ 900)
[ 0.348059] Timothy: error_text: fr-CH (44 x 19 @ 920)
[ 0.348121] Timothy: error_text: fr-FR (44 x 19 @ 940)
[ 0.348184] Timothy: error_text: fr (44 x 19 @ 960)
[ 0.348227] Timothy: error_text: gl (25 x 19 @ 980)
[ 0.348274] Timothy: error_text: gu (24 x 19 @ 1000)
[ 0.348338] Timothy: error_text: hi-IN (42 x 19 @ 1020)
[ 0.348427] Timothy: error_text: hi (42 x 19 @ 1040)
[ 0.348470] Timothy: error_text: hr-HR (62 x 19 @ 1060)
[ 0.348561] Timothy: error_text: hr (62 x 19 @ 1080)
[ 0.348604] Timothy: error_text: hu-HU (32 x 19 @ 1100)
[ 0.348678] Timothy: error_text: hu (32 x 19 @ 1120)
[ 0.348722] Timothy: error_text: hy (39 x 19 @ 1140)
[ 0.348782] Timothy: error_text: id (33 x 19 @ 1160)
[ 0.348828] Timothy: error_text: in (33 x 19 @ 1180)
[ 0.348871] Timothy: error_text: is (32 x 19 @ 1200)
[ 0.348924] Timothy: error_text: it-CH (41 x 19 @ 1220)
[ 0.348992] Timothy: error_text: it-IT (41 x 19 @ 1240)
[ 0.349054] Timothy: error_text: it (41 x 19 @ 1260)
[ 0.349097] Timothy: error_text: iw (41 x 19 @ 1280)
[ 0.349166] Timothy: error_text: ja-JP (144 x 19 @ 1300)
[ 0.349357] Timothy: error_text: ja (144 x 19 @ 1320)
[ 0.349399] Timothy: error_text: ka (162 x 19 @ 1340)
[ 0.349527] Timothy: error_text: kk (35 x 19 @ 1360)
[ 0.349583] Timothy: error_text: km (37 x 19 @ 1380)
[ 0.349649] Timothy: error_text: kn (41 x 19 @ 1400)
[ 0.349724] Timothy: error_text: ko-KR (30 x 19 @ 1420)
[ 0.349809] Timothy: error_text: ko (30 x 19 @ 1440)
[ 0.349851] Timothy: error_text: ky (34 x 19 @ 1460)
[ 0.349902] Timothy: error_text: lo (44 x 19 @ 1480)
[ 0.349965] Timothy: error_text: lt-LT (43 x 19 @ 1500)
[ 0.350047] Timothy: error_text: lt (43 x 19 @ 1520)
[ 0.350091] Timothy: error_text: lv-LV (39 x 19 @ 1540)
[ 0.350161] Timothy: error_text: lv (39 x 19 @ 1560)
[ 0.350204] Timothy: error_text: mk (52 x 19 @ 1580)
[ 0.350266] Timothy: error_text: ml (44 x 19 @ 1600)
[ 0.350339] Timothy: error_text: mn (45 x 19 @ 1620)
[ 0.350399] Timothy: error_text: mr (23 x 19 @ 1640)
[ 0.350463] Timothy: error_text: ms (36 x 19 @ 1660)
[ 0.350519] Timothy: error_text: my (86 x 19 @ 1680)
[ 0.350612] Timothy: error_text: nb-NO (26 x 19 @ 1700)
[ 0.350686] Timothy: error_text: nb (26 x 19 @ 1720)
[ 0.350728] Timothy: error_text: ne (23 x 19 @ 1740)
[ 0.350778] Timothy: error_text: nl-BE (31 x 19 @ 1760)
[ 0.350852] Timothy: error_text: nl-NL (31 x 19 @ 1780)
[ 0.350915] Timothy: error_text: nl (31 x 19 @ 1800)
[ 0.350959] Timothy: error_text: pa (34 x 19 @ 1820)
[ 0.351025] Timothy: error_text: pl-PL (28 x 19 @ 1840)
[ 0.351103] Timothy: error_text: pl (28 x 19 @ 1860)
[ 0.351145] Timothy: error_text: pt-BR (28 x 19 @ 1880)
[ 0.351217] Timothy: error_text: pt-PT (28 x 19 @ 1900)
[ 0.351280] Timothy: error_text: pt (28 x 19 @ 1920)
[ 0.351324] Timothy: error_text: ro-RO (44 x 19 @ 1940)
[ 0.351398] Timothy: error_text: ro (44 x 19 @ 1960)
[ 0.351442] Timothy: error_text: ru-RU (52 x 19 @ 1980)
[ 0.351535] Timothy: error_text: ru (52 x 19 @ 2000)
[ 0.351578] Timothy: error_text: si (44 x 19 @ 2020)
[ 0.351655] Timothy: error_text: sk-SK (43 x 19 @ 2040)
[ 0.351742] Timothy: error_text: sk (43 x 19 @ 2060)
[ 0.351785] Timothy: error_text: sl-SI (47 x 19 @ 2080)
[ 0.351865] Timothy: error_text: sl (47 x 19 @ 2100)
[ 0.351906] Timothy: error_text: sq (45 x 19 @ 2120)
[ 0.351997] Timothy: error_text: sr-Latn (48 x 19 @ 2140)
[ 0.352077] Timothy: error_text: sr-RS (52 x 19 @ 2160)
[ 0.352150] Timothy: error_text: sr (52 x 19 @ 2180)
[ 0.352193] Timothy: error_text: sv-SE (22 x 19 @ 2200)
[ 0.352267] Timothy: error_text: sv (22 x 19 @ 2220)
[ 0.352310] Timothy: error_text: sw (153 x 19 @ 2240)
[ 0.352395] Timothy: error_text: ta (41 x 19 @ 2260)
[ 0.352464] Timothy: error_text: te (110 x 19 @ 2280)
[ 0.352568] Timothy: error_text: th-TH (73 x 19 @ 2300)
[ 0.352668] Timothy: error_text: th (73 x 19 @ 2320)
[ 0.352711] Timothy: error_text: tr-TR (33 x 19 @ 2340)
[ 0.352782] Timothy: error_text: tr (33 x 19 @ 2360)
[ 0.352826] Timothy: error_text: uk-UA (63 x 19 @ 2380)
[ 0.352910] Timothy: error_text: uk (63 x 19 @ 2400)
[ 0.352954] Timothy: error_text: ur (34 x 19 @ 2420)
[ 0.353019] Timothy: error_text: uz (33 x 19 @ 2440)
[ 0.353073] Timothy: error_text: vi-VN (22 x 19 @ 2460)
[ 0.353146] Timothy: error_text: vi (22 x 19 @ 2480)
[ 0.353191] Timothy: error_text: zh-CN (46 x 19 @ 2500)
[ 0.353200] error_text: zh-CN (46 x 19 @ 2500)
[ 0.592899] Timothy: installing_text: af_ZA (207 x 19 @ 0)
[ 0.593023] Timothy: installing_text: af (207 x 19 @ 20)
[ 0.593102] Timothy: installing_text: am_ET (159 x 19 @ 40)
[ 0.593213] Timothy: installing_text: am (159 x 19 @ 60)
[ 0.593300] Timothy: installing_text: ar_EG (122 x 19 @ 80)
[ 0.593396] Timothy: installing_text: ar_XB (156 x 19 @ 100)
[ 0.593487] Timothy: installing_text: ar (122 x 19 @ 120)
[ 0.593564] Timothy: installing_text: az (213 x 19 @ 140)
[ 0.593671] Timothy: installing_text: be (209 x 19 @ 160)
[ 0.593784] Timothy: installing_text: bg_BG (267 x 19 @ 180)
[ 0.593893] Timothy: installing_text: bg (267 x 19 @ 200)
[ 0.593965] Timothy: installing_text: bn (191 x 19 @ 220)
[ 0.594084] Timothy: installing_text: bs (129 x 19 @ 240)
[ 0.594176] Timothy: installing_text: ca_ES (295 x 19 @ 260)
[ 0.594342] Timothy: installing_text: ca (295 x 19 @ 280)
[ 0.594414] Timothy: installing_text: cs_CZ (191 x 19 @ 300)
[ 0.594503] Timothy: installing_text: cs (191 x 19 @ 320)
[ 0.594577] Timothy: installing_text: da_DK (199 x 19 @ 340)
[ 0.594676] Timothy: installing_text: da (199 x 19 @ 360)
[ 0.594750] Timothy: installing_text: de_AT (187 x 19 @ 380)
[ 0.594839] Timothy: installing_text: de_CH (187 x 19 @ 400)
[ 0.594914] Timothy: installing_text: de_DE (187 x 19 @ 420)
[ 0.594990] Timothy: installing_text: de_LI (187 x 19 @ 440)
[ 0.595066] Timothy: installing_text: de (187 x 19 @ 460)
[ 0.595142] Timothy: installing_text: el_GR (249 x 19 @ 480)
[ 0.595264] Timothy: installing_text: el (249 x 19 @ 500)
[ 0.595338] Timothy: installing_text: en_AU (156 x 19 @ 520)
[ 0.595420] Timothy: installing_text: en_CA (156 x 19 @ 540)
[ 0.595494] Timothy: installing_text: en_GB (156 x 19 @ 560)
[ 0.595568] Timothy: installing_text: en_IN (156 x 19 @ 580)
[ 0.595642] Timothy: installing_text: en_NZ (156 x 19 @ 600)
[ 0.595717] Timothy: installing_text: en_SG (156 x 19 @ 620)
[ 0.595791] Timothy: installing_text: en_US (156 x 19 @ 640)
[ 0.595865] Timothy: installing_text: en_XA (254 x 19 @ 660)
[ 0.595986] Timothy: installing_text: en_XC (156 x 19 @ 680)
[ 0.596061] Timothy: installing_text: en (156 x 19 @ 700)
[ 0.596135] Timothy: installing_text: es_ES (232 x 19 @ 720)
[ 0.596279] Timothy: installing_text: es_US (232 x 19 @ 740)
[ 0.596355] Timothy: installing_text: es (232 x 19 @ 760)
[ 0.596428] Timothy: installing_text: et_EE (220 x 19 @ 780)
[ 0.596523] Timothy: installing_text: et (220 x 19 @ 800)
[ 0.596599] Timothy: installing_text: eu (231 x 19 @ 820)
[ 0.596693] Timothy: installing_text: fa_IR (164 x 19 @ 840)
[ 0.596843] Timothy: installing_text: fa (164 x 19 @ 860)
[ 0.596919] Timothy: installing_text: fi_FI (215 x 19 @ 880)
[ 0.597028] Timothy: installing_text: fil_PH (243 x 19 @ 900)
[ 0.597129] Timothy: installing_text: fil (243 x 19 @ 920)
[ 0.597203] Timothy: installing_text: fi (215 x 19 @ 940)
[ 0.597279] Timothy: installing_text: fr_BE (264 x 19 @ 960)
[ 0.597383] Timothy: installing_text: fr_CA (321 x 19 @ 980)
[ 0.597466] Timothy: installing_text: fr_CH (264 x 19 @ 1000)
[ 0.597539] Timothy: installing_text: fr_FR (264 x 19 @ 1020)
[ 0.597611] Timothy: installing_text: fr (264 x 19 @ 1040)
[ 0.597684] Timothy: installing_text: gl (228 x 19 @ 1060)
[ 0.597781] Timothy: installing_text: gu (168 x 19 @ 1080)
[ 0.597897] Timothy: installing_text: hi_IN (184 x 19 @ 1100)
[ 0.598013] Timothy: installing_text: hi (184 x 19 @ 1120)
[ 0.598088] Timothy: installing_text: hr_HR (192 x 19 @ 1140)
[ 0.598183] Timothy: installing_text: hr (192 x 19 @ 1160)
[ 0.598257] Timothy: installing_text: hu_HU (179 x 19 @ 1180)
[ 0.598354] Timothy: installing_text: hu (179 x 19 @ 1200)
[ 0.598428] Timothy: installing_text: hy_AM (261 x 19 @ 1220)
[ 0.598549] Timothy: installing_text: hy (261 x 19 @ 1240)
[ 0.598623] Timothy: installing_text: in_ID (192 x 19 @ 1260)
[ 0.598768] Timothy: installing_text: in (192 x 19 @ 1280)
[ 0.598843] Timothy: installing_text: is (163 x 19 @ 1300)
[ 0.598945] Timothy: installing_text: it_CH (261 x 19 @ 1320)
[ 0.599054] Timothy: installing_text: it_IT (261 x 19 @ 1340)
[ 0.599128] Timothy: installing_text: it (261 x 19 @ 1360)
[ 0.599203] Timothy: installing_text: iw_IL (114 x 19 @ 1380)
[ 0.599293] Timothy: installing_text: iw (114 x 19 @ 1400)
[ 0.599368] Timothy: installing_text: ja_JP (309 x 19 @ 1420)
[ 0.599527] Timothy: installing_text: ja (309 x 19 @ 1440)
[ 0.599598] Timothy: installing_text: ka (375 x 19 @ 1460)
[ 0.599754] Timothy: installing_text: kk (192 x 19 @ 1480)
[ 0.599866] Timothy: installing_text: km_KH (100 x 19 @ 1500)
[ 0.599951] Timothy: installing_text: km (100 x 19 @ 1520)
[ 0.600027] Timothy: installing_text: kn (187 x 19 @ 1540)
[ 0.600199] Timothy: installing_text: ko_KR (122 x 19 @ 1560)
[ 0.600290] Timothy: installing_text: ko (122 x 19 @ 1580)
[ 0.600365] Timothy: installing_text: ky (212 x 19 @ 1600)
[ 0.600476] Timothy: installing_text: lo (163 x 19 @ 1620)
[ 0.600578] Timothy: installing_text: lt_LT (185 x 19 @ 1640)
[ 0.600681] Timothy: installing_text: lt (185 x 19 @ 1660)
[ 0.600755] Timothy: installing_text: lv_LV (275 x 19 @ 1680)
[ 0.600865] Timothy: installing_text: lv (275 x 19 @ 1700)
[ 0.600936] Timothy: installing_text: mk (256 x 19 @ 1720)
[ 0.601049] Timothy: installing_text: ml (226 x 19 @ 1740)
[ 0.601188] Timothy: installing_text: mn (270 x 19 @ 1760)
[ 0.601344] Timothy: installing_text: mr (159 x 19 @ 1780)
[ 0.601451] Timothy: installing_text: ms_MY (187 x 19 @ 1800)
[ 0.601548] Timothy: installing_text: ms (187 x 19 @ 1820)
[ 0.601623] Timothy: installing_text: my_MM (204 x 19 @ 1840)
[ 0.601748] Timothy: installing_text: my (204 x 19 @ 1860)
[ 0.601824] Timothy: installing_text: nb_NO (207 x 19 @ 1880)
[ 0.601927] Timothy: installing_text: nb (207 x 19 @ 1900)
[ 0.602002] Timothy: installing_text: ne (191 x 19 @ 1920)
[ 0.602117] Timothy: installing_text: nl_BE (171 x 19 @ 1940)
[ 0.602199] Timothy: installing_text: nl_NL (171 x 19 @ 1960)
[ 0.602275] Timothy: installing_text: nl (171 x 19 @ 1980)
[ 0.602351] Timothy: installing_text: pa (190 x 19 @ 2000)
[ 0.602499] Timothy: installing_text: pl_PL (192 x 19 @ 2020)
[ 0.602596] Timothy: installing_text: pl (192 x 19 @ 2040)
[ 0.602671] Timothy: installing_text: pt_BR (217 x 19 @ 2060)
[ 0.602811] Timothy: installing_text: pt_PT (211 x 19 @ 2080)
[ 0.602893] Timothy: installing_text: pt (217 x 19 @ 2100)
[ 0.602967] Timothy: installing_text: ro_RO (234 x 19 @ 2120)
[ 0.603058] Timothy: installing_text: ro (234 x 19 @ 2140)
[ 0.603133] Timothy: installing_text: ru_RU (225 x 19 @ 2160)
[ 0.603242] Timothy: installing_text: ru (225 x 19 @ 2180)
[ 0.603318] Timothy: installing_text: si (260 x 19 @ 2200)
[ 0.603465] Timothy: installing_text: sk_SK (210 x 19 @ 2220)
[ 0.603560] Timothy: installing_text: sk (210 x 19 @ 2240)
[ 0.603635] Timothy: installing_text: sl_SI (214 x 19 @ 2260)
[ 0.603743] Timothy: installing_text: sl (214 x 19 @ 2280)
[ 0.603817] Timothy: installing_text: sq (221 x 19 @ 2300)
[ 0.603910] Timothy: installing_text: sr__#Latn (193 x 19 @ 2320)
[ 0.603999] Timothy: installing_text: sr_RS (228 x 19 @ 2340)
[ 0.604110] Timothy: installing_text: sr (228 x 19 @ 2360)
[ 0.604185] Timothy: installing_text: sv_SE (196 x 19 @ 2380)
[ 0.604284] Timothy: installing_text: sv (196 x 19 @ 2400)
[ 0.604360] Timothy: installing_text: sw_TZ (195 x 19 @ 2420)
[ 0.604507] Timothy: installing_text: sw (195 x 19 @ 2440)
[ 0.604582] Timothy: installing_text: ta (241 x 19 @ 2460)
[ 0.604707] Timothy: installing_text: te (193 x 19 @ 2480)
[ 0.604837] Timothy: installing_text: th_TH (159 x 19 @ 2500)
[ 0.604935] Timothy: installing_text: th (159 x 19 @ 2520)
[ 0.605011] Timothy: installing_text: tr_TR (202 x 19 @ 2540)
[ 0.605124] Timothy: installing_text: tr (202 x 19 @ 2560)
[ 0.605199] Timothy: installing_text: uk_UA (245 x 19 @ 2580)
[ 0.605308] Timothy: installing_text: uk (245 x 19 @ 2600)
[ 0.605384] Timothy: installing_text: ur (158 x 19 @ 2620)
[ 0.605481] Timothy: installing_text: uz (207 x 19 @ 2640)
[ 0.605588] Timothy: installing_text: vi_VN (224 x 19 @ 2660)
[ 0.605726] Timothy: installing_text: vi (224 x 19 @ 2680)
[ 0.605802] Timothy: installing_text: zh_CN (266 x 19 @ 2700)
[ 0.605986] Timothy: installing_text: zh_HK (112 x 19 @ 2720)
[ 0.606087] Timothy: installing_text: zh (112 x 19 @ 2740)
[ 0.606103] installing_text: zh (112 x 19 @ 2740)

粗看好像沒啥問題,但是,仔細一看,發現,爲啥其他幾個文件解析出來的都是中劃線“-”,到了installing_text這裏變成了下劃線“_”,難道是生成的素材文件有問題?

於是我網上查了一下,recovery_l10n裏面確實有這麼個bug,就是用了下劃線作爲分隔符。但是,Android8.0的代碼和網上找到的都不一樣,並沒有直接使用分隔符。下面,我們就來看一下這個工具app的源碼。

recovery_l10n

這個工具的代碼並不多,只有一個Main.java。簡單分析一下,可以看到生成文件的函數是mergeBitmaps()。這個函數雖然很長,但是其主要的部分是和生成圖片有關的,我們只需要關注其中產生數據的部分就行了。

private void mergeBitmaps(final Locale[] locales) {
	HashMap<String, Integer> countByLanguage = new HashMap<String, Integer>();

	...
	
	for (Locale loc : locales) {
	
		...
		
		String lang = loc.getLanguage();
		if (countByLanguage.containsKey(lang)) {
			countByLanguage.put(lang, countByLanguage.get(lang)+1);
		} else {
			countByLanguage.put(lang, 1);
		}
	}

	...
	
	for (Locale loc : locales) {
		
		...

		// Make the last country variant for a given language be
		// the catch-all for that language (because recovery will
		// take the first one that matches).
		String lang = loc.getLanguage();
		if (countByLanguage.get(lang) > 1) {
			countByLanguage.put(lang, countByLanguage.get(lang)-1);
			lang = loc.toString();
		}
		int tw = right - left;
		Log.i(TAG, "encoding \"" + loc + "\" as \"" + lang + "\": " + tw + " x " + h);
		
		...
		
	}
	
	...
	
}

這裏的大致意思是,如果一種語言對應的國家是唯一的,lang = loc.getlanguage(),如果不唯一,lang=loc.toString()。後面有日誌把lang和loc都打印出來了。所以我們再跑一遍app來看日誌。在後一種情況下,這裏打印出來的都是下劃線。問題就出在toString()這裏了。
在這裏,你可以直接使用replace方法直接替換掉分隔符,但是這種方式太生硬,不優雅。怎麼做才能比較優雅的實現需求呢?
recovery裏面的本地化信息的來源是RecoverySystem.install()方法裏面在cache分區下寫入的文件,如果recovery裏面用的是中劃線,那麼上述方法寫入的時候應該就是中劃線。我們來看一下RecoverySystem裏面生成字符串的部分:

final String filenameArg = "--update_package=" + filename + "\n";
final String localeArg = "--locale=" + Locale.getDefault().toLanguageTag() + "\n";
final String securityArg = "--security\n";

從上面可以看到,這裏並沒有使用toString()方法,而是使用了toLanguageTag()。再來對比一下toString()和toLanguageTag()這兩個方法的實現,可以看到他們最明顯的區別就是分隔符用的不一樣,前者用的是下劃線,而後者用的是中劃線。爲了recovery裏面比對的時候源和目標的一致,將這裏的toString()換成toLanguageTag(),是最理想的方案。
從嚴謹的角度出發,我還增加了日誌打印,比較了toString()和toLanguageTag().replace("-", “_”)的返回值,發現只有三個語言的返回值是不一樣的,而這三個語言跟我們的產品都不相關,所以我這裏可以放心大膽的這麼幹。
順別說一點,在recovery_l10n中,不管在下拉里面選擇的是什麼,最後生成的文件都是text-out.png。我這裏順手改成了根據選擇,自動生成文件名。最終的修改我貼在這裏了。

diff --git a/bootable/recovery/tools/recovery_l10n/src/com/android/recovery_l10n/Main.java b/bootable/recovery/tools/recovery_l10n/src/com/android/recovery_l10n/Main.java
old mode 100644
new mode 100755
index 30d45f6..3560c13
--- a/bootable/recovery/tools/recovery_l10n/src/com/android/recovery_l10n/Main.java
+++ b/bootable/recovery/tools/recovery_l10n/src/com/android/recovery_l10n/Main.java
@@ -78,6 +78,7 @@ public class Main extends Activity {
     HashMap<Locale, Bitmap> savedBitmaps;
     TextView mText;
     int mStringId = R.string.recovery_installing;
+    String mFileName = "";
 
     public class TextCapture implements Runnable {
         private Locale nextLocale;
@@ -136,11 +137,26 @@ public class Main extends Activity {
             public void onItemSelected(AdapterView parent, View view,
                                        int pos, long id) {
                 switch (pos) {
-                    case 0: mStringId = R.string.recovery_installing; break;
-                    case 1: mStringId = R.string.recovery_erasing; break;
-                    case 2: mStringId = R.string.recovery_no_command; break;
-                    case 3: mStringId = R.string.recovery_error; break;
-                    case 4: mStringId = R.string.recovery_installing_security; break;
+                    case 0:
+                        mStringId = R.string.recovery_installing;
+                        mFileName = "installing_text_raw.png";
+                        break;
+                    case 1:
+                        mStringId = R.string.recovery_erasing;
+                        mFileName = "erasing_text_raw.png";
+                        break;
+                    case 2:
+                        mStringId = R.string.recovery_no_command;
+                        mFileName = "no_command_text_raw.png";
+                        break;
+                    case 3:
+                        mStringId = R.string.recovery_error;
+                        mFileName = "error_text_raw.png";
+                        break;
+                    case 4:
+                        mStringId = R.string.recovery_installing_security;
+                        mFileName = "installing_security_text_raw.png";
+                        break;
                 }
             }
             @Override public void onNothingSelected(AdapterView parent) { }
@@ -297,7 +313,7 @@ public class Main extends Activity {
             String lang = loc.getLanguage();
             if (countByLanguage.get(lang) > 1) {
                 countByLanguage.put(lang, countByLanguage.get(lang)-1);
-                lang = loc.toString();
+                lang = loc.toLanguageTag();
             }
             int tw = right - left;
             Log.i(TAG, "encoding \"" + loc + "\" as \"" + lang + "\": " + tw + " x " + h);
@@ -329,7 +345,7 @@ public class Main extends Activity {
         out.setPixel(4, p, colorFor(0));
         p++;
 
-        saveBitmap(out, "text-out.png");
-        Log.i(TAG, "wrote text-out.png");
+        saveBitmap(out, mFileName);
+        Log.i(TAG, "wrote " + mFileName);
     }
 }
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章