Runt
2025-08-28 c740f3b8e9ede62b5fbcd2a8b03b834dd35fdec5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package com.runt.open.mvi.utils;
 
import android.content.Context;
import android.provider.Settings;
import android.text.TextUtils;
 
import com.github.gzuliyujiang.oaid.DeviceID;
import com.github.gzuliyujiang.oaid.DeviceIdentifier;
 
import org.json.JSONObject;
 
/**
 * copy from: http://docs.aiduoyou.com/web/#/100/1495
 */
public class DeviceIdUtils {
 
 
    public static String getAndroidId(Context context) {
        try {
            return Settings.System.getString(context.getContentResolver(), Settings.System.ANDROID_ID);
        } catch (Exception e) {
            //e.printStackTrace();
        }
        return "";
    }
 
 
    public static JSONObject getDeviceIds(Context context) {
        try {
            JSONObject jsonObject = new JSONObject();
 
            String androidId = getAndroidId(context);
            if (!TextUtils.isEmpty(androidId)) {
                jsonObject.put("6", androidId);
            }
 
            DeviceID.supportedOAID(context);
            // 获取OAID/AAID,同步调用
            String OAID = DeviceIdentifier.getOAID(context);
            jsonObject.put("7", OAID);
            // 2022-03-15 暂时不管oaid
//            String OAID = SPManager.getValue(SPManager.OAID, "");
//            String OAID = PrefUtil.get(PrefUtil.OAID);
//            if (!TextUtils.isEmpty(OAID)) {
//                jsonObject.put("7", OAID);
//            }
 
            return jsonObject;
        } catch (Exception e) {
            //e.printStackTrace();
        }
        return null;
    }
 
 
 
}