翰林优商.apk(点击下载) / CoolpadImpl.java


package com.xlx.speech.voicereadsdk.oaid.impl;

import android.app.Application;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.os.IBinder;
import com.xlx.speech.voicereadsdk.oaid.IGetter;
import com.xlx.speech.voicereadsdk.oaid.IOAID;
import com.xlx.speech.voicereadsdk.oaid.OAIDException;
import com.xlx.speech.voicereadsdk.oaid.OAIDLog;
import com.xlx.speech.voicereadsdk.oaid.aidl.coolpad.deviceidsupport.IDeviceIdManager;
import com.xlx.speech.voicereadsdk.oaid.impl.OAIDService;

public class CoolpadImpl implements IOAID {
    private final Context context;

    public CoolpadImpl(Context context2) {
        this.context = !(context2 instanceof Application) ? context2.getApplicationContext() : context2;
    }

    @Override // com.xlx.speech.voicereadsdk.oaid.IOAID
    public void doGet(IGetter iGetter) {
        if (this.context != null && iGetter != null) {
            Intent intent = new Intent();
            intent.setComponent(new ComponentName("com.coolpad.deviceidsupport", "com.coolpad.deviceidsupport.DeviceIdService"));
            OAIDService.bind(this.context, intent, iGetter, new OAIDService.RemoteCaller() {
                /* class com.xlx.speech.voicereadsdk.oaid.impl.CoolpadImpl.AnonymousClass1 */

                @Override // com.xlx.speech.voicereadsdk.oaid.impl.OAIDService.RemoteCaller
                public String callRemoteInterface(IBinder iBinder) {
                    IDeviceIdManager asInterface = IDeviceIdManager.Stub.asInterface(iBinder);
                    if (asInterface != null) {
                        return asInterface.getOAID(CoolpadImpl.this.context.getPackageName());
                    }
                    throw new OAIDException("IDeviceIdManager is null");
                }
            });
        }
    }

    @Override // com.xlx.speech.voicereadsdk.oaid.IOAID
    public boolean supported() {
        Context context2 = this.context;
        if (context2 == null) {
            return false;
        }
        try {
            return context2.getPackageManager().getPackageInfo("com.coolpad.deviceidsupport", 0) != null;
        } catch (Exception e) {
            OAIDLog.print(e);
            return false;
        }
    }
}