val appinfo = pm.getApplicationInfo("com.MobileTicket", flags)这段代码的getApplicationInfo()方法,位于android.content.pm.PackageManager下
1 2 3 4 5 6 7 8 9
/** * Return the label to use for this application. * * @return Returns a {@link CharSequence} containing the label associated with * this application, or its name the item does not have a label. * @param info The {@link ApplicationInfo} of the application to get the label of. */ @NonNull publicabstract CharSequence getApplicationLabel(@NonNull ApplicationInfo info);
/** * Retrieve the current textual label associated with this item. This * will call back on the given PackageManager to load the label from * the application. * * @param pm A PackageManager from which the label can be loaded; usually * the PackageManager from which you originally retrieved this item. * * @return Returns a CharSequence containing the item's label. If the * item does not have a label, its name is returned. */ public@NonNull CharSequence loadLabel(@NonNull PackageManager pm) { if (sForceSafeLabels && !Objects.equals(packageName, ActivityThread.currentPackageName())) { return loadSafeLabel(pm, DEFAULT_MAX_LABEL_SIZE_PX, SAFE_STRING_FLAG_TRIM | SAFE_STRING_FLAG_FIRST_LINE); } else { // Trims the label string to the MAX_SAFE_LABEL_LENGTH. This is to prevent that the // system is overwhelmed by an enormous string returned by the application. return TextUtils.trimToSize(loadUnsafeLabel(pm), MAX_SAFE_LABEL_LENGTH); } }
/** * Retrieve the icon associated with an application. If it has not defined * an icon, the default app icon is returned. Does not return null. * * @param info Information about application being queried. * * @return Returns the image of the icon, or the default application icon * if it could not be found. * * @see #getApplicationIcon(String) */ @NonNull publicabstract Drawable getApplicationIcon(@NonNull ApplicationInfo info);
/** * Retrieve the current graphical icon associated with this item. This * will call back on the given PackageManager to load the icon from * the application. * * @param pm A PackageManager from which the icon can be loaded; usually * the PackageManager from which you originally retrieved this item. * * @return Returns a Drawable containing the item's icon. If the * item does not have an icon, the item's default icon is returned * such as the default activity icon. */ public Drawable loadIcon(PackageManager pm) { return pm.loadItemIcon(this, getApplicationInfo()); }
放到一边备用
Xposed hook思路分析
好的,既然我们上面已经拿到了几个要hook的方法,我们来总结一下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
// 获取应用程序名称的方法,位于`android.content.pm.PackageItemInfo`下 public@NonNull CharSequence loadLabel(@NonNull PackageManager pm) { if (sForceSafeLabels && !Objects.equals(packageName, ActivityThread.currentPackageName())) { return loadSafeLabel(pm, DEFAULT_MAX_LABEL_SIZE_PX, SAFE_STRING_FLAG_TRIM | SAFE_STRING_FLAG_FIRST_LINE); } else { // Trims the label string to the MAX_SAFE_LABEL_LENGTH. This is to prevent that the // system is overwhelmed by an enormous string returned by the application. return TextUtils.trimToSize(loadUnsafeLabel(pm), MAX_SAFE_LABEL_LENGTH); } }