Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7f319c47 authored by Narayan Kamath's avatar Narayan Kamath Committed by Android Git Automerger
Browse files

am 1dc550fa: Merge "Fix packing of values at offset 16."

* commit '1dc550fa':
  Fix packing of values at offset 16.
parents 89e4c715 1dc550fa
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -1597,9 +1597,9 @@ void ResTable_config::copyFromDeviceNoSwap(const ResTable_config& o) {
      out[0] = in[0];
      out[1] = in[1];
  } else {
      uint8_t first = (in[0] - base) & 0x00ef;
      uint8_t second = (in[1] - base) & 0x00ef;
      uint8_t third = (in[2] - base) & 0x00ef;
      uint8_t first = (in[0] - base) & 0x007f;
      uint8_t second = (in[1] - base) & 0x007f;
      uint8_t third = (in[2] - base) & 0x007f;

      out[0] = (0x80 | (third << 2) | (second >> 3));
      out[1] = ((second << 5) | first);
+24 −0
Original line number Diff line number Diff line
@@ -75,6 +75,30 @@ TEST(ResourceTypesTest, ResourceConfig_packAndUnpack3LetterLanguage) {
     EXPECT_EQ(0, out[3]);
}

TEST(ResourceTypesTest, ResourceConfig_packAndUnpack3LetterLanguageAtOffset16) {
     ResTable_config config;
     config.packLanguage("tgp");

     // We had a bug where we would accidentally mask
     // the 5th bit of both bytes
     //
     // packed[0] = 1011 1100
     // packed[1] = 1101 0011
     //
     // which is equivalent to:
     // 1  [0]   [1]   [2]
     // 1-01111-00110-10011
     EXPECT_EQ(0xbc, config.language[0]);
     EXPECT_EQ(0xd3, config.language[1]);

     char out[4] = { 1, 1, 1, 1};
     config.unpackLanguage(out);
     EXPECT_EQ('t', out[0]);
     EXPECT_EQ('g', out[1]);
     EXPECT_EQ('p', out[2]);
     EXPECT_EQ(0, out[3]);
}

TEST(ResourceTypesTest, ResourceConfig_packAndUnpack3LetterRegion) {
     ResTable_config config;
     config.packRegion("419");