content: package androidx.core.app;
  
  import android.app.Notification;
  import android.app.RemoteInput;
  import android.content.Context;
  import android.net.Uri;
  import android.os.Build;
  import android.os.Bundle;
  import android.text.TextUtils;
  import android.util.SparseArray;
  import android.widget.RemoteViews;
  import androidx.collection.ArraySet;
  import androidx.core.app.NotificationCompat;
  import androidx.core.graphics.drawable.IconCompat;
  import java.util.ArrayList;
  import java.util.Iterator;
  import java.util.List;
  import mt.Log1F380D;
  
  /* compiled from: 0030 */
  class NotificationCompatBuilder implements NotificationBuilderWithBuilderAccessor {
      private final List<Bundle> mActionExtrasList = new ArrayList();
      private RemoteViews mBigContentView;
      private final Notification.Builder mBuilder;
      private final NotificationCompat.Builder mBuilderCompat;
      private RemoteViews mContentView;
      private final Context mContext;
      private final Bundle mExtras = new Bundle();
      private int mGroupAlertBehavior;
      private RemoteViews mHeadsUpContentView;
  
      NotificationCompatBuilder(NotificationCompat.Builder b) {
          List<String> combineLists;
          this.mBuilderCompat = b;
          this.mContext = b.mContext;
          if (Build.VERSION.SDK_INT >= 26) {
              this.mBuilder = new Notification.Builder(b.mContext, b.mChannelId);
          } else {
              this.mBuilder = new Notification.Builder(b.mContext);
          }
          Notification notification = b.mNotification;
          this.mBuilder.setWhen(notification.when).setSmallIcon(notification.icon, notification.iconLevel).setContent(notification.contentView).setTicker(notification.tickerText, b.mTickerView).setVibrate(notification.vibrate).setLights(notification.ledARGB, notification.ledOnMS, notification.ledOffMS).setOngoing((notification.flags & 2) != 0).setOnlyAlertOnce((notification.flags & 8) != 0).setAutoCancel((notification.flags & 16) != 0).setDefaults(notification.defaults).setContentTitle(b.mContentTitle).setContentText(b.mContentText).setContentInfo(b.mContentInfo).setContentIntent(b.mContentIntent).setDeleteIntent(notification.deleteIntent).setFullScreenIntent(b.mFullScreenIntent, (notification.flags & 128) != 0).setLargeIcon(b.mLargeIcon).setNumber(b.mNumber).setProgress(b.mProgressMax, b.mProgress, b.mProgressIndeterminate);
          if (Build.VERSION.SDK_INT < 21) {
              this.mBuilder.setSound(notification.sound, notification.audioStreamType);
          }
          if (Build.VERSION.SDK_INT >= 16) {
              this.mBuilder.setSubText(b.mSubText).setUsesChronometer(b.mUseChronometer).setPriority(b.mPriority);
              Iterator<NotificationCompat.Action> it = b.mActions.iterator();
              while (it.hasNext()) {
                  addAction(it.next());
              }
              if (b.mExtras != null) {
                  this.mExtras.putAll(b.mExtras);
              }
              if (Build.VERSION.SDK_INT < 20) {
                  if (b.mLocalOnly) {
                      this.mExtras.putBoolean(NotificationCompatExtras.EXTRA_LOCAL_ONLY, true);
                  }
                  if (b.mGroupKey != null) {
                      this.mExtras.putString(NotificationCompatExtras.EXTRA_GROUP_KEY, b.mGroupKey);
                      if (b.mGroupSummary) {
                          this.mExtras.putBoolean(NotificationCompatExtras.EXTRA_GROUP_SUMMARY, true);
                      } else {
                          this.mExtras.putBoolean(NotificationManagerCompat.EXTRA_USE_SIDE_CHANNEL, true);
                      }
                  }
                  if (b.mSortKey != null) {
                      this.mExtras.putString(NotificationCompatExtras.EXTRA_SORT_KEY, b.mSortKey);
                  }
              }
              this.mContentView = b.mContentView;
              this.mBigContentView = b.mBigContentView;
          }
          if (Build.VERSION.SDK_INT >= 17) {
              this.mBuilder.setShowWhen(b.mShowWhen);
          }
          if (Build.VERSION.SDK_INT >= 19 && Build.VERSION.SDK_INT < 21 && (combineLists = combineLists(getPeople(b.mPersonList), b.mPeople)) != null && !combineLists.isEmpty()) {
              this.mExtras.putStringArray(NotificationCompat.EXTRA_PEOPLE, (String[]) combineLists.toArray(new String[combineLists.size()]));
          }
          if (Build.VERSION.SDK_INT >= 20) {
              this.mBuilder.setLocalOnly(b.mLocalOnly).setGroup(b.mGroupKey).setGroupSummary(b.mGroupSummary).setSortKey(b.mSortKey);
              this.mGroupAlertBehavior = b.mGroupAlertBehavior;
          }
          if (Build.VERSION.SDK_INT >= 21) {
              this.mBuilder.setCategory(b.mCategory).setColor(b.mColor).setVisibility(b.mVisibility).setPublicVersion(b.mPublicVersion).setSound(notification.sound, notification.audioAttributes);
              List<String> combineLists2 = Build.VERSION.SDK_INT < 28 ? combineLists(getPeople(b.mPersonList), b.mPeople) : b.mPeople;
              if (combineLists2 != null && !combineLists2.isEmpty()) {
                  for (String addPerson : combineLists2) {
                      this.mBuilder.addPerson(addPerson);
                  }
              }
              this.mHeadsUpContentView = b.mHeadsUpContentView;
              if (b.mInvisibleActions.size() > 0) {
                  Bundle bundle = b.getExtras().getBundle("android.car.EXTENSIONS");
                  bundle = bundle == null ? new Bundle() : bundle;
                  Bundle bundle2 = new Bundle(bundle);
                  Bundle bundle3 = new Bundle();
                  for (int i = 0; i < b.mInvisibleActions.size(); i++) {
                      String num = Integer.toString(i);
                      Log1F380D.a((Object) num);
                      bundle3.putBundle(num, NotificationCompatJellybean.getBundleForAction(b.mInvisibleActions.get(i)));
                  }
                  bundle.putBundle("invisible_actions", bundle3);
                  bundle2.putBundle("invisible_actions", bundle3);
                  b.getExtras().putBundle("android.car.EXTENSIONS", bundle);
                  this.mExtras.putBundle("android.car.EXTENSIONS", bundle2);
              }
          }
          if (Build.VERSION.SDK_INT >= 23 && b.mSmallIcon != null) {
              this.mBuilder.setSmallIcon(b.mSmallIcon);
          }
          if (Build.VERSION.SDK_INT >= 24) {
              this.mBuilder.setExtras(b.mExtras).setRemoteInputHistory(b.mRemoteInputHistory);
              if (b.mContentView != null) {
                  this.mBuilder.setCustomContentView(b.mContentView);
              }
              if (b.mBigContentView != null) {
                  this.mBuilder.setCustomBigContentView(b.mBigContentView);
              }
              if (b.mHeadsUpContentView != null) {
                  this.mBuilder.setCustomHeadsUpContentView(b.mHeadsUpContentView);
              }
          }
          if (Build.VERSION.SDK_INT >= 26) {
              this.mBuilder.setBadgeIconType(b.mBadgeIcon).setSettingsText(b.mSettingsText).setShortcutId(b.mShortcutId).setTimeoutAfter(b.mTimeout).setGroupAlertBehavior(b.mGroupAlertBehavior);
              if (b.mColorizedSet) {
                  this.mBuilder.setColorized(b.mColorized);
              }
              if (!TextUtils.isEmpty(b.mChannelId)) {
                  this.mBuilder.setSound((Uri) null).setDefaults(0).setLights(0, 0, 0).setVibrate((long[]) null);
              }
          }
          if (Build.VERSION.SDK_INT >= 28) {
              Iterator<Person> it2 = b.mPersonList.iterator();
              while (it2.hasNext()) {
                  this.mBuilder.addPerson(it2.next().toAndroidPerson());
              }
          }
          if (Build.VERSION.SDK_INT >= 29) {
              this.mBuilder.setAllowSystemGeneratedContextualActions(b.mAllowSystemGeneratedContextualActions);
              this.mBuilder.setBubbleMetadata(NotificationCompat.BubbleMetadata.toPlatform(b.mBubbleMetadata));
              if (b.mLocusId != null) {
                  this.mBuilder.setLocusId(b.mLocusId.toLocusId());
              }
          }
          if (Build.VERSION.SDK_INT >= 31 && b.mFgsDeferBehavior != 0) {
              this.mBuilder.setForegroundServiceBehavior(b.mFgsDeferBehavior);
          }
          if (b.mSilent) {
              if (this.mBuilderCompat.mGroupSummary) {
                  this.mGroupAlertBehavior = 2;
              } else {
                  this.mGroupAlertBehavior = 1;
              }
              this.mBuilder.setVibrate((long[]) null);
              this.mBuilder.setSound((Uri) null);
              notification.defaults &= -2;
              notification.defaults &= -3;
              this.mBuilder.setDefaults(notification.defaults);
              if (Build.VERSION.SDK_INT >= 26) {
                  if (TextUtils.isEmpty(this.mBuilderCompat.mGroupKey)) {
                      this.mBuilder.setGroup(NotificationCompat.GROUP_KEY_SILENT);
                  }
                  this.mBuilder.setGroupAlertBehavior(this.mGroupAlertBehavior);
              }
          }
      }
  
      private void addAction(NotificationCompat.Action action) {
          Notification.Action.Builder builder;
          if (Build.VERSION.SDK_INT >= 20) {
              IconCompat iconCompat = action.getIconCompat();
              if (Build.VERSION.SDK_INT >= 23) {
                  builder = new Notification.Action.Builder(iconCompat != null ? iconCompat.toIcon() : null, action.getTitle(), action.getActionIntent());
              } else {
                  builder = new Notification.Action.Builder(iconCompat != null ? iconCompat.getResId() : 0, action.getTitle(), action.getActionIntent());
              }
              if (action.getRemoteInputs() != null) {
                  for (RemoteInput addRemoteInput : RemoteInput.fromCompat(action.getRemoteInputs())) {
                      builder.addRemoteInput(addRemoteInput);
                  }
              }
              Bundle bundle = action.getExtras() != null ? new Bundle(action.getExtras()) : new Bundle();
              bundle.putBoolean("android.support.allowGeneratedReplies", action.getAllowGeneratedReplies());
              if (Build.VERSION.SDK_INT >= 24) {
                  builder.setAllowGeneratedReplies(action.getAllowGeneratedReplies());
              }
              bundle.putInt("android.support.action.semanticAction", action.getSemanticAction());
              if (Build.VERSION.SDK_INT >= 28) {
                  builder.setSemanticAction(action.getSemanticAction());
              }
              if (Build.VERSION.SDK_INT >= 29) {
                  builder.setContextual(action.isContextual());
              }
              if (Build.VERSION.SDK_INT >= 31) {
                  builder.setAuthenticationRequired(action.isAuthenticationRequired());
              }
              bundle.putBoolean("android.support.action.showsUserInterface", action.getShowsUserInterface());
              builder.addExtras(bundle);
              this.mBuilder.addAction(builder.build());
          } else if (Build.VERSION.SDK_INT >= 16) {
              this.mActionExtrasList.add(NotificationCompatJellybean.writeActionAndGetExtras(this.mBuilder, action));
          }
      }
  
      private static List<String> combineLists(List<String> list, List<String> list2) {
          if (list == null) {
              return list2;
          }
          if (list2 == null) {
              return list;
          }
          ArraySet arraySet = new ArraySet(list.size() + list2.size());
          arraySet.addAll(list);
          arraySet.addAll(list2);
          return new ArrayList(arraySet);
      }
  
      private static List<String> getPeople(List<Person> list) {
          if (list == null) {
              return null;
          }
          ArrayList arrayList = new ArrayList(list.size());
          for (Person resolveToLegacyUri : list) {
              arrayList.add(resolveToLegacyUri.resolveToLegacyUri());
          }
          return arrayList;
      }
  
      private void removeSoundAndVibration(Notification notification) {
          notification.sound = null;
          notification.vibrate = null;
          notification.defaults &= -2;
          notification.defaults &= -3;
      }
  
      public Notification build() {
          Bundle extras;
          RemoteViews makeHeadsUpContentView;
          RemoteViews makeBigContentView;
          NotificationCompat.Style style = this.mBuilderCompat.mStyle;
          if (style != null) {
              style.apply(this);
          }
          RemoteViews makeContentView = style != null ? style.makeContentView(this) : null;
          Notification buildInternal = buildInternal();
          if (makeContentView != null) {
              buildInternal.contentView = makeContentView;
          } else if (this.mBuilderCompat.mContentView != null) {
              buildInternal.contentView = this.mBuilderCompat.mContentView;
          }
          if (!(Build.VERSION.SDK_INT < 16 || style == null || (makeBigContentView = style.makeBigContentView(this)) == null)) {
              buildInternal.bigContentView = makeBigContentView;
          }
          if (!(Build.VERSION.SDK_INT < 21 || style == null || (makeHeadsUpContentView = this.mBuilderCompat.mStyle.makeHeadsUpContentView(this)) == null)) {
              buildInternal.headsUpContentView = makeHeadsUpContentView;
          }
          if (!(Build.VERSION.SDK_INT < 16 || style == null || (extras = NotificationCompat.getExtras(buildInternal)) == null)) {
              style.addCompatExtras(extras);
          }
          return buildInternal;
      }
  
      /* access modifiers changed from: protected */
      public Notification buildInternal() {
          if (Build.VERSION.SDK_INT >= 26) {
              return this.mBuilder.build();
          }
          if (Build.VERSION.SDK_INT >= 24) {
              Notification build = this.mBuilder.build();
              if (this.mGroupAlertBehavior != 0) {
                  if (!(build.getGroup() == null || (build.flags & 512) == 0 || this.mGroupAlertBehavior != 2)) {
                      removeSoundAndVibration(build);
                  }
                  if (build.getGroup() != null && (build.flags & 512) == 0 && this.mGroupAlertBehavior == 1) {
                      removeSoundAndVibration(build);
                  }
              }
              return build;
          } else if (Build.VERSION.SDK_INT >= 21) {
              this.mBuilder.setExtras(this.mExtras);
              Notification build2 = this.mBuilder.build();
              RemoteViews remoteViews = this.mContentView;
              if (remoteViews != null) {
                  build2.contentView = remoteViews;
              }
              RemoteViews remoteViews2 = this.mBigContentView;
              if (remoteViews2 != null) {
                  build2.bigContentView = remoteViews2;
              }
              RemoteViews remoteViews3 = this.mHeadsUpContentView;
              if (remoteViews3 != null) {
                  build2.headsUpContentView = remoteViews3;
              }
              if (this.mGroupAlertBehavior != 0) {
                  if (!(build2.getGroup() == null || (build2.flags & 512) == 0 || this.mGroupAlertBehavior != 2)) {
                      removeSoundAndVibration(build2);
                  }
                  if (build2.getGroup() != null && (build2.flags & 512) == 0 && this.mGroupAlertBehavior == 1) {
                      removeSoundAndVibration(build2);
                  }
              }
              return build2;
          } else if (Build.VERSION.SDK_INT >= 20) {
              this.mBuilder.setExtras(this.mExtras);
              Notification build3 = this.mBuilder.build();
              RemoteViews remoteViews4 = this.mContentView;
              if (remoteViews4 != null) {
                  build3.contentView = remoteViews4;
              }
              RemoteViews remoteViews5 = this.mBigContentView;
              if (remoteViews5 != null) {
                  build3.bigContentView = remoteViews5;
              }
              if (this.mGroupAlertBehavior != 0) {
                  if (!(build3.getGroup() == null || (build3.flags & 512) == 0 || this.mGroupAlertBehavior != 2)) {
                      removeSoundAndVibration(build3);
                  }
                  if (build3.getGroup() != null && (build3.flags & 512) == 0 && this.mGroupAlertBehavior == 1) {
                      removeSoundAndVibration(build3);
                  }
              }
              return build3;
          } else if (Build.VERSION.SDK_INT >= 19) {
              SparseArray<Bundle> buildActionExtrasMap = NotificationCompatJellybean.buildActionExtrasMap(this.mActionExtrasList);
              if (buildActionExtrasMap != null) {
                  this.mExtras.putSparseParcelableArray(NotificationCompatExtras.EXTRA_ACTION_EXTRAS, buildActionExtrasMap);
              }
              this.mBuilder.setExtras(this.mExtras);
              Notification build4 = this.mBuilder.build();
              RemoteViews remoteViews6 = this.mContentView;
              if (remoteViews6 != null) {
                  build4.contentView = remoteViews6;
              }
              RemoteViews remoteViews7 = this.mBigContentView;
              if (remoteViews7 != null) {
                  build4.bigContentView = remoteViews7;
              }
              return build4;
          } else if (Build.VERSION.SDK_INT < 16) {
              return this.mBuilder.getNotification();
          } else {
              Notification build5 = this.mBuilder.build();
              Bundle extras = NotificationCompat.getExtras(build5);
              Bundle bundle = new Bundle(this.mExtras);
              for (String str : this.mExtras.keySet()) {
                  if (extras.containsKey(str)) {
                      bundle.remove(str);
                  }
              }
              extras.putAll(bundle);
              SparseArray<Bundle> buildActionExtrasMap2 = NotificationCompatJellybean.buildActionExtrasMap(this.mActionExtrasList);
              if (buildActionExtrasMap2 != null) {
                  NotificationCompat.getExtras(build5).putSparseParcelableArray(NotificationCompatExtras.EXTRA_ACTION_EXTRAS, buildActionExtrasMap2);
              }
              RemoteViews remoteViews8 = this.mContentView;
              if (remoteViews8 != null) {
                  build5.contentView = remoteViews8;
              }
              RemoteViews remoteViews9 = this.mBigContentView;
              if (remoteViews9 != null) {
                  build5.bigContentView = remoteViews9;
              }
              return build5;
          }
      }
  
      public Notification.Builder getBuilder() {
          return this.mBuilder;
      }
  
      /* access modifiers changed from: package-private */
      public Context getContext() {
          return this.mContext;
      }
  }
  