package com.duoyou.api.oaid.impl; import android.content.Context; import android.content.Intent; import android.os.Build; import android.os.IBinder; import com.bun.miitmdid.content.StringValues; import com.duoyou.api.oaid.IGetter; import com.duoyou.api.oaid.IOAID; import com.duoyou.api.oaid.OAIDException; import com.duoyou.api.oaid.OAIDLog; import com.duoyou.api.oaid.impl.OAIDService; import duoyoulib.com.bun.lib.MsaIdInterface; public class MsaImpl implements IOAID { private final Context context; public MsaImpl(Context context2) { this.context = context2; } private void startMsaKlService() { try { Intent intent = new Intent(StringValues.ACTION_START_MSASERVICE); intent.setClassName("com.mdid.msa", "com.mdid.msa.service.MsaKlService"); intent.putExtra(StringValues.PARAM_BIND_PKGNAME, this.context.getPackageName()); if (Build.VERSION.SDK_INT < 26) { this.context.startService(intent); } else { this.context.startForegroundService(intent); } } catch (Exception e) { OAIDLog.print(e); } } @Override // com.duoyou.api.oaid.IOAID public void doGet(IGetter iGetter) { if (this.context != null && iGetter != null) { startMsaKlService(); Intent intent = new Intent(StringValues.ACTION_BINDTO_MSASERVICE); intent.setClassName("com.mdid.msa", "com.mdid.msa.service.MsaIdService"); intent.putExtra(StringValues.PARAM_BIND_PKGNAME, this.context.getPackageName()); OAIDService.bind(this.context, intent, iGetter, new OAIDService.RemoteCaller() { /* class com.duoyou.api.oaid.impl.MsaImpl.AnonymousClass1 */ @Override // com.duoyou.api.oaid.impl.OAIDService.RemoteCaller public String callRemoteInterface(IBinder iBinder) { MsaIdInterface asInterface = MsaIdInterface.Stub.asInterface(iBinder); if (asInterface == null) { throw new OAIDException("MsaIdInterface is null"); } else if (asInterface.isSupported()) { return asInterface.getOAID(); } else { throw new OAIDException("MsaIdInterface#isSupported return false"); } } }); } } @Override // com.duoyou.api.oaid.IOAID public boolean supported() { Context context2 = this.context; if (context2 == null) { return false; } try { return context2.getPackageManager().getPackageInfo("com.mdid.msa", 0) != null; } catch (Exception e) { OAIDLog.print(e); return false; } } }