MD5 校验值:27cf44ec6e0720408f5ef017a90a3331
PackageManagerProxy.java 文件包含反编译后的源代码,请注意,该内容仅供学习和参考使用,不得用于非法用途。
package com.jiubang.commerce.fbreplace; import android.annotation.TargetApi; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.pm.ActivityInfo; import android.content.pm.ApplicationInfo; import android.content.pm.FeatureInfo; import android.content.pm.InstrumentationInfo; import android.content.pm.PackageInfo; import android.content.pm.PackageInstaller; import android.content.pm.PackageManager; import android.content.pm.PermissionGroupInfo; import android.content.pm.PermissionInfo; import android.content.pm.ProviderInfo; import android.content.pm.ResolveInfo; import android.content.pm.ServiceInfo; import android.content.res.Resources; import android.content.res.XmlResourceParser; import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.os.UserHandle; import android.text.TextUtils; import android.util.Log; import java.lang.reflect.Method; import java.util.List; public class PackageManagerProxy extends PackageManager { static final String TAG = "AdmobTest"; private final Context mContext; private final PackageManager mPackageManager; private String mPackageName; public PackageManagerProxy(PackageManager packageManager, String str, Context context) { this.mPackageManager = packageManager; this.mPackageName = str; this.mContext = context; } @Override public PackageInfo getPackageInfo(String str, int i) throws PackageManager.NameNotFoundException { if (TextUtils.isEmpty(this.mPackageName) || !str.equals(this.mPackageName)) { return this.mPackageManager.getPackageInfo(str, i); } PackageInfo packageInfo = this.mPackageManager.getPackageInfo(this.mContext.getPackageName(), i); packageInfo.packageName = this.mPackageName; return packageInfo; } @Override public ApplicationInfo getApplicationInfo(String str, int i) throws PackageManager.NameNotFoundException { if (TextUtils.isEmpty(this.mPackageName) || !str.equals(this.mPackageName)) { return this.mPackageManager.getApplicationInfo(str, i); } ApplicationInfo applicationInfo = this.mPackageManager.getApplicationInfo(this.mContext.getPackageName(), i); applicationInfo.packageName = this.mPackageName; return applicationInfo; } public void setPackageName(String str) { this.mPackageName = str; } @Override @TargetApi(8) public String[] currentToCanonicalPackageNames(String[] strArr) { return this.mPackageManager.currentToCanonicalPackageNames(strArr); } @Override @TargetApi(8) public String[] canonicalToCurrentPackageNames(String[] strArr) { return this.mPackageManager.canonicalToCurrentPackageNames(strArr); } @Override public Intent getLaunchIntentForPackage(String str) { return this.mPackageManager.getLaunchIntentForPackage(str); } @Override @TargetApi(21) public Intent getLeanbackLaunchIntentForPackage(String str) { return this.mPackageManager.getLeanbackLaunchIntentForPackage(str); } @Override public int[] getPackageGids(String str) throws PackageManager.NameNotFoundException { return this.mPackageManager.getPackageGids(str); } @Override public int[] getPackageGids(String str, int i) throws PackageManager.NameNotFoundException { return this.mPackageManager.getPackageGids(str, i); } @Override public int getPackageUid(String str, int i) throws PackageManager.NameNotFoundException { return this.mPackageManager.getPackageUid(str, i); } @Override public PermissionInfo getPermissionInfo(String str, int i) throws PackageManager.NameNotFoundException { return this.mPackageManager.getPermissionInfo(str, i); } @Override public List<PermissionInfo> queryPermissionsByGroup(String str, int i) throws PackageManager.NameNotFoundException { return this.mPackageManager.queryPermissionsByGroup(str, i); } @Override public PermissionGroupInfo getPermissionGroupInfo(String str, int i) throws PackageManager.NameNotFoundException { return this.mPackageManager.getPermissionGroupInfo(str, i); } @Override public List<PermissionGroupInfo> getAllPermissionGroups(int i) { return this.mPackageManager.getAllPermissionGroups(i); } @Override public ActivityInfo getActivityInfo(ComponentName componentName, int i) throws PackageManager.NameNotFoundException { if (componentName != null && this.mPackageName.equals(componentName.getPackageName())) { Log.e(TAG, "getActivityInfo"); componentName = new ComponentName(this.mContext.getPackageName(), componentName.getClassName()); } return this.mPackageManager.getActivityInfo(componentName, i); } @Override public ActivityInfo getReceiverInfo(ComponentName componentName, int i) throws PackageManager.NameNotFoundException { return this.mPackageManager.getReceiverInfo(componentName, i); } @Override public ServiceInfo getServiceInfo(ComponentName componentName, int i) throws PackageManager.NameNotFoundException { return this.mPackageManager.getServiceInfo(componentName, i); } @Override @TargetApi(9) public ProviderInfo getProviderInfo(ComponentName componentName, int i) throws PackageManager.NameNotFoundException { return this.mPackageManager.getProviderInfo(componentName, i); } @Override public List<PackageInfo> getInstalledPackages(int i) { return this.mPackageManager.getInstalledPackages(i); } @Override @TargetApi(18) public List<PackageInfo> getPackagesHoldingPermissions(String[] strArr, int i) { return this.mPackageManager.getPackagesHoldingPermissions(strArr, i); } @Override public int checkPermission(String str, String str2) { if (this.mPackageName.equals(str2)) { str2 = this.mContext.getPackageName(); } return this.mPackageManager.checkPermission(str, str2); } @Override public boolean isPermissionRevokedByPolicy(String str, String str2) { return this.mPackageManager.isPermissionRevokedByPolicy(str, str2); } @Override public boolean addPermission(PermissionInfo permissionInfo) { return this.mPackageManager.addPermission(permissionInfo); } @Override @TargetApi(8) public boolean addPermissionAsync(PermissionInfo permissionInfo) { return this.mPackageManager.addPermissionAsync(permissionInfo); } @Override public void removePermission(String str) { this.mPackageManager.removePermission(str); } @Override public int checkSignatures(String str, String str2) { return this.mPackageManager.checkSignatures(str, str2); } @Override public int checkSignatures(int i, int i2) { return this.mPackageManager.checkSignatures(i, i2); } @Override public String[] getPackagesForUid(int i) { return this.mPackageManager.getPackagesForUid(i); } @Override public String getNameForUid(int i) { return this.mPackageManager.getNameForUid(i); } @Override public List<ApplicationInfo> getInstalledApplications(int i) { return this.mPackageManager.getInstalledApplications(i); } @Override public String[] getSystemSharedLibraryNames() { return this.mPackageManager.getSystemSharedLibraryNames(); } @Override public FeatureInfo[] getSystemAvailableFeatures() { return this.mPackageManager.getSystemAvailableFeatures(); } @Override public boolean hasSystemFeature(String str) { return this.mPackageManager.hasSystemFeature(str); } @Override public boolean hasSystemFeature(String str, int i) { return this.mPackageManager.hasSystemFeature(str, i); } @Override public ResolveInfo resolveActivity(Intent intent, int i) { ComponentName component = intent.getComponent(); if (component != null && this.mPackageName.equals(component.getPackageName())) { Log.e(TAG, "resolveActivity"); intent.setComponent(new ComponentName(this.mContext.getPackageName(), component.getClassName())); } return this.mPackageManager.resolveActivity(intent, i); } @Override public List<ResolveInfo> queryIntentActivities(Intent intent, int i) { return this.mPackageManager.queryIntentActivities(intent, i); } @Override public List<ResolveInfo> queryIntentActivityOptions(ComponentName componentName, Intent[] intentArr, Intent intent, int i) { return this.mPackageManager.queryIntentActivityOptions(componentName, intentArr, intent, i); } @Override public List<ResolveInfo> queryBroadcastReceivers(Intent intent, int i) { return this.mPackageManager.queryBroadcastReceivers(intent, i); } @Override public ResolveInfo resolveService(Intent intent, int i) { return this.mPackageManager.resolveService(intent, i); } @Override public List<ResolveInfo> queryIntentServices(Intent intent, int i) { return this.mPackageManager.queryIntentActivities(intent, i); } @Override @TargetApi(19) public List<ResolveInfo> queryIntentContentProviders(Intent intent, int i) { return this.mPackageManager.queryIntentContentProviders(intent, i); } @Override public ProviderInfo resolveContentProvider(String str, int i) { return this.mPackageManager.resolveContentProvider(str, i); } @Override public List<ProviderInfo> queryContentProviders(String str, int i, int i2) { return this.mPackageManager.queryContentProviders(str, i, i2); } @Override public InstrumentationInfo getInstrumentationInfo(ComponentName componentName, int i) throws PackageManager.NameNotFoundException { return this.mPackageManager.getInstrumentationInfo(componentName, i); } @Override public List<InstrumentationInfo> queryInstrumentation(String str, int i) { return this.mPackageManager.queryInstrumentation(str, i); } @Override public Drawable getDrawable(String str, int i, ApplicationInfo applicationInfo) { return this.mPackageManager.getDrawable(str, i, applicationInfo); } @Override public Drawable getActivityIcon(ComponentName componentName) throws PackageManager.NameNotFoundException { return this.mPackageManager.getActivityIcon(componentName); } @Override public Drawable getActivityIcon(Intent intent) throws PackageManager.NameNotFoundException { return this.mPackageManager.getActivityIcon(intent); } @Override @TargetApi(20) public Drawable getActivityBanner(ComponentName componentName) throws PackageManager.NameNotFoundException { return this.mPackageManager.getActivityBanner(componentName); } @Override @TargetApi(20) public Drawable getActivityBanner(Intent intent) throws PackageManager.NameNotFoundException { return this.mPackageManager.getActivityBanner(intent); } @Override public Drawable getDefaultActivityIcon() { return this.mPackageManager.getDefaultActivityIcon(); } @Override public Drawable getApplicationIcon(ApplicationInfo applicationInfo) { return this.mPackageManager.getApplicationIcon(applicationInfo); } @Override public Drawable getApplicationIcon(String str) throws PackageManager.NameNotFoundException { return this.mPackageManager.getApplicationIcon(str); } @Override @TargetApi(20) public Drawable getApplicationBanner(ApplicationInfo applicationInfo) { return this.mPackageManager.getApplicationBanner(applicationInfo); } @Override @TargetApi(20) public Drawable getApplicationBanner(String str) throws PackageManager.NameNotFoundException { return this.mPackageManager.getApplicationBanner(str); } @Override @TargetApi(9) public Drawable getActivityLogo(ComponentName componentName) throws PackageManager.NameNotFoundException { return this.mPackageManager.getActivityLogo(componentName); } @Override @TargetApi(9) public Drawable getActivityLogo(Intent intent) throws PackageManager.NameNotFoundException { return this.mPackageManager.getActivityLogo(intent); } @Override @TargetApi(9) public Drawable getApplicationLogo(ApplicationInfo applicationInfo) { return this.mPackageManager.getApplicationLogo(applicationInfo); } @Override @TargetApi(9) public Drawable getApplicationLogo(String str) throws PackageManager.NameNotFoundException { return this.mPackageManager.getApplicationLogo(str); } @Override @TargetApi(21) public Drawable getUserBadgedIcon(Drawable drawable, UserHandle userHandle) { return this.mPackageManager.getUserBadgedIcon(drawable, userHandle); } @Override @TargetApi(21) public Drawable getUserBadgedDrawableForDensity(Drawable drawable, UserHandle userHandle, Rect rect, int i) { return this.mPackageManager.getUserBadgedDrawableForDensity(drawable, userHandle, rect, i); } @Override @TargetApi(21) public CharSequence getUserBadgedLabel(CharSequence charSequence, UserHandle userHandle) { return this.mPackageManager.getUserBadgedLabel(charSequence, userHandle); } @Override public CharSequence getText(String str, int i, ApplicationInfo applicationInfo) { return this.mPackageManager.getText(str, i, applicationInfo); } @Override public XmlResourceParser getXml(String str, int i, ApplicationInfo applicationInfo) { return this.mPackageManager.getXml(str, i, applicationInfo); } @Override public CharSequence getApplicationLabel(ApplicationInfo applicationInfo) { return this.mPackageManager.getApplicationLabel(applicationInfo); } @Override public Resources getResourcesForActivity(ComponentName componentName) throws PackageManager.NameNotFoundException { return this.mPackageManager.getResourcesForActivity(componentName); } @Override public Resources getResourcesForApplication(ApplicationInfo applicationInfo) throws PackageManager.NameNotFoundException { return this.mPackageManager.getResourcesForApplication(applicationInfo); } @Override public Resources getResourcesForApplication(String str) throws PackageManager.NameNotFoundException { return this.mPackageManager.getResourcesForApplication(str); } @Override @TargetApi(14) public void verifyPendingInstall(int i, int i2) { this.mPackageManager.verifyPendingInstall(i, i2); } @Override @TargetApi(17) public void extendVerificationTimeout(int i, int i2, long j) { this.mPackageManager.extendVerificationTimeout(i, i2, j); } @Override @TargetApi(11) public void setInstallerPackageName(String str, String str2) { this.mPackageManager.setInstallerPackageName(str, str2); } @Override public String getInstallerPackageName(String str) { return "com.android.vending"; } @Override public void addPackageToPreferred(String str) { this.mPackageManager.addPackageToPreferred(str); } @Override public void removePackageFromPreferred(String str) { this.mPackageManager.removePackageFromPreferred(str); } @Override public List<PackageInfo> getPreferredPackages(int i) { return this.mPackageManager.getPreferredPackages(i); } @Override public void addPreferredActivity(IntentFilter intentFilter, int i, ComponentName[] componentNameArr, ComponentName componentName) { this.mPackageManager.addPreferredActivity(intentFilter, i, componentNameArr, componentName); } @Override public void clearPackagePreferredActivities(String str) { this.mPackageManager.clearPackagePreferredActivities(str); } @Override public int getPreferredActivities(List<IntentFilter> list, List<ComponentName> list2, String str) { return this.mPackageManager.getPreferredActivities(list, list2, str); } @Override public void setComponentEnabledSetting(ComponentName componentName, int i, int i2) { this.mPackageManager.setComponentEnabledSetting(componentName, i, i2); } @Override public int getComponentEnabledSetting(ComponentName componentName) { return this.mPackageManager.getComponentEnabledSetting(componentName); } @Override public void setApplicationEnabledSetting(String str, int i, int i2) { this.mPackageManager.setApplicationEnabledSetting(str, i, i2); } @Override public int getApplicationEnabledSetting(String str) { return this.mPackageManager.getApplicationEnabledSetting(str); } @Override public boolean isSafeMode() { return this.mPackageManager.isSafeMode(); } @Override @TargetApi(21) public PackageInstaller getPackageInstaller() { return this.mPackageManager.getPackageInstaller(); } public int getSystemFeatureLevel() { if (this.mPackageManager != null) { Class<?> cls = this.mPackageManager.getClass(); try { Method declaredMethod = cls.getDeclaredMethod("getSystemFeatureLevel", new Class[0]); declaredMethod.setAccessible(true); return ((Integer) declaredMethod.invoke(cls, new Object[0])).intValue(); } catch (Exception e) { e.printStackTrace(); } } return 1; } public int semGetSystemFeatureLevel(String str) { if (this.mPackageManager != null) { Class<?> cls = this.mPackageManager.getClass(); try { Method declaredMethod = cls.getDeclaredMethod("semGetSystemFeatureLevel", String.class); declaredMethod.setAccessible(true); return ((Integer) declaredMethod.invoke(cls, str)).intValue(); } catch (Exception e) { e.printStackTrace(); } } return 1; } }