RK3399 Android7.1系统 自定义号码CMEI信息写入vendor_storage

https://blog.csdn.net/kris_fei/article/details/79580845

以上朋友写了基本概念,我们讨论下具体使用

存储SN, MAC, LAN,BT等data,主要特性是不会丢失以及系统启动各个阶段都可以访问,包括uboot, kernel, linux用户空间以及pc端

 

通过调用vendor_storage_write_sn()函数将CMEI信息写在客户数据存储区/dev/vendor_storage


linux/ioctl.h

 68 #define READ_SECTOR_IO          _IOW('r', 0x04, unsigned int)
 69 #define WRITE_SECTOR_IO         _IOW('r', 0x05, unsigned int)
 70 #define END_WRITE_SECTOR_IO     _IOW('r', 0x52, unsigned int)
 71 #define GET_FLASH_INFO_IO       _IOW('r', 0x1A, unsigned int)
 72 #define GET_BAD_BLOCK_IO        _IOW('r', 0x03, unsigned int)
 73 #define GET_LOCK_FLAG_IO        _IOW('r', 0x53, unsigned int)
 74
 75 #define VENDOR_REQ_TAG          0x56524551
 76 #define VENDOR_READ_IO          _IOW('v', 0x01, unsigned int)
 77 #define VENDOR_WRITE_IO         _IOW('v', 0x02, unsigned int)
1 struct rk_vendor_req {
 42         u32 tag;
 43         u16 id;
 44         u16 len;
 45         u8 data[1024];
 46 };

源码如下:
int vendor_storage_write_sn(char* sn)
{
    int ret ;
    struct rk_vendor_req req;
    memset(sn_buf_idb,0,sizeof(sn_buf_idb));
    int sys_fd = open("/dev/vendor_storage",O_RDWR,0);
    if(sys_fd < 0){
        //return -1;
        return sys_fd;
    }
    
    req.tag = VENDOR_REQ_TAG;
    req.id = VENDOR_SN_ID;  //16以上的数都可以厂商自定义
    req.len = 32;
    strncpy(req.data,sn,32);
    ret = ioctl(sys_fd, VENDOR_WRITE_IO, &req);
    close(sys_fd);
    if(ret){
        return -2;
    }

    return 0;
}

RK3399 Android7.1系统 自定义号码CMEI信息写入vendor_storage_第1张图片

你可能感兴趣的:(Android系统)