package com.mbridge.msdk.optimize.a.a; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.ServiceConnection; import android.os.IBinder; import com.bun.miitmdid.content.StringValues; import com.mbridge.msdk.optimize.a.b; import com.mbridge.msdk.optimize.a.b.f; import java.util.concurrent.LinkedBlockingQueue; /* compiled from: ZTEDeviceHelper */ public final class i { Context a; String b = "com.mdid.msa"; public final LinkedBlockingQueue<IBinder> c = new LinkedBlockingQueue<>(1); ServiceConnection d = new ServiceConnection() { /* class com.mbridge.msdk.optimize.a.a.i.AnonymousClass1 */ public final void onServiceDisconnected(ComponentName componentName) { } public final void onServiceConnected(ComponentName componentName, IBinder iBinder) { try { i.this.c.put(iBinder); } catch (Exception e) { e.printStackTrace(); } } }; public i(Context context) { this.a = context; } private int a() { try { this.a.getPackageManager().getPackageInfo(this.b, 0); return 1; } catch (Exception e) { e.printStackTrace(); return 0; } } public final void a(b bVar) { try { this.a.getPackageManager().getPackageInfo(this.b, 0); } catch (Exception e) { e.printStackTrace(); } String packageName = this.a.getPackageName(); a(); Intent intent = new Intent(); intent.setClassName(this.b, "com.mdid.msa.service.MsaKlService"); intent.setAction(StringValues.ACTION_START_MSASERVICE); intent.putExtra(StringValues.PARAM_BIND_PKGNAME, packageName); try { intent.putExtra("com.bun.msa.param.runinset", true); this.a.startService(intent); } catch (Exception e2) { e2.printStackTrace(); } Intent intent2 = new Intent(); intent2.setClassName("com.mdid.msa", "com.mdid.msa.service.MsaIdService"); intent2.setAction(StringValues.ACTION_BINDTO_MSASERVICE); intent2.putExtra(StringValues.PARAM_BIND_PKGNAME, packageName); if (this.a.bindService(intent2, this.d, 1)) { try { String a2 = new f.a.C0228a(this.c.take()).a(); if (bVar != null) { bVar.a(a2, false); } } catch (Exception e3) { e3.printStackTrace(); } catch (Throwable th) { this.a.unbindService(this.d); throw th; } this.a.unbindService(this.d); } } }