jimu-decompiled/sources/com/alibaba/android/arouter/utils/PackageUtils.java
2025-05-13 19:24:51 +02:00

44 lines
1.4 KiB
Java

package com.alibaba.android.arouter.utils;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import com.alibaba.android.arouter.launcher.ARouter;
/* loaded from: classes.dex */
public class PackageUtils {
private static String a;
private static int b;
private static PackageInfo a(Context context) {
try {
return context.getPackageManager().getPackageInfo(context.getPackageName(), 16384);
} catch (Exception unused) {
ARouter.c.b("ARouter::", "Get package info error.");
return null;
}
}
public static boolean b(Context context) {
PackageInfo a2 = a(context);
if (a2 != null) {
String str = a2.versionName;
int i = a2.versionCode;
SharedPreferences sharedPreferences = context.getSharedPreferences("SP_AROUTER_CACHE", 0);
if (str.equals(sharedPreferences.getString("LAST_VERSION_NAME", null)) && i == sharedPreferences.getInt("LAST_VERSION_CODE", -1)) {
return false;
}
a = str;
b = i;
}
return true;
}
public static void c(Context context) {
if (android.text.TextUtils.isEmpty(a) || b == 0) {
return;
}
context.getSharedPreferences("SP_AROUTER_CACHE", 0).edit().putString("LAST_VERSION_NAME", a).putInt("LAST_VERSION_CODE", b).apply();
}
}