Skip to content

Commit

Permalink
Refactor this code to not nest more than 3 if/for/while/switch/try st…
Browse files Browse the repository at this point in the history
…atements.
  • Loading branch information
liyujiang-gzu committed May 21, 2021
1 parent 3cf86f8 commit 475bd09
Showing 1 changed file with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,30 +50,29 @@ public void doGet(@NonNull final IGetter getter) {
return;
}
String oaid = null;
Bundle bundle = null;
try {
Uri uri = Uri.parse("content://cn.nubia.identity/identity");
ContentProviderClient client = context.getContentResolver().acquireContentProviderClient(uri);
if (client != null) {
bundle = client.call("getOAID", null, null);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
client.close();
} else {
client.release();
}
if (client == null) {
return;
}
Bundle bundle = client.call("getOAID", null, null);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
client.close();
} else {
client.release();
}
if (bundle == null) {
throw new OAIDException("OAID query failed: bundle is null");
}
if (bundle.getInt("code", -1) == 0) {
oaid = bundle.getString("id");
}
if (oaid != null && oaid.length() > 0) {
OAIDLog.print("OAID query success: " + oaid);
getter.onOAIDGetComplete(oaid);
} else {
if (oaid == null || oaid.length() == 0) {
throw new OAIDException("OAID query failed: " + bundle.getString("message"));
}
OAIDLog.print("OAID query success: " + oaid);
getter.onOAIDGetComplete(oaid);
} catch (Exception e) {
OAIDLog.print(e);
getter.onOAIDGetError(e);
Expand Down

0 comments on commit 475bd09

Please sign in to comment.