| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.content.pm; |
| 18 |
|
| 19 |
import android.annotation.SuppressLint; |
| 20 |
import android.app.Activity; |
| 21 |
import android.app.Service; |
| 22 |
import android.compat.annotation.UnsupportedAppUsage; |
| 23 |
import android.content.BroadcastReceiver; |
| 24 |
import android.content.ComponentName; |
| 25 |
import android.content.ContentResolver; |
| 26 |
import android.content.Context; |
| 27 |
import android.graphics.drawable.Drawable; |
| 28 |
import android.os.Build; |
| 29 |
import android.os.Parcel; |
| 30 |
import android.util.Printer; |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
public class ComponentInfo extends PackageItemInfo { |
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
public ApplicationInfo applicationInfo; |
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
public String processName; |
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
public String splitName; |
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
@SuppressLint({"MissingNullability", "MutableBareField"}) |
| 77 |
public String[] attributionTags; |
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
public int descriptionRes; |
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
public boolean enabled = true; |
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
public boolean exported = false; |
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
public boolean directBootAware = false; |
| 106 |
|
| 107 |
public ComponentInfo() { |
| 108 |
} |
| 109 |
|
| 110 |
public ComponentInfo(ComponentInfo orig) { |
| 111 |
super(orig); |
| 112 |
applicationInfo = orig.applicationInfo; |
| 113 |
processName = orig.processName; |
| 114 |
splitName = orig.splitName; |
| 115 |
attributionTags = orig.attributionTags; |
| 116 |
descriptionRes = orig.descriptionRes; |
| 117 |
enabled = orig.enabled; |
| 118 |
exported = orig.exported; |
| 119 |
directBootAware = orig.directBootAware; |
| 120 |
} |
| 121 |
|
| 122 |
|
| 123 |
@Override public CharSequence loadUnsafeLabel(PackageManager pm) { |
| 124 |
if (nonLocalizedLabel != null) { |
| 125 |
return nonLocalizedLabel; |
| 126 |
} |
| 127 |
ApplicationInfo ai = applicationInfo; |
| 128 |
CharSequence label; |
| 129 |
if (labelRes != 0) { |
| 130 |
label = pm.getText(packageName, labelRes, ai); |
| 131 |
if (label != null) { |
| 132 |
return label; |
| 133 |
} |
| 134 |
} |
| 135 |
if (ai.nonLocalizedLabel != null) { |
| 136 |
return ai.nonLocalizedLabel; |
| 137 |
} |
| 138 |
if (ai.labelRes != 0) { |
| 139 |
label = pm.getText(packageName, ai.labelRes, ai); |
| 140 |
if (label != null) { |
| 141 |
return label; |
| 142 |
} |
| 143 |
} |
| 144 |
return name; |
| 145 |
} |
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
public boolean isEnabled() { |
| 151 |
return enabled && applicationInfo.enabled; |
| 152 |
} |
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
public final int getIconResource() { |
| 162 |
return icon != 0 ? icon : applicationInfo.icon; |
| 163 |
} |
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
public final int getLogoResource() { |
| 173 |
return logo != 0 ? logo : applicationInfo.logo; |
| 174 |
} |
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
public final int getBannerResource() { |
| 184 |
return banner != 0 ? banner : applicationInfo.banner; |
| 185 |
} |
| 186 |
|
| 187 |
|
| 188 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) |
| 189 |
public ComponentName getComponentName() { |
| 190 |
return new ComponentName(packageName, name); |
| 191 |
} |
| 192 |
|
| 193 |
protected void dumpFront(Printer pw, String prefix) { |
| 194 |
super.dumpFront(pw, prefix); |
| 195 |
if (processName != null && !packageName.equals(processName)) { |
| 196 |
pw.println(prefix + "processName=" + processName); |
| 197 |
} |
| 198 |
if (splitName != null) { |
| 199 |
pw.println(prefix + "splitName=" + splitName); |
| 200 |
} |
| 201 |
if (attributionTags != null && attributionTags.length > 0) { |
| 202 |
StringBuilder tags = new StringBuilder(); |
| 203 |
tags.append(attributionTags[0]); |
| 204 |
for (int i = 1; i < attributionTags.length; i++) { |
| 205 |
tags.append(", "); |
| 206 |
tags.append(attributionTags[i]); |
| 207 |
} |
| 208 |
pw.println(prefix + "attributionTags=[" + tags + "]"); |
| 209 |
} |
| 210 |
pw.println(prefix + "enabled=" + enabled + " exported=" + exported |
| 211 |
+ " directBootAware=" + directBootAware); |
| 212 |
if (descriptionRes != 0) { |
| 213 |
pw.println(prefix + "description=" + descriptionRes); |
| 214 |
} |
| 215 |
} |
| 216 |
|
| 217 |
protected void dumpBack(Printer pw, String prefix) { |
| 218 |
dumpBack(pw, prefix, DUMP_FLAG_ALL); |
| 219 |
} |
| 220 |
|
| 221 |
void dumpBack(Printer pw, String prefix, int dumpFlags) { |
| 222 |
if ((dumpFlags & DUMP_FLAG_APPLICATION) != 0) { |
| 223 |
if (applicationInfo != null) { |
| 224 |
pw.println(prefix + "ApplicationInfo:"); |
| 225 |
applicationInfo.dump(pw, prefix + " ", dumpFlags); |
| 226 |
} else { |
| 227 |
pw.println(prefix + "ApplicationInfo: null"); |
| 228 |
} |
| 229 |
} |
| 230 |
super.dumpBack(pw, prefix); |
| 231 |
} |
| 232 |
|
| 233 |
public void writeToParcel(Parcel dest, int parcelableFlags) { |
| 234 |
super.writeToParcel(dest, parcelableFlags); |
| 235 |
applicationInfo.writeToParcel(dest, parcelableFlags); |
| 236 |
dest.writeString8(processName); |
| 237 |
dest.writeString8(splitName); |
| 238 |
dest.writeString8Array(attributionTags); |
| 239 |
dest.writeInt(descriptionRes); |
| 240 |
dest.writeInt(enabled ? 1 : 0); |
| 241 |
dest.writeInt(exported ? 1 : 0); |
| 242 |
dest.writeInt(directBootAware ? 1 : 0); |
| 243 |
} |
| 244 |
|
| 245 |
protected ComponentInfo(Parcel source) { |
| 246 |
super(source); |
| 247 |
applicationInfo = ApplicationInfo.CREATOR.createFromParcel(source); |
| 248 |
processName = source.readString8(); |
| 249 |
splitName = source.readString8(); |
| 250 |
attributionTags = source.createString8Array(); |
| 251 |
descriptionRes = source.readInt(); |
| 252 |
enabled = (source.readInt() != 0); |
| 253 |
exported = (source.readInt() != 0); |
| 254 |
directBootAware = (source.readInt() != 0); |
| 255 |
} |
| 256 |
|
| 257 |
|
| 258 |
|
| 259 |
|
| 260 |
@Override |
| 261 |
public Drawable loadDefaultIcon(PackageManager pm) { |
| 262 |
return applicationInfo.loadIcon(pm); |
| 263 |
} |
| 264 |
|
| 265 |
|
| 266 |
|
| 267 |
|
| 268 |
@Override protected Drawable loadDefaultBanner(PackageManager pm) { |
| 269 |
return applicationInfo.loadBanner(pm); |
| 270 |
} |
| 271 |
|
| 272 |
|
| 273 |
|
| 274 |
|
| 275 |
@Override |
| 276 |
protected Drawable loadDefaultLogo(PackageManager pm) { |
| 277 |
return applicationInfo.loadLogo(pm); |
| 278 |
} |
| 279 |
|
| 280 |
|
| 281 |
|
| 282 |
|
| 283 |
@Override protected ApplicationInfo getApplicationInfo() { |
| 284 |
return applicationInfo; |
| 285 |
} |
| 286 |
} |