Fix Wi-Fi QR code decode fail
ZXing generate QR code with default encoding ISO-8859-1, the generated QR code is wrong encoded if there is a character outside of the charset. Generate QR code of UTF-8 encoding. Bug: 131851854 Test: manual Change-Id: I96a5e72a978c654b62d89b3b11dd3016bf0ee1df
This commit is contained in:
@@ -128,4 +128,23 @@ public class QrCameraTest {
|
||||
|
||||
assertThat(mQrCode).isEqualTo(googleUrl);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDecode_unicodePictureCaptured_QrCodeCorrectValue() {
|
||||
final String unicodeTest = "中文測試";
|
||||
|
||||
try {
|
||||
final Bitmap bmp = QrCodeGenerator.encodeQrCode(unicodeTest, 320);
|
||||
final int[] intArray = new int[bmp.getWidth() * bmp.getHeight()];
|
||||
bmp.getPixels(intArray, 0, bmp.getWidth(), 0, 0, bmp.getWidth(), bmp.getHeight());
|
||||
LuminanceSource source = new RGBLuminanceSource(bmp.getWidth(), bmp.getHeight(),
|
||||
intArray);
|
||||
final BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
|
||||
mCamera.decodeImage(bitmap);
|
||||
bmp.recycle();
|
||||
} catch (WriterException e) {
|
||||
}
|
||||
|
||||
assertThat(mQrCode).isEqualTo(unicodeTest);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user