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


package com.sjm.sjmsdk.core.oaidhelper;

import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.pm.Signature;
import android.os.IBinder;
import android.util.Log;
import com.sjm.sjmsdk.core.oaidhelper.a.d;
import java.security.MessageDigest;
import java.util.concurrent.LinkedBlockingQueue;
import kotlin.UByte;

public class g {
    private final Context a;
    private final LinkedBlockingQueue<IBinder> b = new LinkedBlockingQueue<>(1);
    private final ServiceConnection c = new ServiceConnection() {
        /* class com.sjm.sjmsdk.core.oaidhelper.g.AnonymousClass1 */

        public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
            Log.d("OppoDeviceIDHelper", "onServiceConnected");
            try {
                g.this.b.put(iBinder);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }

        public void onServiceDisconnected(ComponentName componentName) {
        }
    };

    public g(Context context) {
        this.a = context;
    }

    private String b() {
        try {
            Signature[] signatureArr = this.a.getPackageManager().getPackageInfo(this.a.getPackageName(), 64).signatures;
            if (signatureArr == null || signatureArr.length <= 0) {
                return null;
            }
            byte[] digest = MessageDigest.getInstance("SHA1").digest(signatureArr[0].toByteArray());
            StringBuilder sb = new StringBuilder();
            for (byte b2 : digest) {
                sb.append((CharSequence) Integer.toHexString((b2 & UByte.MAX_VALUE) | 256), 1, 3);
            }
            return sb.toString();
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }

    public String a() {
        Context context;
        ServiceConnection serviceConnection;
        String str = "";
        try {
            Intent intent = new Intent();
            intent.setComponent(new ComponentName("com.heytap.openid", "com.heytap.openid.IdentifyService"));
            intent.setAction("action.com.heytap.openid.OPEN_ID_SERVICE");
            boolean bindService = this.a.bindService(intent, this.c, 1);
            Log.d("OppoDeviceIDHelper", "getOAID isBin=" + bindService);
            if (bindService) {
                try {
                    str = new d(this.b.take()).a(this.a.getPackageName(), b(), "OUID");
                    Log.d("OppoDeviceIDHelper", "getOAID oaid" + str);
                    context = this.a;
                    serviceConnection = this.c;
                } catch (Exception e) {
                    e.printStackTrace();
                    context = this.a;
                    serviceConnection = this.c;
                } catch (Throwable th) {
                    this.a.unbindService(this.c);
                    throw th;
                }
                context.unbindService(serviceConnection);
            }
        } catch (Exception e2) {
            Log.d("OppoDeviceIDHelper", "getOAID service not found");
            e2.printStackTrace();
        }
        return str;
    }
}