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