Skip to content

Commit

Permalink
change method and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
liyujiang-gzu committed Apr 8, 2021
1 parent 96d0ca7 commit ad40f7f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

## 3.0.2 - 2021/04/08

- 小米手机获取OAID问题 @andot PR#18
- 小米手机获取OAID问题 [@andot PR#18](https://github.com/gzu-liyujiang/Android_CN_OAID/pull/18)
- 增加数字版权管理设备ID
- 增加各大手机厂商关于OAID的说明文档
- 允许判断设备是否支持OAID [@andot PR#19](https://github.com/gzu-liyujiang/Android_CN_OAID/pull/19)

## 3.0.1 - 2021/03/29

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
*/
public final class DeviceID {
private static String clientId;
private static IOAID oaid;
private static IOAID ioaid;

private DeviceID() {
super();
Expand Down Expand Up @@ -123,7 +123,7 @@ public static String getClientIdSHA1() {
return clientId == null ? "" : calculateHash(clientId, "SHA-1");
}

private static IOAID getIOAID(@NonNull Context context) {
private static IOAID createIOAID(@NonNull Context context) {
if (OAIDRom.isLenovo() || OAIDRom.isMotolora()) {
return new LenovoImpl(context);
}
Expand Down Expand Up @@ -164,22 +164,22 @@ private static IOAID getIOAID(@NonNull Context context) {
* @param getter 回调
*/
public static void getOAID(@NonNull Context context, @NonNull IGetter getter) {
if (oaid == null) {
oaid = getIOAID(context);
if (ioaid == null) {
ioaid = createIOAID(context);
}
oaid.doGet(getter);
ioaid.doGet(getter);
}

/**
* 判断是否支持OAID
*
* @param context 上下文
*/
public static boolean supported(@NonNull Context context) {
if (oaid == null) {
oaid = getIOAID(context);
public static boolean supportedOAID(@NonNull Context context) {
if (ioaid == null) {
ioaid = createIOAID(context);
}
return oaid.supported();
return ioaid.supported();
}

/**
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ dependencies {
// 获取GUID,随机生成,不会为空
builder.append(DeviceID.getGUID(this));
builder.append("\n");
// 是否支持OAID
builder.append("supportedOAID:").append(DeviceID.supportedOAID(this));
builder.append("\n");
// 获取OAID,异步回调
DeviceID.getOAID(this, new IGetter() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ private void obtainDeviceId() {
// 获取GUID,随机生成,不会为空
builder.append(DeviceID.getGUID(this));
builder.append("\n");
// 是否支持OAID
builder.append("supportedOAID: ").append(DeviceID.supportedOAID(this));
builder.append("\n");
// 获取OAID,异步回调
DeviceID.getOAID(this, new IGetter() {
@Override
Expand Down

0 comments on commit ad40f7f

Please sign in to comment.