请尊重原创,转载请注明出处:http://blog.csdn.net/cbk861110/article/details/26851817
1.nvram lib id定义:
alps\mediatek\custom\prj\cgen\inc\Custom_NvRam_LID.h
typedef enum
{
AP_CFG_RDCL_FILE_AUDIO_LID=AP_CFG_CUSTOM_BEGIN_LID,
//AP_CFG_CUSTOM_BEGIN_LID: this lid must not be changed, it is reserved for system.
AP_CFG_REEB_PRODUCT_INFO_LID,
AP_CFG_CUSTOM_FILE_MAX_LID,
} CUSTOM_CFG_FILE_LID;
#define AP_CFG_REEB_PRODUCT_INFO_LID_VERNO "000"
2.nvram lib id的数据结构和版本号声明
\alps\mediatek\custom\prj\cgen\inc\Custom_NvRam_data_item.h
LID_BIT VER_LID(AP_CFG_REEB_PRODUCT_INFO_LID)
PRODUCT_INFO *CFG_FILE_PRODUCT_INFO_TOTAL
{
};
3.4.nvram lib内容加入nvram数组中
\alps\mediatek\custom\prj\cgen\inc\CFG_file_info_custom.h
const TCFG_FILE g_akCFG_File_Custom[]=
{
{
"/data/nvram/APCFG/APRDEB/PRODUCT_INFO", VER(AP_CFG_REEB_PRODUCT_INFO_LID), CFG_FILE_PRODUCT_INFO_SIZE,
CFG_FILE_PRODUCT_INFO_TOTAL, SIGNLE_DEFUALT_REC, (char *)&stPRODUCT_INFOConfigDefault,DataReset, NULL
},
};
4.nvram lib 数据结构定义
alps\mediatek\custom\prj\cgen\inc\CFG_file_info_custom.h
// the record structure define of PRODUCT_INFO nvram file
typedef struct
{
unsigned char imei[8];
unsigned char svn;
unsigned char pad;
} nvram_ef_imei_imeisv_struct;
typedef struct{
unsigned char barcode[64];
nvram_ef_imei_imeisv_struct IMEI[4];
unsigned char reserved[1024-40-64];
}PRODUCT_INFO;
//the record size and number of PRODUCT_INFO nvram file
#define CFG_FILE_PRODUCT_INFO_SIZE sizeof(PRODUCT_INFO)
#define CFG_FILE_PRODUCT_INFO_TOTAL 1
5.nvram lib 默认值定义
alps\mediatek\custom\prj\cgen\cfgdefault\CFG_PRODUCT_INFO_Default.h
PRODUCT_INFO stPRODUCT_INFOConfigDefault =
{
/* barcode */
{0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0},
/* IMEI*/
{{0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0},0x0,0x0,
{0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0},0x0,0x0,
{0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0},0x0,0x0,
{0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0},0x0,0x0},
/* reserved */
}
6.nvram lib id需要备份到BinRegion:
\alps\mediatek\custom\prj\cgen\CFG_file_info.c
FileName aBackupToBinRegion[]=
{
#ifndef MTK_PRODUCT_INFO_SUPPORT
{"PRODUCT_INFO",AP_CFG_REEB_PRODUCT_INFO_LID},
#endif
};
7.native(c)层读写:
[FAQ04545]【NvRAM】Native层读写nvram
1,NVM_GetFileDesc(file_lid, &rec_size, &rec_num,true);//读打开
2,read
3,NVM_CloseFileDesc
4,NVM_GetFileDesc(file_lid, &rec_size, &rec_num,false);//写打开
5,write
6,NVM_CloseFileDesc
8.java层读写:
参照[FAQ04542]【NvRAM】apk中中读写nvram
IBinder binder = ServiceManager.getService("NvRAMAgent");
NvRAMAgent agent = NvRAMAgent.Stub.asInterface(binder);
buffer = agent.readFile(AP_CFG_CUSTOM_FILE_LID_ID);
agent.writeFile(AP_CFG_CUSTOM_FILE_LID_ID,buffer);
请尊重原创,转载请注明出处:http://blog.csdn.net/cbk861110/article/details/26851817