package com.baidu.mapsdkplatform.comapi.util; import android.content.Context; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.os.Bundle; import android.util.Log; import com.baidu.lbsapi.auth.LBSAuthManager; import com.baidu.lbsapi.auth.LBSAuthManagerListener; import com.xingin.xhs.v2.album.entities.AlbumBean; import java.util.Hashtable; import org.json.JSONException; import org.json.JSONObject; public class PermissionCheck { /* renamed from: a reason: collision with root package name */ public static int f20691a = 200; /* renamed from: b reason: collision with root package name */ public static int f20692b = 202; /* renamed from: c reason: collision with root package name */ public static int f20693c = 252; /* renamed from: d reason: collision with root package name */ private static final String f20694d = "PermissionCheck"; /* renamed from: e reason: collision with root package name */ private static Context f20695e = null; /* renamed from: f reason: collision with root package name */ private static String f20696f = null; /* renamed from: g reason: collision with root package name */ private static Hashtable<String, String> f20697g = null; /* renamed from: h reason: collision with root package name */ private static LBSAuthManager f20698h = null; /* renamed from: i reason: collision with root package name */ private static LBSAuthManagerListener f20699i = null; /* renamed from: j reason: collision with root package name */ private static c f20700j = null; /* renamed from: k reason: collision with root package name */ private static int f20701k = 601; public static class a implements LBSAuthManagerListener { private a() { } @Override // com.baidu.lbsapi.auth.LBSAuthManagerListener public void onAuthResult(int i10, String str) { if (str == null) { Log.e(PermissionCheck.f20694d, "The result is null"); int permissionCheck = PermissionCheck.permissionCheck(); String str2 = PermissionCheck.f20694d; Log.d(str2, "onAuthResult try permissionCheck result is: " + permissionCheck); return; } b bVar = new b(); try { JSONObject jSONObject = new JSONObject(str); if (jSONObject.has("status")) { bVar.f20702a = jSONObject.optInt("status"); } if (jSONObject.has("appid")) { bVar.f20704c = jSONObject.optString("appid"); } if (jSONObject.has("uid")) { bVar.f20703b = jSONObject.optString("uid"); } if (jSONObject.has("message")) { bVar.f20705d = jSONObject.optString("message"); } if (jSONObject.has("token")) { bVar.f20706e = jSONObject.optString("token"); } if (jSONObject.has("ak_permission")) { bVar.f20707f = jSONObject.optInt("ak_permission"); } } catch (JSONException e14) { e14.printStackTrace(); } int unused = PermissionCheck.f20701k = bVar.f20702a; if (PermissionCheck.f20700j != null) { PermissionCheck.f20700j.a(bVar); } } } public static class b { /* renamed from: a reason: collision with root package name */ public int f20702a = 0; /* renamed from: b reason: collision with root package name */ public String f20703b = AlbumBean.ID_ALBUM_ALL; /* renamed from: c reason: collision with root package name */ public String f20704c = AlbumBean.ID_ALBUM_ALL; /* renamed from: d reason: collision with root package name */ public String f20705d = ""; /* renamed from: e reason: collision with root package name */ public String f20706e; /* renamed from: f reason: collision with root package name */ public int f20707f; public String toString() { return String.format("=============================================\n----------------- 鉴权错误信息 ------------\nsha1;package:%s\nkey:%s\nerrorcode: %d uid: %s appid %s msg: %s\n请仔细核查 SHA1、package与key申请信息是否对应,key是否删除,平台是否匹配\nerrorcode为230时,请参考论坛链接:\nhttp://bbs.lbsyun.baidu.com/forum.php?mod=viewthread&tid=106461\n=============================================\n", a.a(PermissionCheck.f20695e), PermissionCheck.f20696f, Integer.valueOf(this.f20702a), this.f20703b, this.f20704c, this.f20705d); } } public interface c { void a(b bVar); } public static void destory() { f20700j = null; f20695e = null; f20699i = null; } public static int getPermissionResult() { return f20701k; } public static void init(Context context) { ApplicationInfo applicationInfo; String str; f20695e = context; try { applicationInfo = context.getPackageManager().getApplicationInfo(f20695e.getPackageName(), 128); } catch (PackageManager.NameNotFoundException e14) { e14.printStackTrace(); applicationInfo = null; } if (applicationInfo != null) { f20696f = applicationInfo.metaData.getString("com.baidu.lbsapi.API_KEY"); } if (f20697g == null) { f20697g = new Hashtable<>(); } if (f20698h == null) { f20698h = LBSAuthManager.getInstance(f20695e); } if (f20699i == null) { f20699i = new a(); } try { str = context.getPackageManager().getPackageInfo(f20695e.getPackageName(), 0).applicationInfo.loadLabel(f20695e.getPackageManager()).toString(); } catch (Exception e15) { e15.printStackTrace(); str = ""; } Bundle b14 = i.b(); if (b14 != null) { f20697g.put("mb", b14.getString("mb")); f20697g.put("os", b14.getString("os")); f20697g.put(com.alipay.sdk.sys.a.f18248h, b14.getString(com.alipay.sdk.sys.a.f18248h)); f20697g.put("imt", "1"); f20697g.put(com.alipay.sdk.app.statistic.b.f18036a, b14.getString(com.alipay.sdk.app.statistic.b.f18036a)); f20697g.put("cpu", b14.getString("cpu")); f20697g.put("glr", b14.getString("glr")); f20697g.put("glv", b14.getString("glv")); f20697g.put("resid", b14.getString("resid")); f20697g.put("appid", AlbumBean.ID_ALBUM_ALL); f20697g.put("ver", "1"); f20697g.put("screen", String.format("(%d,%d)", Integer.valueOf(b14.getInt("screen_x")), Integer.valueOf(b14.getInt("screen_y")))); f20697g.put("dpi", String.format("(%d,%d)", Integer.valueOf(b14.getInt("dpi_x")), Integer.valueOf(b14.getInt("dpi_y")))); f20697g.put("pcn", b14.getString("pcn")); f20697g.put("cuid", b14.getString("cuid")); f20697g.put("name", str); } } public static synchronized int permissionCheck() { LBSAuthManagerListener lBSAuthManagerListener; synchronized (PermissionCheck.class) { LBSAuthManager lBSAuthManager = f20698h; if (!(lBSAuthManager == null || (lBSAuthManagerListener = f20699i) == null)) { if (f20695e != null) { int authenticate = lBSAuthManager.authenticate(false, "lbs_androidmapsdk", f20697g, lBSAuthManagerListener); if (authenticate != 0) { String str = f20694d; Log.e(str, "permission check result is: " + authenticate); } return authenticate; } } String str2 = f20694d; Log.e(str2, "The authManager is: " + f20698h + "; the authCallback is: " + f20699i + "; the mContext is: " + f20695e); return 0; } } public static void setPermissionCheckResultListener(c cVar) { f20700j = cVar; } }