Add decompiled APK source code (JADX)

- 28,932 files
- Full Java source code
- Smali files
- Resources

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
2026-02-18 14:52:23 -08:00
parent cc210a65ea
commit f9d20bb3fc
26991 changed files with 2541449 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
package androidx.core.content.pm;
@Deprecated
/* loaded from: classes.dex */
public final class ActivityInfoCompat {
@Deprecated
public static final int CONFIG_UI_MODE = 512;
private ActivityInfoCompat() {
}
}

View File

@@ -0,0 +1,5 @@
package androidx.core.content.pm;
/* loaded from: classes.dex */
public abstract /* synthetic */ class PackageInfoCompat$$ExternalSyntheticApiModelOutline0 {
}

View File

@@ -0,0 +1,156 @@
package androidx.core.content.pm;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.Signature;
import android.content.pm.SigningInfo;
import android.os.Build;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.annotation.Size;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
/* loaded from: classes.dex */
public final class PackageInfoCompat {
public static long getLongVersionCode(@NonNull PackageInfo packageInfo) {
if (Build.VERSION.SDK_INT >= 28) {
return Api28Impl.getLongVersionCode(packageInfo);
}
return packageInfo.versionCode;
}
@NonNull
public static List<Signature> getSignatures(@NonNull PackageManager packageManager, @NonNull String str) throws PackageManager.NameNotFoundException {
Signature[] signatureArr;
SigningInfo signingInfo;
if (Build.VERSION.SDK_INT >= 28) {
signingInfo = packageManager.getPackageInfo(str, 134217728).signingInfo;
if (Api28Impl.hasMultipleSigners(signingInfo)) {
signatureArr = Api28Impl.getApkContentsSigners(signingInfo);
} else {
signatureArr = Api28Impl.getSigningCertificateHistory(signingInfo);
}
} else {
signatureArr = packageManager.getPackageInfo(str, 64).signatures;
}
if (signatureArr == null) {
return Collections.emptyList();
}
return Arrays.asList(signatureArr);
}
public static boolean hasSignatures(@NonNull PackageManager packageManager, @NonNull String str, @NonNull @Size(min = 1) Map<byte[], Integer> map, boolean z) throws PackageManager.NameNotFoundException {
byte[][] bArr;
if (map.isEmpty()) {
return false;
}
Set<byte[]> keySet = map.keySet();
for (byte[] bArr2 : keySet) {
if (bArr2 == null) {
throw new IllegalArgumentException("Cert byte array cannot be null when verifying " + str);
}
Integer num = map.get(bArr2);
if (num == null) {
throw new IllegalArgumentException("Type must be specified for cert when verifying " + str);
}
int intValue = num.intValue();
if (intValue != 0 && intValue != 1) {
throw new IllegalArgumentException("Unsupported certificate type " + num + " when verifying " + str);
}
}
List<Signature> signatures = getSignatures(packageManager, str);
if (!z && Build.VERSION.SDK_INT >= 28) {
for (byte[] bArr3 : keySet) {
if (!Api28Impl.hasSigningCertificate(packageManager, str, bArr3, map.get(bArr3).intValue())) {
return false;
}
}
return true;
}
if (signatures.size() != 0 && map.size() <= signatures.size() && (!z || map.size() == signatures.size())) {
if (map.containsValue(1)) {
bArr = new byte[signatures.size()][];
for (int i = 0; i < signatures.size(); i++) {
bArr[i] = computeSHA256Digest(signatures.get(i).toByteArray());
}
} else {
bArr = null;
}
Iterator<byte[]> it = keySet.iterator();
if (it.hasNext()) {
byte[] next = it.next();
Integer num2 = map.get(next);
int intValue2 = num2.intValue();
if (intValue2 != 0) {
if (intValue2 == 1) {
if (!byteArrayContains(bArr, next)) {
return false;
}
} else {
throw new IllegalArgumentException("Unsupported certificate type " + num2);
}
} else if (!signatures.contains(new Signature(next))) {
return false;
}
return true;
}
}
return false;
}
private static boolean byteArrayContains(@NonNull byte[][] bArr, @NonNull byte[] bArr2) {
for (byte[] bArr3 : bArr) {
if (Arrays.equals(bArr2, bArr3)) {
return true;
}
}
return false;
}
private static byte[] computeSHA256Digest(byte[] bArr) {
try {
return MessageDigest.getInstance("SHA256").digest(bArr);
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException("Device doesn't support SHA256 cert checking", e);
}
}
private PackageInfoCompat() {
}
@RequiresApi(28)
public static class Api28Impl {
private Api28Impl() {
}
public static boolean hasSigningCertificate(@NonNull PackageManager packageManager, @NonNull String str, @NonNull byte[] bArr, int i) {
return packageManager.hasSigningCertificate(str, bArr, i);
}
public static boolean hasMultipleSigners(@NonNull SigningInfo signingInfo) {
return signingInfo.hasMultipleSigners();
}
@Nullable
public static Signature[] getApkContentsSigners(@NonNull SigningInfo signingInfo) {
return signingInfo.getApkContentsSigners();
}
@Nullable
public static Signature[] getSigningCertificateHistory(@NonNull SigningInfo signingInfo) {
return signingInfo.getSigningCertificateHistory();
}
public static long getLongVersionCode(PackageInfo packageInfo) {
return packageInfo.getLongVersionCode();
}
}
}

View File

@@ -0,0 +1,58 @@
package androidx.core.content.pm;
import android.annotation.SuppressLint;
import android.content.pm.PermissionInfo;
import android.os.Build;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.annotation.RestrictTo;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/* loaded from: classes.dex */
public final class PermissionInfoCompat {
@Retention(RetentionPolicy.SOURCE)
@RestrictTo({RestrictTo.Scope.LIBRARY})
public @interface Protection {
}
@SuppressLint({"UniqueConstants"})
@Retention(RetentionPolicy.SOURCE)
@RestrictTo({RestrictTo.Scope.LIBRARY})
public @interface ProtectionFlags {
}
private PermissionInfoCompat() {
}
@SuppressLint({"WrongConstant"})
public static int getProtection(@NonNull PermissionInfo permissionInfo) {
if (Build.VERSION.SDK_INT >= 28) {
return Api28Impl.getProtection(permissionInfo);
}
return permissionInfo.protectionLevel & 15;
}
@SuppressLint({"WrongConstant"})
public static int getProtectionFlags(@NonNull PermissionInfo permissionInfo) {
if (Build.VERSION.SDK_INT >= 28) {
return Api28Impl.getProtectionFlags(permissionInfo);
}
return permissionInfo.protectionLevel & (-16);
}
@RequiresApi(28)
public static class Api28Impl {
private Api28Impl() {
}
public static int getProtection(PermissionInfo permissionInfo) {
return permissionInfo.getProtection();
}
public static int getProtectionFlags(PermissionInfo permissionInfo) {
return permissionInfo.getProtectionFlags();
}
}
}

View File

@@ -0,0 +1,30 @@
package androidx.core.content.pm;
import androidx.annotation.AnyThread;
import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import java.util.List;
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
/* loaded from: classes.dex */
public abstract class ShortcutInfoChangeListener {
@AnyThread
public void onAllShortcutsRemoved() {
}
@AnyThread
public void onShortcutAdded(@NonNull List<ShortcutInfoCompat> list) {
}
@AnyThread
public void onShortcutRemoved(@NonNull List<String> list) {
}
@AnyThread
public void onShortcutUpdated(@NonNull List<ShortcutInfoCompat> list) {
}
@AnyThread
public void onShortcutUsageReported(@NonNull List<String> list) {
}
}

View File

@@ -0,0 +1,5 @@
package androidx.core.content.pm;
/* loaded from: classes.dex */
public abstract /* synthetic */ class ShortcutInfoCompat$$ExternalSyntheticApiModelOutline0 {
}

View File

@@ -0,0 +1,5 @@
package androidx.core.content.pm;
/* loaded from: classes.dex */
public abstract /* synthetic */ class ShortcutInfoCompat$$ExternalSyntheticApiModelOutline1 {
}

View File

@@ -0,0 +1,5 @@
package androidx.core.content.pm;
/* loaded from: classes.dex */
public abstract /* synthetic */ class ShortcutInfoCompat$$ExternalSyntheticApiModelOutline2 {
}

View File

@@ -0,0 +1,5 @@
package androidx.core.content.pm;
/* loaded from: classes.dex */
public abstract /* synthetic */ class ShortcutInfoCompat$$ExternalSyntheticApiModelOutline3 {
}

View File

@@ -0,0 +1,5 @@
package androidx.core.content.pm;
/* loaded from: classes.dex */
public abstract /* synthetic */ class ShortcutInfoCompat$Builder$$ExternalSyntheticApiModelOutline0 {
}

View File

@@ -0,0 +1,5 @@
package androidx.core.content.pm;
/* loaded from: classes.dex */
public abstract /* synthetic */ class ShortcutInfoCompat$Builder$$ExternalSyntheticApiModelOutline1 {
}

View File

@@ -0,0 +1,677 @@
package androidx.core.content.pm;
import android.annotation.SuppressLint;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.LocusId;
import android.content.pm.PackageManager;
import android.content.pm.ShortcutInfo;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.PersistableBundle;
import android.os.UserHandle;
import android.text.TextUtils;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.annotation.RestrictTo;
import androidx.annotation.VisibleForTesting;
import androidx.collection.ArraySet;
import androidx.core.app.Person;
import androidx.core.content.LocusIdCompat;
import androidx.core.graphics.drawable.IconCompat;
import androidx.core.net.UriCompat;
import androidx.core.util.Preconditions;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
/* loaded from: classes.dex */
public class ShortcutInfoCompat {
private static final String EXTRA_LOCUS_ID = "extraLocusId";
private static final String EXTRA_LONG_LIVED = "extraLongLived";
private static final String EXTRA_PERSON_ = "extraPerson_";
private static final String EXTRA_PERSON_COUNT = "extraPersonCount";
private static final String EXTRA_SLICE_URI = "extraSliceUri";
public static final int SURFACE_LAUNCHER = 1;
ComponentName mActivity;
Set<String> mCategories;
Context mContext;
CharSequence mDisabledMessage;
int mDisabledReason;
int mExcludedSurfaces;
PersistableBundle mExtras;
boolean mHasKeyFieldsOnly;
IconCompat mIcon;
String mId;
Intent[] mIntents;
boolean mIsAlwaysBadged;
boolean mIsCached;
boolean mIsDeclaredInManifest;
boolean mIsDynamic;
boolean mIsEnabled = true;
boolean mIsImmutable;
boolean mIsLongLived;
boolean mIsPinned;
CharSequence mLabel;
long mLastChangedTimestamp;
@Nullable
LocusIdCompat mLocusId;
CharSequence mLongLabel;
String mPackageName;
Person[] mPersons;
int mRank;
Bundle mTransientExtras;
UserHandle mUser;
@Retention(RetentionPolicy.SOURCE)
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
public @interface Surface {
}
@Nullable
public ComponentName getActivity() {
return this.mActivity;
}
@Nullable
public Set<String> getCategories() {
return this.mCategories;
}
@Nullable
public CharSequence getDisabledMessage() {
return this.mDisabledMessage;
}
public int getDisabledReason() {
return this.mDisabledReason;
}
public int getExcludedFromSurfaces() {
return this.mExcludedSurfaces;
}
@Nullable
public PersistableBundle getExtras() {
return this.mExtras;
}
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
public IconCompat getIcon() {
return this.mIcon;
}
@NonNull
public String getId() {
return this.mId;
}
public long getLastChangedTimestamp() {
return this.mLastChangedTimestamp;
}
@Nullable
public LocusIdCompat getLocusId() {
return this.mLocusId;
}
@Nullable
public CharSequence getLongLabel() {
return this.mLongLabel;
}
@NonNull
public String getPackage() {
return this.mPackageName;
}
public int getRank() {
return this.mRank;
}
@NonNull
public CharSequence getShortLabel() {
return this.mLabel;
}
@Nullable
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
public Bundle getTransientExtras() {
return this.mTransientExtras;
}
@Nullable
public UserHandle getUserHandle() {
return this.mUser;
}
public boolean hasKeyFieldsOnly() {
return this.mHasKeyFieldsOnly;
}
public boolean isCached() {
return this.mIsCached;
}
public boolean isDeclaredInManifest() {
return this.mIsDeclaredInManifest;
}
public boolean isDynamic() {
return this.mIsDynamic;
}
public boolean isEnabled() {
return this.mIsEnabled;
}
public boolean isExcludedFromSurfaces(int i) {
return (i & this.mExcludedSurfaces) != 0;
}
public boolean isImmutable() {
return this.mIsImmutable;
}
public boolean isPinned() {
return this.mIsPinned;
}
@RequiresApi(25)
public ShortcutInfo toShortcutInfo() {
ShortcutInfo.Builder intents = new ShortcutInfo.Builder(this.mContext, this.mId).setShortLabel(this.mLabel).setIntents(this.mIntents);
IconCompat iconCompat = this.mIcon;
if (iconCompat != null) {
intents.setIcon(iconCompat.toIcon(this.mContext));
}
if (!TextUtils.isEmpty(this.mLongLabel)) {
intents.setLongLabel(this.mLongLabel);
}
if (!TextUtils.isEmpty(this.mDisabledMessage)) {
intents.setDisabledMessage(this.mDisabledMessage);
}
ComponentName componentName = this.mActivity;
if (componentName != null) {
intents.setActivity(componentName);
}
Set<String> set = this.mCategories;
if (set != null) {
intents.setCategories(set);
}
intents.setRank(this.mRank);
PersistableBundle persistableBundle = this.mExtras;
if (persistableBundle != null) {
intents.setExtras(persistableBundle);
}
if (Build.VERSION.SDK_INT >= 29) {
Person[] personArr = this.mPersons;
if (personArr != null && personArr.length > 0) {
int length = personArr.length;
android.app.Person[] personArr2 = new android.app.Person[length];
for (int i = 0; i < length; i++) {
personArr2[i] = this.mPersons[i].toAndroidPerson();
}
intents.setPersons(personArr2);
}
LocusIdCompat locusIdCompat = this.mLocusId;
if (locusIdCompat != null) {
intents.setLocusId(locusIdCompat.toLocusId());
}
intents.setLongLived(this.mIsLongLived);
} else {
intents.setExtras(buildLegacyExtrasBundle());
}
if (Build.VERSION.SDK_INT >= 33) {
Api33Impl.setExcludedFromSurfaces(intents, this.mExcludedSurfaces);
}
return intents.build();
}
@RequiresApi(22)
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
private PersistableBundle buildLegacyExtrasBundle() {
if (this.mExtras == null) {
this.mExtras = new PersistableBundle();
}
Person[] personArr = this.mPersons;
if (personArr != null && personArr.length > 0) {
this.mExtras.putInt(EXTRA_PERSON_COUNT, personArr.length);
int i = 0;
while (i < this.mPersons.length) {
PersistableBundle persistableBundle = this.mExtras;
StringBuilder sb = new StringBuilder();
sb.append(EXTRA_PERSON_);
int i2 = i + 1;
sb.append(i2);
persistableBundle.putPersistableBundle(sb.toString(), this.mPersons[i].toPersistableBundle());
i = i2;
}
}
LocusIdCompat locusIdCompat = this.mLocusId;
if (locusIdCompat != null) {
this.mExtras.putString(EXTRA_LOCUS_ID, locusIdCompat.getId());
}
this.mExtras.putBoolean(EXTRA_LONG_LIVED, this.mIsLongLived);
return this.mExtras;
}
public Intent addToIntent(Intent intent) {
intent.putExtra("android.intent.extra.shortcut.INTENT", this.mIntents[r0.length - 1]).putExtra("android.intent.extra.shortcut.NAME", this.mLabel.toString());
if (this.mIcon != null) {
Drawable drawable = null;
if (this.mIsAlwaysBadged) {
PackageManager packageManager = this.mContext.getPackageManager();
ComponentName componentName = this.mActivity;
if (componentName != null) {
try {
drawable = packageManager.getActivityIcon(componentName);
} catch (PackageManager.NameNotFoundException unused) {
}
}
if (drawable == null) {
drawable = this.mContext.getApplicationInfo().loadIcon(packageManager);
}
}
this.mIcon.addToShortcutIntent(intent, drawable, this.mContext);
}
return intent;
}
@NonNull
public Intent getIntent() {
return this.mIntents[r0.length - 1];
}
@NonNull
public Intent[] getIntents() {
Intent[] intentArr = this.mIntents;
return (Intent[]) Arrays.copyOf(intentArr, intentArr.length);
}
@VisibleForTesting
@Nullable
@RequiresApi(25)
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
public static Person[] getPersonsFromExtra(@NonNull PersistableBundle persistableBundle) {
if (persistableBundle == null || !persistableBundle.containsKey(EXTRA_PERSON_COUNT)) {
return null;
}
int i = persistableBundle.getInt(EXTRA_PERSON_COUNT);
Person[] personArr = new Person[i];
int i2 = 0;
while (i2 < i) {
StringBuilder sb = new StringBuilder();
sb.append(EXTRA_PERSON_);
int i3 = i2 + 1;
sb.append(i3);
personArr[i2] = Person.fromPersistableBundle(persistableBundle.getPersistableBundle(sb.toString()));
i2 = i3;
}
return personArr;
}
@RequiresApi(25)
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
@VisibleForTesting
public static boolean getLongLivedFromExtra(@Nullable PersistableBundle persistableBundle) {
if (persistableBundle == null || !persistableBundle.containsKey(EXTRA_LONG_LIVED)) {
return false;
}
return persistableBundle.getBoolean(EXTRA_LONG_LIVED);
}
@RequiresApi(25)
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
public static List<ShortcutInfoCompat> fromShortcuts(@NonNull Context context, @NonNull List<ShortcutInfo> list) {
ArrayList arrayList = new ArrayList(list.size());
Iterator<ShortcutInfo> it = list.iterator();
while (it.hasNext()) {
arrayList.add(new Builder(context, it.next()).build());
}
return arrayList;
}
@Nullable
@RequiresApi(25)
public static LocusIdCompat getLocusId(@NonNull ShortcutInfo shortcutInfo) {
LocusId locusId;
LocusId locusId2;
if (Build.VERSION.SDK_INT >= 29) {
locusId = shortcutInfo.getLocusId();
if (locusId == null) {
return null;
}
locusId2 = shortcutInfo.getLocusId();
return LocusIdCompat.toLocusIdCompat(locusId2);
}
return getLocusIdFromExtra(shortcutInfo.getExtras());
}
@Nullable
@RequiresApi(25)
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
private static LocusIdCompat getLocusIdFromExtra(@Nullable PersistableBundle persistableBundle) {
String string;
if (persistableBundle == null || (string = persistableBundle.getString(EXTRA_LOCUS_ID)) == null) {
return null;
}
return new LocusIdCompat(string);
}
public static class Builder {
private Map<String, Map<String, List<String>>> mCapabilityBindingParams;
private Set<String> mCapabilityBindings;
private final ShortcutInfoCompat mInfo;
private boolean mIsConversation;
private Uri mSliceUri;
@NonNull
public Builder setIsConversation() {
this.mIsConversation = true;
return this;
}
@NonNull
@SuppressLint({"MissingGetterMatchingBuilder"})
public Builder setSliceUri(@NonNull Uri uri) {
this.mSliceUri = uri;
return this;
}
public Builder(@NonNull Context context, @NonNull String str) {
ShortcutInfoCompat shortcutInfoCompat = new ShortcutInfoCompat();
this.mInfo = shortcutInfoCompat;
shortcutInfoCompat.mContext = context;
shortcutInfoCompat.mId = str;
}
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
public Builder(@NonNull ShortcutInfoCompat shortcutInfoCompat) {
ShortcutInfoCompat shortcutInfoCompat2 = new ShortcutInfoCompat();
this.mInfo = shortcutInfoCompat2;
shortcutInfoCompat2.mContext = shortcutInfoCompat.mContext;
shortcutInfoCompat2.mId = shortcutInfoCompat.mId;
shortcutInfoCompat2.mPackageName = shortcutInfoCompat.mPackageName;
Intent[] intentArr = shortcutInfoCompat.mIntents;
shortcutInfoCompat2.mIntents = (Intent[]) Arrays.copyOf(intentArr, intentArr.length);
shortcutInfoCompat2.mActivity = shortcutInfoCompat.mActivity;
shortcutInfoCompat2.mLabel = shortcutInfoCompat.mLabel;
shortcutInfoCompat2.mLongLabel = shortcutInfoCompat.mLongLabel;
shortcutInfoCompat2.mDisabledMessage = shortcutInfoCompat.mDisabledMessage;
shortcutInfoCompat2.mDisabledReason = shortcutInfoCompat.mDisabledReason;
shortcutInfoCompat2.mIcon = shortcutInfoCompat.mIcon;
shortcutInfoCompat2.mIsAlwaysBadged = shortcutInfoCompat.mIsAlwaysBadged;
shortcutInfoCompat2.mUser = shortcutInfoCompat.mUser;
shortcutInfoCompat2.mLastChangedTimestamp = shortcutInfoCompat.mLastChangedTimestamp;
shortcutInfoCompat2.mIsCached = shortcutInfoCompat.mIsCached;
shortcutInfoCompat2.mIsDynamic = shortcutInfoCompat.mIsDynamic;
shortcutInfoCompat2.mIsPinned = shortcutInfoCompat.mIsPinned;
shortcutInfoCompat2.mIsDeclaredInManifest = shortcutInfoCompat.mIsDeclaredInManifest;
shortcutInfoCompat2.mIsImmutable = shortcutInfoCompat.mIsImmutable;
shortcutInfoCompat2.mIsEnabled = shortcutInfoCompat.mIsEnabled;
shortcutInfoCompat2.mLocusId = shortcutInfoCompat.mLocusId;
shortcutInfoCompat2.mIsLongLived = shortcutInfoCompat.mIsLongLived;
shortcutInfoCompat2.mHasKeyFieldsOnly = shortcutInfoCompat.mHasKeyFieldsOnly;
shortcutInfoCompat2.mRank = shortcutInfoCompat.mRank;
Person[] personArr = shortcutInfoCompat.mPersons;
if (personArr != null) {
shortcutInfoCompat2.mPersons = (Person[]) Arrays.copyOf(personArr, personArr.length);
}
if (shortcutInfoCompat.mCategories != null) {
shortcutInfoCompat2.mCategories = new HashSet(shortcutInfoCompat.mCategories);
}
PersistableBundle persistableBundle = shortcutInfoCompat.mExtras;
if (persistableBundle != null) {
shortcutInfoCompat2.mExtras = persistableBundle;
}
shortcutInfoCompat2.mExcludedSurfaces = shortcutInfoCompat.mExcludedSurfaces;
}
@RequiresApi(25)
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
public Builder(@NonNull Context context, @NonNull ShortcutInfo shortcutInfo) {
boolean isCached;
int disabledReason;
ShortcutInfoCompat shortcutInfoCompat = new ShortcutInfoCompat();
this.mInfo = shortcutInfoCompat;
shortcutInfoCompat.mContext = context;
shortcutInfoCompat.mId = shortcutInfo.getId();
shortcutInfoCompat.mPackageName = shortcutInfo.getPackage();
Intent[] intents = shortcutInfo.getIntents();
shortcutInfoCompat.mIntents = (Intent[]) Arrays.copyOf(intents, intents.length);
shortcutInfoCompat.mActivity = shortcutInfo.getActivity();
shortcutInfoCompat.mLabel = shortcutInfo.getShortLabel();
shortcutInfoCompat.mLongLabel = shortcutInfo.getLongLabel();
shortcutInfoCompat.mDisabledMessage = shortcutInfo.getDisabledMessage();
int i = Build.VERSION.SDK_INT;
if (i >= 28) {
disabledReason = shortcutInfo.getDisabledReason();
shortcutInfoCompat.mDisabledReason = disabledReason;
} else {
shortcutInfoCompat.mDisabledReason = shortcutInfo.isEnabled() ? 0 : 3;
}
shortcutInfoCompat.mCategories = shortcutInfo.getCategories();
shortcutInfoCompat.mPersons = ShortcutInfoCompat.getPersonsFromExtra(shortcutInfo.getExtras());
shortcutInfoCompat.mUser = shortcutInfo.getUserHandle();
shortcutInfoCompat.mLastChangedTimestamp = shortcutInfo.getLastChangedTimestamp();
if (i >= 30) {
isCached = shortcutInfo.isCached();
shortcutInfoCompat.mIsCached = isCached;
}
shortcutInfoCompat.mIsDynamic = shortcutInfo.isDynamic();
shortcutInfoCompat.mIsPinned = shortcutInfo.isPinned();
shortcutInfoCompat.mIsDeclaredInManifest = shortcutInfo.isDeclaredInManifest();
shortcutInfoCompat.mIsImmutable = shortcutInfo.isImmutable();
shortcutInfoCompat.mIsEnabled = shortcutInfo.isEnabled();
shortcutInfoCompat.mHasKeyFieldsOnly = shortcutInfo.hasKeyFieldsOnly();
shortcutInfoCompat.mLocusId = ShortcutInfoCompat.getLocusId(shortcutInfo);
shortcutInfoCompat.mRank = shortcutInfo.getRank();
shortcutInfoCompat.mExtras = shortcutInfo.getExtras();
}
@NonNull
public Builder setShortLabel(@NonNull CharSequence charSequence) {
this.mInfo.mLabel = charSequence;
return this;
}
@NonNull
public Builder setLongLabel(@NonNull CharSequence charSequence) {
this.mInfo.mLongLabel = charSequence;
return this;
}
@NonNull
public Builder setDisabledMessage(@NonNull CharSequence charSequence) {
this.mInfo.mDisabledMessage = charSequence;
return this;
}
@NonNull
public Builder setIntent(@NonNull Intent intent) {
return setIntents(new Intent[]{intent});
}
@NonNull
public Builder setIntents(@NonNull Intent[] intentArr) {
this.mInfo.mIntents = intentArr;
return this;
}
@NonNull
public Builder setIcon(IconCompat iconCompat) {
this.mInfo.mIcon = iconCompat;
return this;
}
@NonNull
public Builder setLocusId(@Nullable LocusIdCompat locusIdCompat) {
this.mInfo.mLocusId = locusIdCompat;
return this;
}
@NonNull
public Builder setActivity(@NonNull ComponentName componentName) {
this.mInfo.mActivity = componentName;
return this;
}
@NonNull
public Builder setAlwaysBadged() {
this.mInfo.mIsAlwaysBadged = true;
return this;
}
@NonNull
public Builder setPerson(@NonNull Person person) {
return setPersons(new Person[]{person});
}
@NonNull
public Builder setPersons(@NonNull Person[] personArr) {
this.mInfo.mPersons = personArr;
return this;
}
@NonNull
public Builder setCategories(@NonNull Set<String> set) {
ArraySet arraySet = new ArraySet();
arraySet.addAll(set);
this.mInfo.mCategories = arraySet;
return this;
}
@NonNull
@Deprecated
public Builder setLongLived() {
this.mInfo.mIsLongLived = true;
return this;
}
@NonNull
public Builder setLongLived(boolean z) {
this.mInfo.mIsLongLived = z;
return this;
}
@NonNull
public Builder setExcludedFromSurfaces(int i) {
this.mInfo.mExcludedSurfaces = i;
return this;
}
@NonNull
public Builder setRank(int i) {
this.mInfo.mRank = i;
return this;
}
@NonNull
public Builder setExtras(@NonNull PersistableBundle persistableBundle) {
this.mInfo.mExtras = persistableBundle;
return this;
}
@NonNull
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
public Builder setTransientExtras(@NonNull Bundle bundle) {
this.mInfo.mTransientExtras = (Bundle) Preconditions.checkNotNull(bundle);
return this;
}
@NonNull
@SuppressLint({"MissingGetterMatchingBuilder"})
public Builder addCapabilityBinding(@NonNull String str) {
if (this.mCapabilityBindings == null) {
this.mCapabilityBindings = new HashSet();
}
this.mCapabilityBindings.add(str);
return this;
}
@NonNull
@SuppressLint({"MissingGetterMatchingBuilder"})
public Builder addCapabilityBinding(@NonNull String str, @NonNull String str2, @NonNull List<String> list) {
addCapabilityBinding(str);
if (!list.isEmpty()) {
if (this.mCapabilityBindingParams == null) {
this.mCapabilityBindingParams = new HashMap();
}
if (this.mCapabilityBindingParams.get(str) == null) {
this.mCapabilityBindingParams.put(str, new HashMap());
}
this.mCapabilityBindingParams.get(str).put(str2, list);
}
return this;
}
@NonNull
public ShortcutInfoCompat build() {
if (TextUtils.isEmpty(this.mInfo.mLabel)) {
throw new IllegalArgumentException("Shortcut must have a non-empty label");
}
ShortcutInfoCompat shortcutInfoCompat = this.mInfo;
Intent[] intentArr = shortcutInfoCompat.mIntents;
if (intentArr == null || intentArr.length == 0) {
throw new IllegalArgumentException("Shortcut must have an intent");
}
if (this.mIsConversation) {
if (shortcutInfoCompat.mLocusId == null) {
shortcutInfoCompat.mLocusId = new LocusIdCompat(shortcutInfoCompat.mId);
}
this.mInfo.mIsLongLived = true;
}
if (this.mCapabilityBindings != null) {
ShortcutInfoCompat shortcutInfoCompat2 = this.mInfo;
if (shortcutInfoCompat2.mCategories == null) {
shortcutInfoCompat2.mCategories = new HashSet();
}
this.mInfo.mCategories.addAll(this.mCapabilityBindings);
}
if (this.mCapabilityBindingParams != null) {
ShortcutInfoCompat shortcutInfoCompat3 = this.mInfo;
if (shortcutInfoCompat3.mExtras == null) {
shortcutInfoCompat3.mExtras = new PersistableBundle();
}
for (String str : this.mCapabilityBindingParams.keySet()) {
Map<String, List<String>> map = this.mCapabilityBindingParams.get(str);
this.mInfo.mExtras.putStringArray(str, (String[]) map.keySet().toArray(new String[0]));
for (String str2 : map.keySet()) {
List<String> list = map.get(str2);
this.mInfo.mExtras.putStringArray(str + "/" + str2, list == null ? new String[0] : (String[]) list.toArray(new String[0]));
}
}
}
if (this.mSliceUri != null) {
ShortcutInfoCompat shortcutInfoCompat4 = this.mInfo;
if (shortcutInfoCompat4.mExtras == null) {
shortcutInfoCompat4.mExtras = new PersistableBundle();
}
this.mInfo.mExtras.putString(ShortcutInfoCompat.EXTRA_SLICE_URI, UriCompat.toSafeString(this.mSliceUri));
}
return this.mInfo;
}
}
@RequiresApi(33)
public static class Api33Impl {
private Api33Impl() {
}
public static void setExcludedFromSurfaces(@NonNull ShortcutInfo.Builder builder, int i) {
builder.setExcludedFromSurfaces(i);
}
}
}

View File

@@ -0,0 +1,55 @@
package androidx.core.content.pm;
import androidx.annotation.AnyThread;
import androidx.annotation.RestrictTo;
import androidx.annotation.WorkerThread;
import java.util.ArrayList;
import java.util.List;
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
/* loaded from: classes.dex */
public abstract class ShortcutInfoCompatSaver<T> {
@AnyThread
public abstract T addShortcuts(List<ShortcutInfoCompat> list);
@AnyThread
public abstract T removeAllShortcuts();
@AnyThread
public abstract T removeShortcuts(List<String> list);
@WorkerThread
public List<ShortcutInfoCompat> getShortcuts() throws Exception {
return new ArrayList();
}
@RestrictTo({RestrictTo.Scope.LIBRARY})
public static class NoopImpl extends ShortcutInfoCompatSaver<Void> {
@Override // androidx.core.content.pm.ShortcutInfoCompatSaver
/* renamed from: addShortcuts, reason: avoid collision after fix types in other method */
public Void addShortcuts2(List<ShortcutInfoCompat> list) {
return null;
}
@Override // androidx.core.content.pm.ShortcutInfoCompatSaver
public Void removeAllShortcuts() {
return null;
}
@Override // androidx.core.content.pm.ShortcutInfoCompatSaver
/* renamed from: removeShortcuts, reason: avoid collision after fix types in other method */
public Void removeShortcuts2(List<String> list) {
return null;
}
@Override // androidx.core.content.pm.ShortcutInfoCompatSaver
public /* bridge */ /* synthetic */ Void addShortcuts(List list) {
return addShortcuts2((List<ShortcutInfoCompat>) list);
}
@Override // androidx.core.content.pm.ShortcutInfoCompatSaver
public /* bridge */ /* synthetic */ Void removeShortcuts(List list) {
return removeShortcuts2((List<String>) list);
}
}
}

View File

@@ -0,0 +1,5 @@
package androidx.core.content.pm;
/* loaded from: classes.dex */
public abstract /* synthetic */ class ShortcutManagerCompat$$ExternalSyntheticApiModelOutline0 {
}

View File

@@ -0,0 +1,5 @@
package androidx.core.content.pm;
/* loaded from: classes.dex */
public abstract /* synthetic */ class ShortcutManagerCompat$$ExternalSyntheticApiModelOutline1 {
}

View File

@@ -0,0 +1,5 @@
package androidx.core.content.pm;
/* loaded from: classes.dex */
public abstract /* synthetic */ class ShortcutManagerCompat$$ExternalSyntheticApiModelOutline2 {
}

View File

@@ -0,0 +1,481 @@
package androidx.core.content.pm;
import android.app.ActivityManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentSender;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.pm.ShortcutInfo;
import android.content.pm.ShortcutManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Build;
import android.os.Bundle;
import android.util.DisplayMetrics;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.annotation.RestrictTo;
import androidx.annotation.VisibleForTesting;
import androidx.core.content.pm.ShortcutInfoCompat;
import androidx.core.content.pm.ShortcutInfoCompatSaver;
import androidx.core.graphics.drawable.IconCompat;
import androidx.core.util.Preconditions;
import java.io.InputStream;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
/* loaded from: classes.dex */
public class ShortcutManagerCompat {
@VisibleForTesting
static final String ACTION_INSTALL_SHORTCUT = "com.android.launcher.action.INSTALL_SHORTCUT";
private static final int DEFAULT_MAX_ICON_DIMENSION_DP = 96;
private static final int DEFAULT_MAX_ICON_DIMENSION_LOWRAM_DP = 48;
public static final String EXTRA_SHORTCUT_ID = "android.intent.extra.shortcut.ID";
public static final int FLAG_MATCH_CACHED = 8;
public static final int FLAG_MATCH_DYNAMIC = 2;
public static final int FLAG_MATCH_MANIFEST = 1;
public static final int FLAG_MATCH_PINNED = 4;
@VisibleForTesting
static final String INSTALL_SHORTCUT_PERMISSION = "com.android.launcher.permission.INSTALL_SHORTCUT";
private static final String SHORTCUT_LISTENER_INTENT_FILTER_ACTION = "androidx.core.content.pm.SHORTCUT_LISTENER";
private static final String SHORTCUT_LISTENER_META_DATA_KEY = "androidx.core.content.pm.shortcut_listener_impl";
private static volatile List<ShortcutInfoChangeListener> sShortcutInfoChangeListeners;
private static volatile ShortcutInfoCompatSaver<?> sShortcutInfoCompatSaver;
@Retention(RetentionPolicy.SOURCE)
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
public @interface ShortcutMatchFlags {
}
@VisibleForTesting
public static List<ShortcutInfoChangeListener> getShortcutInfoChangeListeners() {
return sShortcutInfoChangeListeners;
}
@VisibleForTesting
public static void setShortcutInfoChangeListeners(List<ShortcutInfoChangeListener> list) {
sShortcutInfoChangeListeners = list;
}
@VisibleForTesting
public static void setShortcutInfoCompatSaver(ShortcutInfoCompatSaver<Void> shortcutInfoCompatSaver) {
sShortcutInfoCompatSaver = shortcutInfoCompatSaver;
}
private ShortcutManagerCompat() {
}
public static boolean isRequestPinShortcutSupported(@NonNull Context context) {
return ((ShortcutManager) context.getSystemService(ShortcutManager.class)).isRequestPinShortcutSupported();
}
public static boolean requestPinShortcut(@NonNull Context context, @NonNull ShortcutInfoCompat shortcutInfoCompat, @Nullable IntentSender intentSender) {
if (Build.VERSION.SDK_INT > 32 || !shortcutInfoCompat.isExcludedFromSurfaces(1)) {
return ((ShortcutManager) context.getSystemService(ShortcutManager.class)).requestPinShortcut(shortcutInfoCompat.toShortcutInfo(), intentSender);
}
return false;
}
/* renamed from: androidx.core.content.pm.ShortcutManagerCompat$1, reason: invalid class name */
public class AnonymousClass1 extends BroadcastReceiver {
final /* synthetic */ IntentSender val$callback;
public AnonymousClass1(IntentSender intentSender) {
this.val$callback = intentSender;
}
@Override // android.content.BroadcastReceiver
public void onReceive(Context context, Intent intent) {
try {
this.val$callback.sendIntent(context, 0, null, null, null);
} catch (IntentSender.SendIntentException unused) {
}
}
}
@NonNull
public static Intent createShortcutResultIntent(@NonNull Context context, @NonNull ShortcutInfoCompat shortcutInfoCompat) {
Intent createShortcutResultIntent = ((ShortcutManager) context.getSystemService(ShortcutManager.class)).createShortcutResultIntent(shortcutInfoCompat.toShortcutInfo());
if (createShortcutResultIntent == null) {
createShortcutResultIntent = new Intent();
}
return shortcutInfoCompat.addToIntent(createShortcutResultIntent);
}
@NonNull
public static List<ShortcutInfoCompat> getShortcuts(@NonNull Context context, int i) {
List shortcuts;
if (Build.VERSION.SDK_INT >= 30) {
shortcuts = ((ShortcutManager) context.getSystemService(ShortcutManager.class)).getShortcuts(i);
return ShortcutInfoCompat.fromShortcuts(context, shortcuts);
}
ShortcutManager shortcutManager = (ShortcutManager) context.getSystemService(ShortcutManager.class);
ArrayList arrayList = new ArrayList();
if ((i & 1) != 0) {
arrayList.addAll(shortcutManager.getManifestShortcuts());
}
if ((i & 2) != 0) {
arrayList.addAll(shortcutManager.getDynamicShortcuts());
}
if ((i & 4) != 0) {
arrayList.addAll(shortcutManager.getPinnedShortcuts());
}
return ShortcutInfoCompat.fromShortcuts(context, arrayList);
}
public static boolean addDynamicShortcuts(@NonNull Context context, @NonNull List<ShortcutInfoCompat> list) {
List<ShortcutInfoCompat> removeShortcutsExcludedFromSurface = removeShortcutsExcludedFromSurface(list, 1);
if (Build.VERSION.SDK_INT <= 29) {
convertUriIconsToBitmapIcons(context, removeShortcutsExcludedFromSurface);
}
ArrayList arrayList = new ArrayList();
Iterator<ShortcutInfoCompat> it = removeShortcutsExcludedFromSurface.iterator();
while (it.hasNext()) {
arrayList.add(it.next().toShortcutInfo());
}
if (!((ShortcutManager) context.getSystemService(ShortcutManager.class)).addDynamicShortcuts(arrayList)) {
return false;
}
getShortcutInfoSaverInstance(context).addShortcuts(removeShortcutsExcludedFromSurface);
Iterator<ShortcutInfoChangeListener> it2 = getShortcutInfoListeners(context).iterator();
while (it2.hasNext()) {
it2.next().onShortcutAdded(list);
}
return true;
}
public static int getMaxShortcutCountPerActivity(@NonNull Context context) {
Preconditions.checkNotNull(context);
return ((ShortcutManager) context.getSystemService(ShortcutManager.class)).getMaxShortcutCountPerActivity();
}
public static boolean isRateLimitingActive(@NonNull Context context) {
Preconditions.checkNotNull(context);
return ((ShortcutManager) context.getSystemService(ShortcutManager.class)).isRateLimitingActive();
}
public static int getIconMaxWidth(@NonNull Context context) {
Preconditions.checkNotNull(context);
return ((ShortcutManager) context.getSystemService(ShortcutManager.class)).getIconMaxWidth();
}
public static int getIconMaxHeight(@NonNull Context context) {
Preconditions.checkNotNull(context);
return ((ShortcutManager) context.getSystemService(ShortcutManager.class)).getIconMaxHeight();
}
public static void reportShortcutUsed(@NonNull Context context, @NonNull String str) {
Preconditions.checkNotNull(context);
Preconditions.checkNotNull(str);
((ShortcutManager) context.getSystemService(ShortcutManager.class)).reportShortcutUsed(str);
Iterator<ShortcutInfoChangeListener> it = getShortcutInfoListeners(context).iterator();
while (it.hasNext()) {
it.next().onShortcutUsageReported(Collections.singletonList(str));
}
}
public static boolean setDynamicShortcuts(@NonNull Context context, @NonNull List<ShortcutInfoCompat> list) {
Preconditions.checkNotNull(context);
Preconditions.checkNotNull(list);
List<ShortcutInfoCompat> removeShortcutsExcludedFromSurface = removeShortcutsExcludedFromSurface(list, 1);
ArrayList arrayList = new ArrayList(removeShortcutsExcludedFromSurface.size());
Iterator<ShortcutInfoCompat> it = removeShortcutsExcludedFromSurface.iterator();
while (it.hasNext()) {
arrayList.add(it.next().toShortcutInfo());
}
if (!((ShortcutManager) context.getSystemService(ShortcutManager.class)).setDynamicShortcuts(arrayList)) {
return false;
}
getShortcutInfoSaverInstance(context).removeAllShortcuts();
getShortcutInfoSaverInstance(context).addShortcuts(removeShortcutsExcludedFromSurface);
for (ShortcutInfoChangeListener shortcutInfoChangeListener : getShortcutInfoListeners(context)) {
shortcutInfoChangeListener.onAllShortcutsRemoved();
shortcutInfoChangeListener.onShortcutAdded(list);
}
return true;
}
@NonNull
public static List<ShortcutInfoCompat> getDynamicShortcuts(@NonNull Context context) {
List<ShortcutInfo> dynamicShortcuts = ((ShortcutManager) context.getSystemService(ShortcutManager.class)).getDynamicShortcuts();
ArrayList arrayList = new ArrayList(dynamicShortcuts.size());
Iterator<ShortcutInfo> it = dynamicShortcuts.iterator();
while (it.hasNext()) {
arrayList.add(new ShortcutInfoCompat.Builder(context, it.next()).build());
}
return arrayList;
}
public static boolean updateShortcuts(@NonNull Context context, @NonNull List<ShortcutInfoCompat> list) {
List<ShortcutInfoCompat> removeShortcutsExcludedFromSurface = removeShortcutsExcludedFromSurface(list, 1);
if (Build.VERSION.SDK_INT <= 29) {
convertUriIconsToBitmapIcons(context, removeShortcutsExcludedFromSurface);
}
ArrayList arrayList = new ArrayList();
Iterator<ShortcutInfoCompat> it = removeShortcutsExcludedFromSurface.iterator();
while (it.hasNext()) {
arrayList.add(it.next().toShortcutInfo());
}
if (!((ShortcutManager) context.getSystemService(ShortcutManager.class)).updateShortcuts(arrayList)) {
return false;
}
getShortcutInfoSaverInstance(context).addShortcuts(removeShortcutsExcludedFromSurface);
Iterator<ShortcutInfoChangeListener> it2 = getShortcutInfoListeners(context).iterator();
while (it2.hasNext()) {
it2.next().onShortcutUpdated(list);
}
return true;
}
@VisibleForTesting
public static boolean convertUriIconToBitmapIcon(@NonNull Context context, @NonNull ShortcutInfoCompat shortcutInfoCompat) {
Bitmap decodeStream;
IconCompat createWithBitmap;
IconCompat iconCompat = shortcutInfoCompat.mIcon;
if (iconCompat == null) {
return false;
}
int i = iconCompat.mType;
if (i != 6 && i != 4) {
return true;
}
InputStream uriInputStream = iconCompat.getUriInputStream(context);
if (uriInputStream == null || (decodeStream = BitmapFactory.decodeStream(uriInputStream)) == null) {
return false;
}
if (i == 6) {
createWithBitmap = IconCompat.createWithAdaptiveBitmap(decodeStream);
} else {
createWithBitmap = IconCompat.createWithBitmap(decodeStream);
}
shortcutInfoCompat.mIcon = createWithBitmap;
return true;
}
@VisibleForTesting
public static void convertUriIconsToBitmapIcons(@NonNull Context context, @NonNull List<ShortcutInfoCompat> list) {
for (ShortcutInfoCompat shortcutInfoCompat : new ArrayList(list)) {
if (!convertUriIconToBitmapIcon(context, shortcutInfoCompat)) {
list.remove(shortcutInfoCompat);
}
}
}
public static void disableShortcuts(@NonNull Context context, @NonNull List<String> list, @Nullable CharSequence charSequence) {
((ShortcutManager) context.getSystemService(ShortcutManager.class)).disableShortcuts(list, charSequence);
getShortcutInfoSaverInstance(context).removeShortcuts(list);
Iterator<ShortcutInfoChangeListener> it = getShortcutInfoListeners(context).iterator();
while (it.hasNext()) {
it.next().onShortcutRemoved(list);
}
}
public static void enableShortcuts(@NonNull Context context, @NonNull List<ShortcutInfoCompat> list) {
List<ShortcutInfoCompat> removeShortcutsExcludedFromSurface = removeShortcutsExcludedFromSurface(list, 1);
ArrayList arrayList = new ArrayList(list.size());
Iterator<ShortcutInfoCompat> it = removeShortcutsExcludedFromSurface.iterator();
while (it.hasNext()) {
arrayList.add(it.next().mId);
}
((ShortcutManager) context.getSystemService(ShortcutManager.class)).enableShortcuts(arrayList);
getShortcutInfoSaverInstance(context).addShortcuts(removeShortcutsExcludedFromSurface);
Iterator<ShortcutInfoChangeListener> it2 = getShortcutInfoListeners(context).iterator();
while (it2.hasNext()) {
it2.next().onShortcutAdded(list);
}
}
public static void removeDynamicShortcuts(@NonNull Context context, @NonNull List<String> list) {
((ShortcutManager) context.getSystemService(ShortcutManager.class)).removeDynamicShortcuts(list);
getShortcutInfoSaverInstance(context).removeShortcuts(list);
Iterator<ShortcutInfoChangeListener> it = getShortcutInfoListeners(context).iterator();
while (it.hasNext()) {
it.next().onShortcutRemoved(list);
}
}
public static void removeAllDynamicShortcuts(@NonNull Context context) {
((ShortcutManager) context.getSystemService(ShortcutManager.class)).removeAllDynamicShortcuts();
getShortcutInfoSaverInstance(context).removeAllShortcuts();
Iterator<ShortcutInfoChangeListener> it = getShortcutInfoListeners(context).iterator();
while (it.hasNext()) {
it.next().onAllShortcutsRemoved();
}
}
public static void removeLongLivedShortcuts(@NonNull Context context, @NonNull List<String> list) {
if (Build.VERSION.SDK_INT < 30) {
removeDynamicShortcuts(context, list);
return;
}
((ShortcutManager) context.getSystemService(ShortcutManager.class)).removeLongLivedShortcuts(list);
getShortcutInfoSaverInstance(context).removeShortcuts(list);
Iterator<ShortcutInfoChangeListener> it = getShortcutInfoListeners(context).iterator();
while (it.hasNext()) {
it.next().onShortcutRemoved(list);
}
}
public static boolean pushDynamicShortcut(@NonNull Context context, @NonNull ShortcutInfoCompat shortcutInfoCompat) {
Preconditions.checkNotNull(context);
Preconditions.checkNotNull(shortcutInfoCompat);
int i = Build.VERSION.SDK_INT;
if (i <= 32 && shortcutInfoCompat.isExcludedFromSurfaces(1)) {
Iterator<ShortcutInfoChangeListener> it = getShortcutInfoListeners(context).iterator();
while (it.hasNext()) {
it.next().onShortcutAdded(Collections.singletonList(shortcutInfoCompat));
}
return true;
}
int maxShortcutCountPerActivity = getMaxShortcutCountPerActivity(context);
if (maxShortcutCountPerActivity == 0) {
return false;
}
if (i <= 29) {
convertUriIconToBitmapIcon(context, shortcutInfoCompat);
}
if (i >= 30) {
((ShortcutManager) context.getSystemService(ShortcutManager.class)).pushDynamicShortcut(shortcutInfoCompat.toShortcutInfo());
} else {
ShortcutManager shortcutManager = (ShortcutManager) context.getSystemService(ShortcutManager.class);
if (shortcutManager.isRateLimitingActive()) {
return false;
}
List<ShortcutInfo> dynamicShortcuts = shortcutManager.getDynamicShortcuts();
if (dynamicShortcuts.size() >= maxShortcutCountPerActivity) {
shortcutManager.removeDynamicShortcuts(Arrays.asList(Api25Impl.getShortcutInfoWithLowestRank(dynamicShortcuts)));
}
shortcutManager.addDynamicShortcuts(Arrays.asList(shortcutInfoCompat.toShortcutInfo()));
}
ShortcutInfoCompatSaver<?> shortcutInfoSaverInstance = getShortcutInfoSaverInstance(context);
try {
List<ShortcutInfoCompat> shortcuts = shortcutInfoSaverInstance.getShortcuts();
if (shortcuts.size() >= maxShortcutCountPerActivity) {
shortcutInfoSaverInstance.removeShortcuts(Arrays.asList(getShortcutInfoCompatWithLowestRank(shortcuts)));
}
shortcutInfoSaverInstance.addShortcuts(Arrays.asList(shortcutInfoCompat));
Iterator<ShortcutInfoChangeListener> it2 = getShortcutInfoListeners(context).iterator();
while (it2.hasNext()) {
it2.next().onShortcutAdded(Collections.singletonList(shortcutInfoCompat));
}
reportShortcutUsed(context, shortcutInfoCompat.getId());
return true;
} catch (Exception unused) {
Iterator<ShortcutInfoChangeListener> it3 = getShortcutInfoListeners(context).iterator();
while (it3.hasNext()) {
it3.next().onShortcutAdded(Collections.singletonList(shortcutInfoCompat));
}
reportShortcutUsed(context, shortcutInfoCompat.getId());
return false;
} catch (Throwable th) {
Iterator<ShortcutInfoChangeListener> it4 = getShortcutInfoListeners(context).iterator();
while (it4.hasNext()) {
it4.next().onShortcutAdded(Collections.singletonList(shortcutInfoCompat));
}
reportShortcutUsed(context, shortcutInfoCompat.getId());
throw th;
}
}
private static String getShortcutInfoCompatWithLowestRank(@NonNull List<ShortcutInfoCompat> list) {
int i = -1;
String str = null;
for (ShortcutInfoCompat shortcutInfoCompat : list) {
if (shortcutInfoCompat.getRank() > i) {
str = shortcutInfoCompat.getId();
i = shortcutInfoCompat.getRank();
}
}
return str;
}
private static int getIconDimensionInternal(@NonNull Context context, boolean z) {
ActivityManager activityManager = (ActivityManager) context.getSystemService("activity");
int max = Math.max(1, activityManager == null || activityManager.isLowRamDevice() ? 48 : DEFAULT_MAX_ICON_DIMENSION_DP);
DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
return (int) (max * ((z ? displayMetrics.xdpi : displayMetrics.ydpi) / 160.0f));
}
private static ShortcutInfoCompatSaver<?> getShortcutInfoSaverInstance(Context context) {
if (sShortcutInfoCompatSaver == null) {
try {
sShortcutInfoCompatSaver = (ShortcutInfoCompatSaver) Class.forName("androidx.sharetarget.ShortcutInfoCompatSaverImpl", false, ShortcutManagerCompat.class.getClassLoader()).getMethod("getInstance", Context.class).invoke(null, context);
} catch (Exception unused) {
}
if (sShortcutInfoCompatSaver == null) {
sShortcutInfoCompatSaver = new ShortcutInfoCompatSaver.NoopImpl();
}
}
return sShortcutInfoCompatSaver;
}
private static List<ShortcutInfoChangeListener> getShortcutInfoListeners(Context context) {
Bundle bundle;
String string;
if (sShortcutInfoChangeListeners == null) {
ArrayList arrayList = new ArrayList();
PackageManager packageManager = context.getPackageManager();
Intent intent = new Intent(SHORTCUT_LISTENER_INTENT_FILTER_ACTION);
intent.setPackage(context.getPackageName());
Iterator<ResolveInfo> it = packageManager.queryIntentActivities(intent, 128).iterator();
while (it.hasNext()) {
ActivityInfo activityInfo = it.next().activityInfo;
if (activityInfo != null && (bundle = activityInfo.metaData) != null && (string = bundle.getString(SHORTCUT_LISTENER_META_DATA_KEY)) != null) {
try {
arrayList.add((ShortcutInfoChangeListener) Class.forName(string, false, ShortcutManagerCompat.class.getClassLoader()).getMethod("getInstance", Context.class).invoke(null, context));
} catch (Exception unused) {
}
}
}
if (sShortcutInfoChangeListeners == null) {
sShortcutInfoChangeListeners = arrayList;
}
}
return sShortcutInfoChangeListeners;
}
@NonNull
private static List<ShortcutInfoCompat> removeShortcutsExcludedFromSurface(@NonNull List<ShortcutInfoCompat> list, int i) {
Objects.requireNonNull(list);
if (Build.VERSION.SDK_INT > 32) {
return list;
}
ArrayList arrayList = new ArrayList(list);
for (ShortcutInfoCompat shortcutInfoCompat : list) {
if (shortcutInfoCompat.isExcludedFromSurfaces(i)) {
arrayList.remove(shortcutInfoCompat);
}
}
return arrayList;
}
@RequiresApi(25)
public static class Api25Impl {
private Api25Impl() {
}
public static String getShortcutInfoWithLowestRank(@NonNull List<ShortcutInfo> list) {
int i = -1;
String str = null;
for (ShortcutInfo shortcutInfo : list) {
if (shortcutInfo.getRank() > i) {
str = shortcutInfo.getId();
i = shortcutInfo.getRank();
}
}
return str;
}
}
}

View File

@@ -0,0 +1,116 @@
package androidx.core.content.pm;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.ResolveInfo;
import android.content.res.XmlResourceParser;
import android.os.Bundle;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.annotation.VisibleForTesting;
import androidx.annotation.WorkerThread;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
/* loaded from: classes.dex */
public class ShortcutXmlParser {
private static final String ATTR_SHORTCUT_ID = "shortcutId";
private static final Object GET_INSTANCE_LOCK = new Object();
private static final String META_DATA_APP_SHORTCUTS = "android.app.shortcuts";
private static final String TAG = "ShortcutXmlParser";
private static final String TAG_SHORTCUT = "shortcut";
private static volatile ArrayList<String> sShortcutIds;
@NonNull
@WorkerThread
public static List<String> getShortcutIds(@NonNull Context context) {
if (sShortcutIds == null) {
synchronized (GET_INSTANCE_LOCK) {
try {
if (sShortcutIds == null) {
sShortcutIds = new ArrayList<>();
sShortcutIds.addAll(parseShortcutIds(context));
}
} finally {
}
}
}
return sShortcutIds;
}
private ShortcutXmlParser() {
}
@NonNull
private static Set<String> parseShortcutIds(@NonNull Context context) {
HashSet hashSet = new HashSet();
Intent intent = new Intent("android.intent.action.MAIN");
intent.addCategory("android.intent.category.LAUNCHER");
intent.setPackage(context.getPackageName());
List<ResolveInfo> queryIntentActivities = context.getPackageManager().queryIntentActivities(intent, 128);
if (queryIntentActivities != null && queryIntentActivities.size() != 0) {
try {
Iterator<ResolveInfo> it = queryIntentActivities.iterator();
while (it.hasNext()) {
ActivityInfo activityInfo = it.next().activityInfo;
Bundle bundle = activityInfo.metaData;
if (bundle != null && bundle.containsKey(META_DATA_APP_SHORTCUTS)) {
XmlResourceParser xmlResourceParser = getXmlResourceParser(context, activityInfo);
try {
hashSet.addAll(parseShortcutIds(xmlResourceParser));
if (xmlResourceParser != null) {
xmlResourceParser.close();
}
} finally {
}
}
}
} catch (Exception e) {
Log.e(TAG, "Failed to parse the Xml resource: ", e);
}
}
return hashSet;
}
@NonNull
private static XmlResourceParser getXmlResourceParser(Context context, ActivityInfo activityInfo) {
XmlResourceParser loadXmlMetaData = activityInfo.loadXmlMetaData(context.getPackageManager(), META_DATA_APP_SHORTCUTS);
if (loadXmlMetaData != null) {
return loadXmlMetaData;
}
throw new IllegalArgumentException("Failed to open android.app.shortcuts meta-data resource of " + activityInfo.name);
}
@NonNull
@VisibleForTesting
public static List<String> parseShortcutIds(@NonNull XmlPullParser xmlPullParser) throws IOException, XmlPullParserException {
String attributeValue;
ArrayList arrayList = new ArrayList(1);
while (true) {
int next = xmlPullParser.next();
if (next == 1 || (next == 3 && xmlPullParser.getDepth() <= 0)) {
break;
}
int depth = xmlPullParser.getDepth();
String name = xmlPullParser.getName();
if (next == 2 && depth == 2 && TAG_SHORTCUT.equals(name) && (attributeValue = getAttributeValue(xmlPullParser, ATTR_SHORTCUT_ID)) != null) {
arrayList.add(attributeValue);
}
}
return arrayList;
}
private static String getAttributeValue(XmlPullParser xmlPullParser, String str) {
String attributeValue = xmlPullParser.getAttributeValue("http://schemas.android.com/apk/res/android", str);
return attributeValue == null ? xmlPullParser.getAttributeValue(null, str) : attributeValue;
}
}