content: package androidx.core.content.pm;
  
  import android.content.ComponentName;
  import android.content.Context;
  import android.content.Intent;
  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.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.List;
  import java.util.Map;
  import java.util.Set;
  import mt.Log1F380D;
  
  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;
      LocusIdCompat mLocusId;
      CharSequence mLongLabel;
      String mPackageName;
      Person[] mPersons;
      int mRank;
      Bundle mTransientExtras;
      UserHandle mUser;
  
      /* compiled from: 003C */
      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;
  
          public Builder(Context context, ShortcutInfo shortcutInfo) {
              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();
              if (Build.VERSION.SDK_INT >= 28) {
                  shortcutInfoCompat.mDisabledReason = shortcutInfo.getDisabledReason();
              } 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 (Build.VERSION.SDK_INT >= 30) {
                  shortcutInfoCompat.mIsCached = shortcutInfo.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();
          }
  
          public Builder(Context context, String id) {
              ShortcutInfoCompat shortcutInfoCompat = new ShortcutInfoCompat();
              this.mInfo = shortcutInfoCompat;
              shortcutInfoCompat.mContext = context;
              shortcutInfoCompat.mId = id;
          }
  
          public Builder(ShortcutInfoCompat shortcutInfo) {
              ShortcutInfoCompat shortcutInfoCompat = new ShortcutInfoCompat();
              this.mInfo = shortcutInfoCompat;
              shortcutInfoCompat.mContext = shortcutInfo.mContext;
              shortcutInfoCompat.mId = shortcutInfo.mId;
              shortcutInfoCompat.mPackageName = shortcutInfo.mPackageName;
              shortcutInfoCompat.mIntents = (Intent[]) Arrays.copyOf(shortcutInfo.mIntents, shortcutInfo.mIntents.length);
              shortcutInfoCompat.mActivity = shortcutInfo.mActivity;
              shortcutInfoCompat.mLabel = shortcutInfo.mLabel;
              shortcutInfoCompat.mLongLabel = shortcutInfo.mLongLabel;
              shortcutInfoCompat.mDisabledMessage = shortcutInfo.mDisabledMessage;
              shortcutInfoCompat.mDisabledReason = shortcutInfo.mDisabledReason;
              shortcutInfoCompat.mIcon = shortcutInfo.mIcon;
              shortcutInfoCompat.mIsAlwaysBadged = shortcutInfo.mIsAlwaysBadged;
              shortcutInfoCompat.mUser = shortcutInfo.mUser;
              shortcutInfoCompat.mLastChangedTimestamp = shortcutInfo.mLastChangedTimestamp;
              shortcutInfoCompat.mIsCached = shortcutInfo.mIsCached;
              shortcutInfoCompat.mIsDynamic = shortcutInfo.mIsDynamic;
              shortcutInfoCompat.mIsPinned = shortcutInfo.mIsPinned;
              shortcutInfoCompat.mIsDeclaredInManifest = shortcutInfo.mIsDeclaredInManifest;
              shortcutInfoCompat.mIsImmutable = shortcutInfo.mIsImmutable;
              shortcutInfoCompat.mIsEnabled = shortcutInfo.mIsEnabled;
              shortcutInfoCompat.mLocusId = shortcutInfo.mLocusId;
              shortcutInfoCompat.mIsLongLived = shortcutInfo.mIsLongLived;
              shortcutInfoCompat.mHasKeyFieldsOnly = shortcutInfo.mHasKeyFieldsOnly;
              shortcutInfoCompat.mRank = shortcutInfo.mRank;
              if (shortcutInfo.mPersons != null) {
                  shortcutInfoCompat.mPersons = (Person[]) Arrays.copyOf(shortcutInfo.mPersons, shortcutInfo.mPersons.length);
              }
              if (shortcutInfo.mCategories != null) {
                  shortcutInfoCompat.mCategories = new HashSet(shortcutInfo.mCategories);
              }
              if (shortcutInfo.mExtras != null) {
                  shortcutInfoCompat.mExtras = shortcutInfo.mExtras;
              }
              shortcutInfoCompat.mExcludedSurfaces = shortcutInfo.mExcludedSurfaces;
          }
  
          public Builder addCapabilityBinding(String capability) {
              if (this.mCapabilityBindings == null) {
                  this.mCapabilityBindings = new HashSet();
              }
              this.mCapabilityBindings.add(capability);
              return this;
          }
  
          public Builder addCapabilityBinding(String capability, String parameter, List<String> list) {
              addCapabilityBinding(capability);
              if (!list.isEmpty()) {
                  if (this.mCapabilityBindingParams == null) {
                      this.mCapabilityBindingParams = new HashMap();
                  }
                  if (this.mCapabilityBindingParams.get(capability) == null) {
                      this.mCapabilityBindingParams.put(capability, new HashMap());
                  }
                  this.mCapabilityBindingParams.get(capability).put(parameter, list);
              }
              return this;
          }
  
          public ShortcutInfoCompat build() {
              if (TextUtils.isEmpty(this.mInfo.mLabel)) {
                  throw new IllegalArgumentException("Shortcut must have a non-empty label");
              } else if (this.mInfo.mIntents == null || this.mInfo.mIntents.length == 0) {
                  throw new IllegalArgumentException("Shortcut must have an intent");
              } else {
                  if (this.mIsConversation) {
                      if (this.mInfo.mLocusId == null) {
                          this.mInfo.mLocusId = new LocusIdCompat(this.mInfo.mId);
                      }
                      this.mInfo.mIsLongLived = true;
                  }
                  if (this.mCapabilityBindings != null) {
                      if (this.mInfo.mCategories == null) {
                          this.mInfo.mCategories = new HashSet();
                      }
                      this.mInfo.mCategories.addAll(this.mCapabilityBindings);
                  }
                  if (Build.VERSION.SDK_INT >= 21) {
                      if (this.mCapabilityBindingParams != null) {
                          if (this.mInfo.mExtras == null) {
                              this.mInfo.mExtras = new PersistableBundle();
                          }
                          for (String next : this.mCapabilityBindingParams.keySet()) {
                              Map map = this.mCapabilityBindingParams.get(next);
                              this.mInfo.mExtras.putStringArray(next, (String[]) map.keySet().toArray(new String[0]));
                              for (String str : map.keySet()) {
                                  List list = (List) map.get(str);
                                  PersistableBundle persistableBundle = this.mInfo.mExtras;
                                  String str2 = next + "/" + str;
                                  String[] strArr = new String[0];
                                  if (list != null) {
                                      strArr = (String[]) list.toArray(strArr);
                                  }
                                  persistableBundle.putStringArray(str2, strArr);
                              }
                          }
                      }
                      if (this.mSliceUri != null) {
                          if (this.mInfo.mExtras == null) {
                              this.mInfo.mExtras = new PersistableBundle();
                          }
                          PersistableBundle persistableBundle2 = this.mInfo.mExtras;
                          String safeString = UriCompat.toSafeString(this.mSliceUri);
                          Log1F380D.a((Object) safeString);
                          persistableBundle2.putString(ShortcutInfoCompat.EXTRA_SLICE_URI, safeString);
                      }
                  }
                  return this.mInfo;
              }
          }
  
          public Builder setActivity(ComponentName activity) {
              this.mInfo.mActivity = activity;
              return this;
          }
  
          public Builder setAlwaysBadged() {
              this.mInfo.mIsAlwaysBadged = true;
              return this;
          }
  
          public Builder setCategories(Set<String> set) {
              this.mInfo.mCategories = set;
              return this;
          }
  
          public Builder setDisabledMessage(CharSequence disabledMessage) {
              this.mInfo.mDisabledMessage = disabledMessage;
              return this;
          }
  
          public Builder setExcludedFromSurfaces(int surfaces) {
              this.mInfo.mExcludedSurfaces = surfaces;
              return this;
          }
  
          public Builder setExtras(PersistableBundle extras) {
              this.mInfo.mExtras = extras;
              return this;
          }
  
          public Builder setIcon(IconCompat icon) {
              this.mInfo.mIcon = icon;
              return this;
          }
  
          public Builder setIntent(Intent intent) {
              return setIntents(new Intent[]{intent});
          }
  
          public Builder setIntents(Intent[] intents) {
              this.mInfo.mIntents = intents;
              return this;
          }
  
          public Builder setIsConversation() {
              this.mIsConversation = true;
              return this;
          }
  
          public Builder setLocusId(LocusIdCompat locusId) {
              this.mInfo.mLocusId = locusId;
              return this;
          }
  
          public Builder setLongLabel(CharSequence longLabel) {
              this.mInfo.mLongLabel = longLabel;
              return this;
          }
  
          @Deprecated
          public Builder setLongLived() {
              this.mInfo.mIsLongLived = true;
              return this;
          }
  
          public Builder setLongLived(boolean longLived) {
              this.mInfo.mIsLongLived = longLived;
              return this;
          }
  
          public Builder setPerson(Person person) {
              return setPersons(new Person[]{person});
          }
  
          public Builder setPersons(Person[] persons) {
              this.mInfo.mPersons = persons;
              return this;
          }
  
          public Builder setRank(int rank) {
              this.mInfo.mRank = rank;
              return this;
          }
  
          public Builder setShortLabel(CharSequence shortLabel) {
              this.mInfo.mLabel = shortLabel;
              return this;
          }
  
          public Builder setSliceUri(Uri sliceUri) {
              this.mSliceUri = sliceUri;
              return this;
          }
  
          public Builder setTransientExtras(Bundle transientExtras) {
              this.mInfo.mTransientExtras = (Bundle) Preconditions.checkNotNull(transientExtras);
              return this;
          }
      }
  
      @Retention(RetentionPolicy.SOURCE)
      public @interface Surface {
      }
  
      ShortcutInfoCompat() {
      }
  
      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);
              for (int i = 0; i < this.mPersons.length; i++) {
                  this.mExtras.putPersistableBundle(EXTRA_PERSON_ + (i + 1), this.mPersons[i].toPersistableBundle());
              }
          }
          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;
      }
  
      static List<ShortcutInfoCompat> fromShortcuts(Context context, List<ShortcutInfo> list) {
          ArrayList arrayList = new ArrayList(list.size());
          for (ShortcutInfo builder : list) {
              arrayList.add(new Builder(context, builder).build());
          }
          return arrayList;
      }
  
      static LocusIdCompat getLocusId(ShortcutInfo shortcutInfo) {
          if (Build.VERSION.SDK_INT < 29) {
              return getLocusIdFromExtra(shortcutInfo.getExtras());
          }
          if (shortcutInfo.getLocusId() == null) {
              return null;
          }
          return LocusIdCompat.toLocusIdCompat(shortcutInfo.getLocusId());
      }
  
      private static LocusIdCompat getLocusIdFromExtra(PersistableBundle bundle) {
          String string;
          if (bundle == null || (string = bundle.getString(EXTRA_LOCUS_ID)) == null) {
              return null;
          }
          return new LocusIdCompat(string);
      }
  
      static boolean getLongLivedFromExtra(PersistableBundle bundle) {
          if (bundle == null || !bundle.containsKey(EXTRA_LONG_LIVED)) {
              return false;
          }
          return bundle.getBoolean(EXTRA_LONG_LIVED);
      }
  
      static Person[] getPersonsFromExtra(PersistableBundle bundle) {
          if (bundle == null || !bundle.containsKey(EXTRA_PERSON_COUNT)) {
              return null;
          }
          int i = bundle.getInt(EXTRA_PERSON_COUNT);
          Person[] personArr = new Person[i];
          for (int i2 = 0; i2 < i; i2++) {
              personArr[i2] = Person.fromPersistableBundle(bundle.getPersistableBundle(EXTRA_PERSON_ + (i2 + 1)));
          }
          return personArr;
      }
  
      /* access modifiers changed from: package-private */
      public Intent addToIntent(Intent outIntent) {
          Intent[] intentArr = this.mIntents;
          outIntent.putExtra("android.intent.extra.shortcut.INTENT", intentArr[intentArr.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 e) {
                      }
                  }
                  if (drawable == null) {
                      drawable = this.mContext.getApplicationInfo().loadIcon(packageManager);
                  }
              }
              this.mIcon.addToShortcutIntent(outIntent, drawable, this.mContext);
          }
          return outIntent;
      }
  
      public ComponentName getActivity() {
          return this.mActivity;
      }
  
      public Set<String> getCategories() {
          return this.mCategories;
      }
  
      public CharSequence getDisabledMessage() {
          return this.mDisabledMessage;
      }
  
      public int getDisabledReason() {
          return this.mDisabledReason;
      }
  
      public int getExcludedFromSurfaces() {
          return this.mExcludedSurfaces;
      }
  
      public PersistableBundle getExtras() {
          return this.mExtras;
      }
  
      public IconCompat getIcon() {
          return this.mIcon;
      }
  
      public String getId() {
          return this.mId;
      }
  
      public Intent getIntent() {
          Intent[] intentArr = this.mIntents;
          return intentArr[intentArr.length - 1];
      }
  
      public Intent[] getIntents() {
          Intent[] intentArr = this.mIntents;
          return (Intent[]) Arrays.copyOf(intentArr, intentArr.length);
      }
  
      public long getLastChangedTimestamp() {
          return this.mLastChangedTimestamp;
      }
  
      public LocusIdCompat getLocusId() {
          return this.mLocusId;
      }
  
      public CharSequence getLongLabel() {
          return this.mLongLabel;
      }
  
      public String getPackage() {
          return this.mPackageName;
      }
  
      public int getRank() {
          return this.mRank;
      }
  
      public CharSequence getShortLabel() {
          return this.mLabel;
      }
  
      public Bundle getTransientExtras() {
          return this.mTransientExtras;
      }
  
      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 surface) {
          return (this.mExcludedSurfaces & surface) != 0;
      }
  
      public boolean isImmutable() {
          return this.mIsImmutable;
      }
  
      public boolean isPinned() {
          return this.mIsPinned;
      }
  
      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) {
                  android.app.Person[] personArr2 = new android.app.Person[personArr.length];
                  for (int i = 0; i < personArr2.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());
          }
          return intents.build();
      }
  }
  