Read SN (barcode) in NVRAM

Source: Internet
Author: User

In Custom_nvram_lid.h, find the value corresponding to the ID that needs to be read

Implement Nvramagent

Import Java.lang.string;import android.os.remoteexception;import android.os.ibinder;import android.os.IInterface; Import Android.os.binder;import Android.os.parcel;public interface nvramagent extends android.os.iinterface{/** Local -side IPC implementation stub class. */public static abstract class Stub extends Android.os.Binder implements Nvramagent {private static final J        Ava.lang.String descriptor = "Nvramagent"; /** Construct The stub at attach it to the interface.        */Public Stub () {this.attachinterface (this, descriptor);         }/** * Cast an IBinder object to an Nvramagent interface, * Generating a proxy if needed.                */public static nvramagent asinterface (Android.os.IBinder obj) {if ((Obj==null)) {            return null;            } android.os.IInterface iin = (android.os.IInterface) obj.querylocalinterface (descriptor); if ((Iin!=null) && (Iin instanceof Nvramagent)) {return (nvramagent) iin);        } return new NvRAMAgent.Stub.Proxy (obj);        } public Android.os.IBinder Asbinder () {return this; } public boolean ontransact (int code, ANDROID.OS.PARCEL data, android.os.Parcel reply, int flags) throws Android.os .                     remoteexception {switch (code) {case Interface_transaction: {                    Reply.writestring (descriptor);                return true;                    } case Transaction_readfile: {data.enforceinterface (descriptor);                    int _arg0;                    _arg0 = Data.readint ();                    byte[] _result = This.readfile (_arg0);                    Reply.writenoexception ();                    Reply.writebytearray (_result);                return true; } Case Transaction_writefiLE: {data.enforceinterface (descriptor);                    int _arg0;                    _arg0 = Data.readint ();                    Byte[] _ARG1;                    _ARG1 = Data.createbytearray ();                    int _result = This.writefile (_arg0, _ARG1);                    Reply.writenoexception ();                    Reply.writeint (_result);                return true;                } default: {break;        }} return Super.ontransact (code, data, reply, flags);            } private static Class Proxy implements Nvramagent {private Android.os.IBinder mremote;            Proxy (Android.os.IBinder remote) {mremote = remote;            } public Android.os.IBinder Asbinder () {return mremote;       } public java.lang.String Getinterfacedescriptor () {         return descriptor; } public byte[] readFile (int file_lid) throws Android.os.RemoteException {Android.os .                Parcel _data = Android.os.Parcel.obtain ();                Android.os.Parcel _reply = Android.os.Parcel.obtain ();                Byte[] _result;                    try {_data.writeinterfacetoken (descriptor);                    _data.writeint (File_lid);                    Mremote.transact (Stub.transaction_readfile, _data, _reply, 0);                    _reply.readexception ();                _result = _reply.createbytearray ();                    } finally {_reply.recycle ();                _data.recycle ();            } return _result;                } public int WriteFile (int file_lid, byte[] buff) throws Android.os.RemoteException {                Android.os.Parcel _data = Android.os.Parcel.obtain (); Android.os.Parcel _reply = Android.os.Parcel.obtain ();                int _result;                    try {_data.writeinterfacetoken (descriptor);                    _data.writeint (File_lid);                    _data.writebytearray (Buff);                    Mremote.transact (Stub.transaction_writefile, _data, _reply, 0);                    _reply.readexception ();                _result = _reply.readint ();                    } finally {_reply.recycle ();                _data.recycle ();            } return _result;        }} static final int transaction_readfile = (ibinder.first_call_transaction + 0);    static final int transaction_writefile = (ibinder.first_call_transaction + 1);    } public byte[] readFile (int file_lid) throws android.os.RemoteException; public int WriteFile (int file_lid, byte[] buff) throws android.os.RemoteException;}

The following is an example of reading SN in NVRAM (SN and IMEI together, ID in mt6582 is ap_cfg_reeb_product_info_lid)

IBinder Binder = Servicemanager.getservice ("nvramagent");

Nvramagent Agent = NvRAMAgent.Stub.asInterface (binder);

byte[] buff = null;

try {

Buff = Agent.readfile (+);//Ap_cfg_reeb_product_info_lid

} catch (Exception ee) {ee.printstacktrace (); }

Read SN (barcode) in NVRAM

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.