package com.huawei.hms.opendevice; import android.content.Context; import android.content.Intent; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.os.Bundle; import android.text.TextUtils; import com.huawei.hms.aaid.HmsInstanceId; import com.huawei.hms.aaid.constant.ErrorEnum; import com.huawei.hms.common.ApiException; import com.huawei.hms.push.constant.RemoteMessageConst; import com.huawei.hms.support.log.HMSLog; import com.huawei.hms.utils.Util; import com.umeng.analytics.pro.d; /* compiled from: AutoInitRunnable */ public class f implements Runnable { public Context a; public f(Context context) { this.a = context; } public void run() { try { int internalCode = ErrorEnum.SUCCESS.getInternalCode(); String str = null; try { str = HmsInstanceId.getInstance(this.a).getToken(Util.getAppId(this.a), null); HMSLog.i("AutoInit", "Push init succeed"); if (TextUtils.isEmpty(str)) { return; } } catch (ApiException e) { internalCode = e.getStatusCode(); HMSLog.e("AutoInit", "Push init failed"); } try { ApplicationInfo applicationInfo = this.a.getPackageManager().getApplicationInfo(this.a.getPackageName(), 128); if (applicationInfo.metaData == null || applicationInfo.metaData.getString("com.huawei.hms.client.service.name:push") == null) { HMSLog.i("AutoInit", "push kit sdk not exists"); return; } Intent intent = new Intent("com.huawei.push.action.MESSAGING_EVENT"); intent.setPackage(this.a.getPackageName()); Bundle bundle = new Bundle(); bundle.putString("message_type", "new_token"); bundle.putString(RemoteMessageConst.DEVICE_TOKEN, str); bundle.putInt(d.O, internalCode); if (!new h().a(this.a, bundle, intent)) { HMSLog.e("AutoInit", "start service failed"); } } catch (PackageManager.NameNotFoundException unused) { HMSLog.i("AutoInit", "push kit sdk not exists"); } } catch (Exception e2) { HMSLog.e("AutoInit", "Push init failed", e2); } } }