Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to decode android.os.Build.SERIAL?

I'm working on the recurring serial number topic to provide a unique id.

I try this :

       String serial = null; 

        try {
            Class<?> c = Class.forName("android.os.SystemProperties");
            Method get = c.getMethod("get", String.class);
            serial = (String) get.invoke(c, "ro.serialno");
        } catch (Exception ignored) {
        }

and

        StringBuilder sb = new StringBuilder();
        sb.append("SERIAL ").append(android.os.Build.SERIAL).append("\n");


        textReportAdmin.setText(
                sb.toString());

Both gives the same value : C4F12FDD949F22F

On the box and on the sticker of my tab, the serial number is : RF2C202WYME

I work on a tab, no way to use

    TelephonyManager telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
    String imei = telephonyManager.getDeviceId();

IMEI is empty in my case.

SERIAL is what I need, but I need it in clear version as displayed on the sticker upon the barcode behind the tab.

I guess it is possible as, When going in the system app, and looking at the state of the device, it is displayed in clear...

How to convert the value returned by android.os.Build.SERIAL to the human visible one ?

EDITION : I also looked in :

        sb.append("PRODUCT ").append(android.os.Build.PRODUCT).append("\n");
        sb.append("BOARD ").append(android.os.Build.BOARD).append("\n");
        sb.append("BOOTLOADER ").append(android.os.Build.BOOTLOADER).append("\n");
        sb.append("BRAND ").append(android.os.Build.BRAND).append("\n");
        sb.append("CPU_ABI ").append(android.os.Build.CPU_ABI).append("\n");
        sb.append("CPU_ABI2 ").append(android.os.Build.CPU_ABI2).append("\n");
        sb.append("DEVICE ").append(android.os.Build.DEVICE).append("\n");
        sb.append("DISPLAY ").append(android.os.Build.DISPLAY).append("\n");
        sb.append("FINGERPRINT ").append(android.os.Build.FINGERPRINT).append("\n");
        sb.append("HARDWARE ").append(android.os.Build.HARDWARE).append("\n");
        sb.append("HOST ").append(android.os.Build.HOST).append("\n");
        sb.append("ID ").append(android.os.Build.ID).append("\n");
        sb.append("MANUFACTURER ").append(android.os.Build.MANUFACTURER).append("\n");
        sb.append("MODEL ").append(android.os.Build.MODEL).append("\n");
        sb.append("PRODUCT ").append(android.os.Build.PRODUCT).append("\n");
        sb.append("RADIO ").append(android.os.Build.RADIO).append("\n");
        sb.append("SERIAL ").append(android.os.Build.SERIAL).append("\n");
        sb.append("TAGS ").append(android.os.Build.TAGS).append("\n");
        sb.append("TIME ").append(android.os.Build.TIME).append("\n");
        sb.append("TYPE ").append(android.os.Build.TYPE).append("\n");
        sb.append("USER ").append(android.os.Build.USER).append("\n");

nowhere, I get the serialnumber as on the sticker, while it can be possible to be found as ,the system itself is able to display it in "Parameters", "About", "State" (I don't know the words in english, I have a french tab, and it is "Paramètres", "A propos de", "Etat" and then "Serial Number", the clear version, as on the sticker.

like image 449
christophe46 Avatar asked Dec 07 '22 13:12

christophe46


2 Answers

Have you tried this?

String serial = null; 

try {
     Class<?> c = Class.forName("android.os.SystemProperties");
     Method get = c.getMethod("get", String.class);
     serial = (String) get.invoke(c, "ril.serialnumber");
 } catch (Exception ignored) {
 }
like image 191
Jonathan Liono Avatar answered Dec 09 '22 03:12

Jonathan Liono


If you want to get the serial number as shown on the back of the device and if you are using the Samsung Galaxy Tab then why not use the 'ril.serialnumber' property

Items changed to what your device should show:

$ adb shell getprop | grep serial
[ril.serialnumber]: [RF2C202WYME]
[ro.boot.serialno]: [c4f12fdd949f22f]
[ro.serialno]: [c4f12fdd949f22f]

Pre-jellybean 'ro.boot.serialno' didn't exist

like image 25
James Avatar answered Dec 09 '22 03:12

James