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();
|
}
|
}
|