panlili2024
2025-03-05 134209ad70f82051da3ce63471df0cc8f778e57d
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
58
59
60
61
62
63
64
65
package com.hdl.sdk.sourceos.qrcode;
 
import android.net.Uri;
import android.text.TextUtils;
 
import com.hdl.sdk.common.utils.SPUtils;
import com.hdl.sdk.sourceos.Rk3566Manager;
import com.hdl.sdk.sourceos.utils.DeviceUtils;
import com.hdl.sdk.sourceos.utils.SPKey;
 
/**
 * Created by Tong on 2021/11/8.
 */
public class QRCode {
 
    private static final String SOURCE_SCHEME = "source";
    //绑定source
    private static final String BIND_HOST = "bind";
 
 
 
    /**
     * @return source://bind/包名_序列号_时间戳
     */
    public static String getBindQRCodeInfo() {
        return SPUtils.getString(SPKey.BIND_CODE);
    }
 
    /**
     * @return 包名_序列号_时间戳
     */
    public static String getBindQRCode(String code) {
        if (!TextUtils.isEmpty(code)) {
            Uri uri = Uri.parse(code);
            return uri.getLastPathSegment();
        }
        return null;
    }
 
    /**
     * @return 包名_序列号_时间戳
     */
    public static String getBindQRCode() {
        String info = QRCode.getBindQRCodeInfo();
        return getBindQRCode(info);
    }
 
    /**
     * 序列号android10 会获取不到
     *
     * @return 获取绑定二维码信息, source://bind/包名_序列号_时间戳
     */
    public static String createBindQRCodeInfo(String time) {
        final String packageName = Rk3566Manager.getInstance().getContext().getPackageName();
        final String deviceId = DeviceUtils.getUniqueCode();
        final String builder = packageName +
                "_" +
                deviceId +
                "_" +
                time;
        final Uri uri = new Uri.Builder().scheme(SOURCE_SCHEME).authority(BIND_HOST)
                .appendPath(builder).build();
        return uri.toString();
    }
}