We decompile the xiaomi scanner application and take the scan result

A colleague had a suggestion:

"Write to me for a jar of chips a barcode reader for android, just to write the results in the files and the time, my brother needs." In the end, it turned out to be not a brother, and it was not necessary, and in general a can of chips is expensive

Out of interest, I ran through ready-made solutions in js and android, and since. I have a xiaomi smartphone with a ready-made scanner application, I thought, why not try to just take the scan results from it? Ok, I tried to google info about intents or ready-made instructions for getting data from the scanner, but in vain. It was decided to scan the application manifest for intents.



  1. Find and pick up the APK from the phone.



    adb shell
    ~:/pm list packages | grep scanner
    ~:/pm path com.xiaomi.scanner
    exit
    pull /system/priv-app/MiuiScanner/MiuiScanner.apk
    
  2. We decompile apk using an online service .
  3. Examining the manifest. Find the first action that comes across.



    AndroidManifest.xml


  4. Create a new android project and write a scanner call.



      val intent = Intent("miui.intent.action.scanbarcode")
       startActivityForResult(intent, 1);
    
  5. , … , , ? , . .



    ScanActivity.java




    .

  6. , EXTRA_INTENT_IS_BACKTO_THIRDAPP isBackToThirdApp.



    AppUtils.java


  7. .



      val intent = Intent("miui.intent.action.scanbarcode")
      intent.putExtra("isBackToThirdApp",true)
      startActivityForResult(intent, 1);
    
  8. .



            super.onActivityResult(requestCode, resultCode, data)
            if (resultCode==Activity.RESULT_OK){
                    result.setText(data?.extras?.getString("result"))
            } 
    
  9. .
  10. , Xiaomi ,



All Articles