package com.heytap.mcssdk.f; import android.content.Context; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.text.TextUtils; import com.meizu.cloud.pushsdk.constants.PushConstants; public class g { private static final int a = 26; public static int a(String str) { if (!TextUtils.isEmpty(str)) { try { return Integer.parseInt(str); } catch (NumberFormatException e) { c.e("parseInt--NumberFormatException" + e.getMessage()); } } return -1; } public static String a(Context context) { try { return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName; } catch (Exception unused) { return PushConstants.PUSH_TYPE_NOTIFY; } } public static String a(String str, String str2) { try { Class<?> cls = Class.forName("android.os.SystemProperties"); return (String) cls.getMethod("get", String.class, String.class).invoke(cls, str, str2); } catch (IllegalArgumentException e) { throw e; } catch (Exception unused) { return str2; } } public static String a(int[] iArr) { StringBuilder sb = new StringBuilder(); for (int i : iArr) { sb.append((char) i); } return sb.toString(); } public static boolean a(Context context, String str) { try { context.getPackageManager().getPackageInfo(str, 1); return true; } catch (PackageManager.NameNotFoundException e) { c.e("isExistPackage NameNotFoundException:" + e.getMessage()); return false; } } public static boolean a(Context context, String str, String str2) { ApplicationInfo applicationInfo; try { applicationInfo = context.getPackageManager().getApplicationInfo(str, 128); } catch (PackageManager.NameNotFoundException e) { c.e("isSupportPush NameNotFoundException:" + e.getMessage()); applicationInfo = null; } return applicationInfo != null && applicationInfo.metaData.getBoolean(str2, false); } public static int b(Context context) { try { return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionCode; } catch (Exception unused) { return 0; } } public static int b(Context context, String str) { try { return context.getPackageManager().getPackageInfo(str, 0).versionCode; } catch (Exception e) { c.b("getVersionCode--Exception:" + e.getMessage()); return 0; } } public static String c(Context context) { try { return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).packageName; } catch (Exception e) { c.a(e); return PushConstants.PUSH_TYPE_NOTIFY; } } public static String c(Context context, String str) { try { return context.getPackageManager().getPackageInfo(str, 0).versionName; } catch (Exception e) { c.b("getVersionName--Exception:" + e.getMessage()); return null; } } public static String d(Context context) { try { return context.getResources().getString(context.getPackageManager().getPackageInfo(context.getPackageName(), 0).applicationInfo.labelRes); } catch (Exception e) { c.a(e); return PushConstants.EXTRA_APPLICATION_PENDING_INTENT; } } }