Android
匿名设备标识符OAID
输出java
随着大数据和人工智能时代的到来,数据的价值也逐渐增长,移动终端设备标识码,如国际移动设备识别码(IMEI)、Wi-Fi MAC地址、SIM卡国际移动用户识别码(IMSI)和蓝牙地址等终端设备标识信息的收集和使用成为广泛现象。同时各国对用户隐私保护的要求愈来愈高,传统的移动终端设备标识如国际移动设备识别码(IMEI)等已被部分国家认定为用户隐私的一部分。另外,在不少与隐私无关的场景中,如生产、售后、报关、政府抽检等场景,传统设备标识码(如IMEI)被篡改或冒用的状况时有发生,给设备生产企业的经济利益带来损失,同时对设备追溯带来较大影响。git
SDK 获取地址github
miit_mdid_x.x.x.aar
拷贝到项的 libs
目录,并设置依赖,其中 x.x.x 表明版本号。supplierconfig.json
拷贝到项目 assets
目录下,并修改里边对应 内容,特别是须要设置 appid 的部分。须要设置 appid 的部分须要去对应厂商 的应用商店里注册本身的 app。implementation files(‘libs/miit_mdid_x.x.x.aar’)
复制代码
-keep class com.bun.miitmdid.core.** {*;}
复制代码
ndk {
abiFilters 'armeabi-v7a', 'x86', 'arm64-v8a', 'x86_64', 'armeabi'
}
packagingOptions {
doNotStrip "*/armeabi-v7a/*.so"
doNotStrip "*/x86/*.so"
doNotStrip "*/arm64-v8a/*.so"
doNotStrip "*/x86_64/*.so"
doNotStrip "armeabi.so"
}
复制代码
public class APP extends Application {
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
JLibrary.InitEntry(base);
}
}
复制代码
public interface AppIdsUpdater {
void OnValidId(@NonNull JSONObject ids);
}
复制代码
public class MiIdHelper implements IIdentifierListener {
private boolean isSupport;
private String oaid, vaid, aaid;
public JSONObject getDeviceIds(Context cxt) {
long startTime = System.currentTimeMillis();
int code = CallFromReflect(cxt);
long endTime = System.currentTimeMillis();
long time = endTime - startTime;
JSONObject jsonObject = new JSONObject();
try {
jsonObject.put("description", descriptionCode(code));
jsonObject.put("code", code);
jsonObject.put("time", time);
jsonObject.put("isSupport", isSupport);
jsonObject.put("oaid", oaid);
jsonObject.put("vaid", vaid);
jsonObject.put("aaid", aaid);
} catch (Exception e) {
e.printStackTrace();
}
return jsonObject;
}
private int CallFromReflect(Context cxt) {
return MdidSdkHelper.InitSdk(cxt, true, this);
}
@Override
public void OnSupport(boolean isSupport, IdSupplier _supplier) {
this.isSupport = isSupport;
if (_supplier != null) {
this.oaid = _supplier.getOAID();
this.vaid = _supplier.getVAID();
this.aaid = _supplier.getAAID();
_supplier.shutDown();
}
}
private String descriptionCode(int code) {
switch (code) {
case ErrorCode.INIT_ERROR_DEVICE_NOSUPPORT:
return "DEVICE_NOSUPPORT";
case ErrorCode.INIT_ERROR_LOAD_CONFIGFILE:
return "LOAD_CONFIGFILE";
case ErrorCode.INIT_ERROR_MANUFACTURER_NOSUPPORT:
return "MANUFACTURER_NOSUPPORT";
case ErrorCode.INIT_ERROR_RESULT_DELAY:
return "RESULT_DELAY";
case ErrorCode.INIT_HELPER_CALL_ERROR:
return "HELPER_CALL_ERROR";
default:
return "SUCCESS";
}
}
}
复制代码
MiIdHelper miIdHelper = new MiIdHelper();
JSONObject result=miIdHelper.getDeviceIds(getApplicationContext());
复制代码
{
"description":"SUCCESS",
"code":0,
"time":49,
"isSupport":true,
"oaid":"cf8cc008bb5adf96",
"vaid":"f8239c19f92836f1",
"aaid":"0115d997-c845-4e86-8fed-58c4fb246827"
}
复制代码
Demojson