package com.tencent.youtu.ytcommon.auth; import android.content.Context; import android.content.res.AssetManager; import android.os.Looper; import com.tencent.youtu.ytcommon.auth.HttpUtil; import com.tencent.youtu.ytcommon.tools.YTLogger; import java.io.IOException; import java.util.Timer; import java.util.TimerTask; public class YTAuthJNIInterface { private static final String DAT_SUFFIX = "SDK.dat"; private static final String LICENCE_SUFFIX = "SDK.licence"; private static final String SDK_NAME = "YoutuFaceTrack"; private static final String SDK_PREFIX = "YT"; private static final String TAG = "log_print_java"; private static String VERSION = "1.2"; private static long handle = 0; private static boolean isReportStarted = false; private static String licenceStr = ""; private static HttpUtil.HttpResponseListener mListener = new HttpUtil.HttpResponseListener() { /* class com.tencent.youtu.ytcommon.auth.YTAuthJNIInterface.AnonymousClass3 */ @Override // com.tencent.youtu.ytcommon.auth.HttpUtil.HttpResponseListener public void onFail(int i15) { try { YTLogger.d(YTAuthJNIInterface.TAG, "http request error : " + i15); YTLogger.d(YTAuthJNIInterface.TAG, "handle: " + YTAuthJNIInterface.handle); YTAuthJNIInterface.nativeUpdateFromServer(YTAuthJNIInterface.handle, null); } catch (Exception unused) { } } @Override // com.tencent.youtu.ytcommon.auth.HttpUtil.HttpResponseListener public void onSuccess(String str) { try { YTLogger.d(YTAuthJNIInterface.TAG, "response: " + str); YTLogger.d(YTAuthJNIInterface.TAG, "handle: " + YTAuthJNIInterface.handle); YTAuthJNIInterface.nativeUpdateFromServer(YTAuthJNIInterface.handle, str); } catch (Exception unused) { } } }; private static Timer timerFlush; private static Timer timerReport; private long nativePtr; public static boolean check() { boolean nativeCheck = nativeCheck(handle); YTLogger.d("sdk", "--------------check"); return nativeCheck; } private static native int getCurrentAuthStatus(long j15); public static long getHandle() { return handle; } private static native int getIsNeedReport(long j15); /* access modifiers changed from: private */ public static native String getReportContent(); public static int init(Context context, String str, int i15, boolean z15) { YTLogger.d(TAG, "start init"); String str2 = context.getFilesDir().getPath() + "/" + SDK_PREFIX + SDK_NAME + DAT_SUFFIX; YTLogger.d(TAG, "path: " + str2); handle = nativeInitN(context, i15, str, context.getAssets(), str2); YTLogger.d(TAG, "handleinit: " + handle); if (getIsNeedReport(handle) == 0) { YTLogger.d(TAG, "no need to report"); } else { YTLogger.d(TAG, "need report"); startTimer(); } return getCurrentAuthStatus(handle); } private static boolean isInMainThread() { return Looper.myLooper() == Looper.getMainLooper(); } private static native boolean nativeCheck(long j15); /* access modifiers changed from: private */ public static native long nativeFlush(); private static native long nativeInitN(Context context, int i15, String str, AssetManager assetManager, String str2); private static native int nativePreInitAndCheck(byte[] bArr, int i15, String str, String str2, String str3); /* access modifiers changed from: private */ public static native long nativeUpdateFromServer(long j15, String str); public static int preCheckAndInitWithLicenceStr(Context context, String str) { licenceStr = str; try { byte[] bytes = str.getBytes(); int length = bytes.length; if (length > 0) { String str2 = context.getFilesDir().getPath() + "/" + SDK_PREFIX + SDK_NAME + DAT_SUFFIX; String packageName = context.getPackageName(); String deviceUid = StatisticsUtils.getDeviceUid(context); YTLogger.d(TAG, "Package name: " + packageName); YTLogger.d(TAG, "Device id: " + deviceUid); return nativePreInitAndCheck(bytes, length, packageName, deviceUid, str2); } throw new IOException("licence error"); } catch (IOException unused) { return -1; } } public static void report(final String str) { if (isInMainThread()) { new Thread(new Runnable() { /* class com.tencent.youtu.ytcommon.auth.YTAuthJNIInterface.AnonymousClass4 */ public void run() { try { HttpUtil.post("https://api.youtu.qq.com/auth/report", str, YTAuthJNIInterface.mListener); } catch (IOException unused) { } } }).start(); return; } try { HttpUtil.post("https://api.youtu.qq.com/auth/report", str, mListener); } catch (IOException unused) { } } private static void startTimer() { YTLogger.d(TAG, "start timer"); if (!isReportStarted) { AnonymousClass1 r25 = new TimerTask() { /* class com.tencent.youtu.ytcommon.auth.YTAuthJNIInterface.AnonymousClass1 */ public void run() { String reportContent = YTAuthJNIInterface.getReportContent(); if (reportContent != "") { YTAuthJNIInterface.report(reportContent); } } }; Timer timer = new Timer(true); timerReport = timer; timer.schedule(r25, 600000, 600000); AnonymousClass2 r85 = new TimerTask() { /* class com.tencent.youtu.ytcommon.auth.YTAuthJNIInterface.AnonymousClass2 */ public void run() { YTLogger.d(YTAuthJNIInterface.TAG, "flush in java "); YTAuthJNIInterface.nativeFlush(); } }; Timer timer2 = new Timer(true); timerFlush = timer2; timer2.schedule(r85, 600000, 600000); isReportStarted = true; } } }