package com.huawei.hms.hwid; import android.content.Context; import android.content.SharedPreferences; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.text.TextUtils; import android.util.Base64; import com.huawei.hms.common.ApiException; import com.huawei.hms.common.ResolvableApiException; import com.huawei.hms.common.internal.ResponseErrorCode; import com.huawei.hms.common.internal.TaskApiCall; import com.huawei.hms.support.account.result.AccountIcon; import com.huawei.hms.support.account.result.GetChannelResult; import com.huawei.hms.support.api.client.Status; import com.huawei.hms.support.api.entity.core.CommonCode; import o.nNj; import org.json.JSONException; /* loaded from: classes2.dex */ public class i extends TaskApiCall { private Context a; @Override // com.huawei.hms.common.internal.TaskApiCall public int getApiLevel() { return 10; } public i(String str, String str2, String str3, Context context) { super(str, str2, str3); this.a = context; } /* JADX INFO: Access modifiers changed from: protected */ @Override // com.huawei.hms.common.internal.TaskApiCall /* renamed from: a, reason: merged with bridge method [inline-methods] */ public void doExecute(c cVar, ResponseErrorCode responseErrorCode, String str, nNj nnj) { if (responseErrorCode == null) { as.b("[AccountSDK]AccountGetChannelTaskApiCall", "response is null.", true); nnj.c(new ApiException(new Status(2003, "response is null."))); return; } int errorCode = responseErrorCode.getErrorCode(); if (errorCode != 0 && CommonCode.Resolution.HAS_RESOLUTION.equals(responseErrorCode.getResolution())) { as.b("[AccountSDK]AccountGetChannelTaskApiCall", "apk version is low or is not exist.", true); Status status = new Status(errorCode, responseErrorCode.getErrorReason()); ao.a(responseErrorCode, status); nnj.c(new ResolvableApiException(status)); return; } StringBuilder sb = new StringBuilder("ResponseErrorCode.status:"); sb.append(responseErrorCode.getErrorCode()); as.b("[AccountSDK]AccountGetChannelTaskApiCall", sb.toString(), true); AccountIcon accountIcon = new AccountIcon(); if (!TextUtils.isEmpty(str)) { if ("{}".equals(str)) { as.b("[AccountSDK]AccountGetChannelTaskApiCall", "getChannel complete, body is null", true); nnj.c(new ApiException(new Status(responseErrorCode.getErrorCode(), responseErrorCode.getErrorReason()))); return; } try { GetChannelResult fromJson = new GetChannelResult().fromJson(str); if (fromJson.isSuccess()) { as.b("[AccountSDK]AccountGetChannelTaskApiCall", "getChannel success", true); accountIcon.setDescription(fromJson.getDescription()); accountIcon.setIcon(a(fromJson.getIcon())); nnj.b(accountIcon); long a = ao.a(); SharedPreferences.Editor edit = this.a.getSharedPreferences("ACCOUNT_CHANNEL_CACHE", 0).edit(); edit.putLong("cache_time", a); edit.putString("desc", fromJson.getDescription()); edit.putString("icon", fromJson.getIcon()); edit.apply(); return; } as.b("[AccountSDK]AccountGetChannelTaskApiCall", "getChannel failed", true); nnj.c(new ApiException(fromJson.getStatus())); return; } catch (JSONException unused) { as.c("[AccountSDK]AccountGetChannelTaskApiCall", "getChannel complete, but parser json exception", true); nnj.c(new ApiException(new Status(errorCode, responseErrorCode.getErrorReason()))); return; } } as.b("[AccountSDK]AccountGetChannelTaskApiCall", "getChannel complete, response is null, failed", true); nnj.c(new ApiException(new Status(errorCode, responseErrorCode.getErrorReason()))); } private Bitmap a(String str) { try { byte[] decode = Base64.decode(str, 0); return BitmapFactory.decodeByteArray(decode, 0, decode.length); } catch (Exception e) { StringBuilder sb = new StringBuilder("stringToBitmap Exception is "); sb.append(e.getClass().getSimpleName()); as.d("[AccountSDK]AccountGetChannelTaskApiCall", sb.toString(), true); return null; } catch (OutOfMemoryError unused) { as.d("[AccountSDK]AccountGetChannelTaskApiCall", "out of memory error ", true); return null; } } }