Program: 191357
Project: 191357
Buggy source:
final void processNextBroadcast(boolean fromMsg){
synchronized (mService) {
    BroadcastRecord r;
    if (DEBUG_BROADCAST)     Slog.v(TAG_BROADCAST,"String_Node_Str" + mQueueName + "String_Node_Str"+ mParallelBroadcasts.size()+ "String_Node_Str"+ mOrderedBroadcasts.size()+ "String_Node_Str");
    mService.updateCpuStats();
    if (fromMsg) {
      mBroadcastsScheduled=false;
    }
    while (mParallelBroadcasts.size() > 0) {
      r=mParallelBroadcasts.remove(0);
      r.dispatchTime=SystemClock.uptimeMillis();
      r.dispatchClockTime=System.currentTimeMillis();
      final int N=r.receivers.size();
      if (DEBUG_BROADCAST_LIGHT)       Slog.v(TAG_BROADCAST,"String_Node_Str" + mQueueName + "String_Node_Str"+ r);
      for (int i=0; i < N; i++) {
        Object target=r.receivers.get(i);
        if (DEBUG_BROADCAST)         Slog.v(TAG_BROADCAST,"String_Node_Str" + mQueueName + "String_Node_Str"+ target+ "String_Node_Str"+ r);
        deliverToRegisteredReceiverLocked(r,(BroadcastFilter)target,false,i);
      }
      addBroadcastToHistoryLocked(r);
      if (DEBUG_BROADCAST_LIGHT)       Slog.v(TAG_BROADCAST,"String_Node_Str" + mQueueName + "String_Node_Str"+ r);
    }
    if (mPendingBroadcast != null) {
      if (DEBUG_BROADCAST_LIGHT)       Slog.v(TAG_BROADCAST,"String_Node_Str" + mQueueName + "String_Node_Str"+ mPendingBroadcast.curApp);
      boolean isDead;
synchronized (mService.mPidsSelfLocked) {
        ProcessRecord proc=mService.mPidsSelfLocked.get(mPendingBroadcast.curApp.pid);
        isDead=proc == null || proc.crashing;
      }
      if (!isDead) {
        return;
      }
 else {
        Slog.w(TAG,"String_Node_Str" + mQueueName + "String_Node_Str"+ mPendingBroadcast.curApp+ "String_Node_Str");
        mPendingBroadcast.state=BroadcastRecord.IDLE;
        mPendingBroadcast.nextReceiver=mPendingBroadcastRecvIndex;
        mPendingBroadcast=null;
      }
    }
    boolean looped=false;
    do {
      if (mOrderedBroadcasts.size() == 0) {
        mService.scheduleAppGcsLocked();
        if (looped) {
          mService.updateOomAdjLocked();
        }
        return;
      }
      r=mOrderedBroadcasts.get(0);
      boolean forceReceive=false;
      int numReceivers=(r.receivers != null) ? r.receivers.size() : 0;
      if (mService.mProcessesReady && r.dispatchTime > 0) {
        long now=SystemClock.uptimeMillis();
        if ((numReceivers > 0) && (now > r.dispatchTime + (2 * mTimeoutPeriod * numReceivers))) {
          Slog.w(TAG,"String_Node_Str" + mQueueName + "String_Node_Str"+ "String_Node_Str"+ now+ "String_Node_Str"+ r.dispatchTime+ "String_Node_Str"+ r.receiverTime+ "String_Node_Str"+ r.intent+ "String_Node_Str"+ numReceivers+ "String_Node_Str"+ r.nextReceiver+ "String_Node_Str"+ r.state);
          broadcastTimeoutLocked(false);
          forceReceive=true;
          r.state=BroadcastRecord.IDLE;
        }
      }
      if (r.state != BroadcastRecord.IDLE) {
        if (DEBUG_BROADCAST)         Slog.d(TAG_BROADCAST,"String_Node_Str" + mQueueName + "String_Node_Str"+ r.state+ "String_Node_Str");
        return;
      }
      if (r.receivers == null || r.nextReceiver >= numReceivers || r.resultAbort || forceReceive) {
        if (r.resultTo != null) {
          try {
            if (DEBUG_BROADCAST)             Slog.i(TAG_BROADCAST,"String_Node_Str" + mQueueName + "String_Node_Str"+ r.intent.getAction()+ "String_Node_Str"+ r.callerApp);
            performReceiveLocked(r.callerApp,r.resultTo,new Intent(r.intent),r.resultCode,r.resultData,r.resultExtras,false,false,r.userId);
            r.resultTo=null;
          }
 catch (          RemoteException e) {
            r.resultTo=null;
            Slog.w(TAG,"String_Node_Str" + mQueueName + "String_Node_Str"+ r.intent,e);
          }
        }
        if (DEBUG_BROADCAST)         Slog.v(TAG_BROADCAST,"String_Node_Str");
        cancelBroadcastTimeoutLocked();
        if (DEBUG_BROADCAST_LIGHT)         Slog.v(TAG_BROADCAST,"String_Node_Str" + r);
        addBroadcastToHistoryLocked(r);
        mOrderedBroadcasts.remove(0);
        r=null;
        looped=true;
        continue;
      }
    }
 while (r == null);
    int recIdx=r.nextReceiver++;
    r.receiverTime=SystemClock.uptimeMillis();
    if (recIdx == 0) {
      r.dispatchTime=r.receiverTime;
      r.dispatchClockTime=System.currentTimeMillis();
      if (DEBUG_BROADCAST_LIGHT)       Slog.v(TAG_BROADCAST,"String_Node_Str" + mQueueName + "String_Node_Str"+ r);
    }
    if (!mPendingBroadcastTimeoutMessage) {
      long timeoutTime=r.receiverTime + mTimeoutPeriod;
      if (DEBUG_BROADCAST)       Slog.v(TAG_BROADCAST,"String_Node_Str" + mQueueName + "String_Node_Str"+ r+ "String_Node_Str"+ timeoutTime);
      setBroadcastTimeoutLocked(timeoutTime);
    }
    final BroadcastOptions brOptions=r.options;
    final Object nextReceiver=r.receivers.get(recIdx);
    if (nextReceiver instanceof BroadcastFilter) {
      BroadcastFilter filter=(BroadcastFilter)nextReceiver;
      if (DEBUG_BROADCAST)       Slog.v(TAG_BROADCAST,"String_Node_Str" + mQueueName + "String_Node_Str"+ filter+ "String_Node_Str"+ r);
      deliverToRegisteredReceiverLocked(r,filter,r.ordered,recIdx);
      if (r.receiver == null || !r.ordered) {
        if (DEBUG_BROADCAST)         Slog.v(TAG_BROADCAST,"String_Node_Str" + mQueueName + "String_Node_Str"+ r.ordered+ "String_Node_Str"+ r.receiver);
        r.state=BroadcastRecord.IDLE;
        scheduleBroadcastsLocked();
      }
 else {
        if (brOptions != null && brOptions.getTemporaryAppWhitelistDuration() > 0) {
          scheduleTempWhitelistLocked(filter.owningUid,brOptions.getTemporaryAppWhitelistDuration(),r);
        }
      }
      return;
    }
    ResolveInfo info=(ResolveInfo)nextReceiver;
    ComponentName component=new ComponentName(info.activityInfo.applicationInfo.packageName,info.activityInfo.name);
    boolean skip=false;
    if (brOptions != null && (info.activityInfo.applicationInfo.targetSdkVersion < brOptions.getMinManifestReceiverApiLevel() || info.activityInfo.applicationInfo.targetSdkVersion > brOptions.getMaxManifestReceiverApiLevel())) {
      skip=true;
    }
    int perm=mService.checkComponentPermission(info.activityInfo.permission,r.callingPid,r.callingUid,info.activityInfo.applicationInfo.uid,info.activityInfo.exported);
    if (!skip && perm != PackageManager.PERMISSION_GRANTED) {
      if (!info.activityInfo.exported) {
        Slog.w(TAG,"String_Node_Str" + r.intent.toString() + "String_Node_Str"+ r.callerPackage+ "String_Node_Str"+ r.callingPid+ "String_Node_Str"+ r.callingUid+ "String_Node_Str"+ "String_Node_Str"+ info.activityInfo.applicationInfo.uid+ "String_Node_Str"+ component.flattenToShortString());
      }
 else {
        Slog.w(TAG,"String_Node_Str" + r.intent.toString() + "String_Node_Str"+ r.callerPackage+ "String_Node_Str"+ r.callingPid+ "String_Node_Str"+ r.callingUid+ "String_Node_Str"+ "String_Node_Str"+ info.activityInfo.permission+ "String_Node_Str"+ component.flattenToShortString());
      }
      skip=true;
    }
 else     if (!skip && info.activityInfo.permission != null) {
      final int opCode=AppOpsManager.permissionToOpCode(info.activityInfo.permission);
      if (opCode != AppOpsManager.OP_NONE && mService.mAppOpsService.noteOperation(opCode,r.callingUid,r.callerPackage) != AppOpsManager.MODE_ALLOWED) {
        Slog.w(TAG,"String_Node_Str" + r.intent.toString() + "String_Node_Str"+ r.callerPackage+ "String_Node_Str"+ r.callingPid+ "String_Node_Str"+ r.callingUid+ "String_Node_Str"+ "String_Node_Str"+ AppOpsManager.permissionToOp(info.activityInfo.permission)+ "String_Node_Str"+ component.flattenToShortString());
        skip=true;
      }
    }
    if (!skip && info.activityInfo.applicationInfo.uid != Process.SYSTEM_UID && r.requiredPermissions != null && r.requiredPermissions.length > 0) {
      for (int i=0; i < r.requiredPermissions.length; i++) {
        String requiredPermission=r.requiredPermissions[i];
        try {
          perm=AppGlobals.getPackageManager().checkPermission(requiredPermission,info.activityInfo.applicationInfo.packageName,UserHandle.getUserId(info.activityInfo.applicationInfo.uid));
        }
 catch (        RemoteException e) {
          perm=PackageManager.PERMISSION_DENIED;
        }
        if (perm != PackageManager.PERMISSION_GRANTED) {
          Slog.w(TAG,"String_Node_Str" + r.intent + "String_Node_Str"+ component.flattenToShortString()+ "String_Node_Str"+ requiredPermission+ "String_Node_Str"+ r.callerPackage+ "String_Node_Str"+ r.callingUid+ "String_Node_Str");
          skip=true;
          break;
        }
        int appOp=AppOpsManager.permissionToOpCode(requiredPermission);
        if (appOp != AppOpsManager.OP_NONE && appOp != r.appOp && mService.mAppOpsService.noteOperation(appOp,info.activityInfo.applicationInfo.uid,info.activityInfo.packageName) != AppOpsManager.MODE_ALLOWED) {
          Slog.w(TAG,"String_Node_Str" + r.intent + "String_Node_Str"+ component.flattenToShortString()+ "String_Node_Str"+ AppOpsManager.permissionToOp(requiredPermission)+ "String_Node_Str"+ r.callerPackage+ "String_Node_Str"+ r.callingUid+ "String_Node_Str");
          skip=true;
          break;
        }
      }
    }
    if (!skip && r.appOp != AppOpsManager.OP_NONE && mService.mAppOpsService.noteOperation(r.appOp,info.activityInfo.applicationInfo.uid,info.activityInfo.packageName) != AppOpsManager.MODE_ALLOWED) {
      Slog.w(TAG,"String_Node_Str" + r.intent + "String_Node_Str"+ component.flattenToShortString()+ "String_Node_Str"+ AppOpsManager.opToName(r.appOp)+ "String_Node_Str"+ r.callerPackage+ "String_Node_Str"+ r.callingUid+ "String_Node_Str");
      skip=true;
    }
    if (!skip) {
      skip=!mService.mIntentFirewall.checkBroadcast(r.intent,r.callingUid,r.callingPid,r.resolvedType,info.activityInfo.applicationInfo.uid);
    }
    boolean isSingleton=false;
    try {
      isSingleton=mService.isSingleton(info.activityInfo.processName,info.activityInfo.applicationInfo,info.activityInfo.name,info.activityInfo.flags);
    }
 catch (    SecurityException e) {
      Slog.w(TAG,e.getMessage());
      skip=true;
    }
    if ((info.activityInfo.flags & ActivityInfo.FLAG_SINGLE_USER) != 0) {
      if (ActivityManager.checkUidPermission(android.Manifest.permission.INTERACT_ACROSS_USERS,info.activityInfo.applicationInfo.uid) != PackageManager.PERMISSION_GRANTED) {
        Slog.w(TAG,"String_Node_Str" + component.flattenToShortString() + "String_Node_Str"+ android.Manifest.permission.INTERACT_ACROSS_USERS);
        skip=true;
      }
    }
    if (r.curApp != null && r.curApp.crashing) {
      Slog.w(TAG,"String_Node_Str" + mQueueName + "String_Node_Str"+ r+ "String_Node_Str"+ r.curApp+ "String_Node_Str");
      skip=true;
    }
    if (!skip) {
      boolean isAvailable=false;
      try {
        isAvailable=AppGlobals.getPackageManager().isPackageAvailable(info.activityInfo.packageName,UserHandle.getUserId(info.activityInfo.applicationInfo.uid));
      }
 catch (      Exception e) {
        Slog.w(TAG,"String_Node_Str" + info.activityInfo.packageName,e);
      }
      if (!isAvailable) {
        if (DEBUG_BROADCAST)         Slog.v(TAG_BROADCAST,"String_Node_Str" + info.activityInfo.packageName + "String_Node_Str"+ info.activityInfo.applicationInfo.uid+ "String_Node_Str");
        skip=true;
      }
    }
    if (Build.PERMISSIONS_REVIEW_REQUIRED && !skip) {
      if (!requestStartTargetPermissionsReviewIfNeededLocked(r,info.activityInfo.packageName,UserHandle.getUserId(info.activityInfo.applicationInfo.uid))) {
        skip=true;
      }
    }
    final int receiverUid=info.activityInfo.applicationInfo.uid;
    if (r.callingUid != Process.SYSTEM_UID && isSingleton && mService.isValidSingletonCall(r.callingUid,receiverUid)) {
      info.activityInfo=mService.getActivityInfoForUser(info.activityInfo,0);
    }
    String targetProcess=info.activityInfo.processName;
    ProcessRecord app=mService.getProcessRecordLocked(targetProcess,info.activityInfo.applicationInfo.uid,false);
    if (!skip) {
      final int allowed=mService.checkAllowBackgroundLocked(info.activityInfo.applicationInfo.uid,info.activityInfo.packageName,-1,false);
      if (allowed != ActivityManager.APP_START_MODE_NORMAL) {
        if (allowed == ActivityManager.APP_START_MODE_DISABLED) {
          Slog.w(TAG,"String_Node_Str" + r.intent + "String_Node_Str"+ component.flattenToShortString());
          skip=true;
        }
 else         if (((r.intent.getFlags() & Intent.FLAG_RECEIVER_EXCLUDE_BACKGROUND) != 0) || (r.intent.getComponent() == null && r.intent.getPackage() == null && ((r.intent.getFlags() & Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND) == 0))) {
          Slog.w(TAG,"String_Node_Str" + r.intent + "String_Node_Str"+ component.flattenToShortString());
          skip=true;
        }
      }
    }
    if (skip) {
      if (DEBUG_BROADCAST)       Slog.v(TAG_BROADCAST,"String_Node_Str" + mQueueName + "String_Node_Str"+ r+ "String_Node_Str");
      r.delivery[recIdx]=BroadcastRecord.DELIVERY_SKIPPED;
      r.receiver=null;
      r.curFilter=null;
      r.state=BroadcastRecord.IDLE;
      scheduleBroadcastsLocked();
      return;
    }
    r.delivery[recIdx]=BroadcastRecord.DELIVERY_DELIVERED;
    r.state=BroadcastRecord.APP_RECEIVE;
    r.curComponent=component;
    r.curReceiver=info.activityInfo;
    if (DEBUG_MU && r.callingUid > UserHandle.PER_USER_RANGE) {
      Slog.v(TAG_MU,"String_Node_Str" + info.activityInfo + "String_Node_Str"+ r.callingUid+ "String_Node_Str"+ info.activityInfo.applicationInfo.uid);
    }
    if (brOptions != null && brOptions.getTemporaryAppWhitelistDuration() > 0) {
      scheduleTempWhitelistLocked(receiverUid,brOptions.getTemporaryAppWhitelistDuration(),r);
    }
    try {
      AppGlobals.getPackageManager().setPackageStoppedState(r.curComponent.getPackageName(),false,UserHandle.getUserId(r.callingUid));
    }
 catch (    RemoteException e) {
    }
catch (    IllegalArgumentException e) {
      Slog.w(TAG,"String_Node_Str" + r.curComponent.getPackageName() + "String_Node_Str"+ e);
    }
    if (app != null && app.thread != null) {
      try {
        app.addPackage(info.activityInfo.packageName,info.activityInfo.applicationInfo.versionCode,mService.mProcessStats);
        processCurBroadcastLocked(r,app);
        return;
      }
 catch (      RemoteException e) {
        Slog.w(TAG,"String_Node_Str" + r.curComponent,e);
      }
catch (      RuntimeException e) {
        Slog.wtf(TAG,"String_Node_Str" + r.curComponent + "String_Node_Str"+ r.intent,e);
        logBroadcastReceiverDiscardLocked(r);
        finishReceiverLocked(r,r.resultCode,r.resultData,r.resultExtras,r.resultAbort,false);
        scheduleBroadcastsLocked();
        r.state=BroadcastRecord.IDLE;
        return;
      }
    }
    if (DEBUG_BROADCAST)     Slog.v(TAG_BROADCAST,"String_Node_Str" + mQueueName + "String_Node_Str"+ targetProcess+ "String_Node_Str"+ r);
    if ((r.curApp=mService.startProcessLocked(targetProcess,info.activityInfo.applicationInfo,true,r.intent.getFlags() | Intent.FLAG_FROM_BACKGROUND,"String_Node_Str",r.curComponent,(r.intent.getFlags() & Intent.FLAG_RECEIVER_BOOT_UPGRADE) != 0,false,false)) == null) {
      Slog.w(TAG,"String_Node_Str" + info.activityInfo.applicationInfo.packageName + "String_Node_Str"+ info.activityInfo.applicationInfo.uid+ "String_Node_Str"+ r.intent+ "String_Node_Str");
      logBroadcastReceiverDiscardLocked(r);
      finishReceiverLocked(r,r.resultCode,r.resultData,r.resultExtras,r.resultAbort,false);
      scheduleBroadcastsLocked();
      r.state=BroadcastRecord.IDLE;
      return;
    }
    mPendingBroadcast=r;
    mPendingBroadcastRecvIndex=recIdx;
  }
}

Fixed version (ground truth):
final void processNextBroadcast(boolean fromMsg){
synchronized (mService) {
    BroadcastRecord r;
    if (DEBUG_BROADCAST)     Slog.v(TAG_BROADCAST,"String_Node_Str" + mQueueName + "String_Node_Str"+ mParallelBroadcasts.size()+ "String_Node_Str"+ mOrderedBroadcasts.size()+ "String_Node_Str");
    mService.updateCpuStats();
    if (fromMsg) {
      mBroadcastsScheduled=false;
    }
    while (mParallelBroadcasts.size() > 0) {
      r=mParallelBroadcasts.remove(0);
      r.dispatchTime=SystemClock.uptimeMillis();
      r.dispatchClockTime=System.currentTimeMillis();
      final int N=r.receivers.size();
      if (DEBUG_BROADCAST_LIGHT)       Slog.v(TAG_BROADCAST,"String_Node_Str" + mQueueName + "String_Node_Str"+ r);
      for (int i=0; i < N; i++) {
        Object target=r.receivers.get(i);
        if (DEBUG_BROADCAST)         Slog.v(TAG_BROADCAST,"String_Node_Str" + mQueueName + "String_Node_Str"+ target+ "String_Node_Str"+ r);
        deliverToRegisteredReceiverLocked(r,(BroadcastFilter)target,false,i);
      }
      addBroadcastToHistoryLocked(r);
      if (DEBUG_BROADCAST_LIGHT)       Slog.v(TAG_BROADCAST,"String_Node_Str" + mQueueName + "String_Node_Str"+ r);
    }
    if (mPendingBroadcast != null) {
      if (DEBUG_BROADCAST_LIGHT)       Slog.v(TAG_BROADCAST,"String_Node_Str" + mQueueName + "String_Node_Str"+ mPendingBroadcast.curApp);
      boolean isDead;
synchronized (mService.mPidsSelfLocked) {
        ProcessRecord proc=mService.mPidsSelfLocked.get(mPendingBroadcast.curApp.pid);
        isDead=proc == null || proc.crashing;
      }
      if (!isDead) {
        return;
      }
 else {
        Slog.w(TAG,"String_Node_Str" + mQueueName + "String_Node_Str"+ mPendingBroadcast.curApp+ "String_Node_Str");
        mPendingBroadcast.state=BroadcastRecord.IDLE;
        mPendingBroadcast.nextReceiver=mPendingBroadcastRecvIndex;
        mPendingBroadcast=null;
      }
    }
    boolean looped=false;
    do {
      if (mOrderedBroadcasts.size() == 0) {
        mService.scheduleAppGcsLocked();
        if (looped) {
          mService.updateOomAdjLocked();
        }
        return;
      }
      r=mOrderedBroadcasts.get(0);
      boolean forceReceive=false;
      int numReceivers=(r.receivers != null) ? r.receivers.size() : 0;
      if (mService.mProcessesReady && r.dispatchTime > 0) {
        long now=SystemClock.uptimeMillis();
        if ((numReceivers > 0) && (now > r.dispatchTime + (2 * mTimeoutPeriod * numReceivers))) {
          Slog.w(TAG,"String_Node_Str" + mQueueName + "String_Node_Str"+ "String_Node_Str"+ now+ "String_Node_Str"+ r.dispatchTime+ "String_Node_Str"+ r.receiverTime+ "String_Node_Str"+ r.intent+ "String_Node_Str"+ numReceivers+ "String_Node_Str"+ r.nextReceiver+ "String_Node_Str"+ r.state);
          broadcastTimeoutLocked(false);
          forceReceive=true;
          r.state=BroadcastRecord.IDLE;
        }
      }
      if (r.state != BroadcastRecord.IDLE) {
        if (DEBUG_BROADCAST)         Slog.d(TAG_BROADCAST,"String_Node_Str" + mQueueName + "String_Node_Str"+ r.state+ "String_Node_Str");
        return;
      }
      if (r.receivers == null || r.nextReceiver >= numReceivers || r.resultAbort || forceReceive) {
        if (r.resultTo != null) {
          try {
            if (DEBUG_BROADCAST)             Slog.i(TAG_BROADCAST,"String_Node_Str" + mQueueName + "String_Node_Str"+ r.intent.getAction()+ "String_Node_Str"+ r.callerApp);
            performReceiveLocked(r.callerApp,r.resultTo,new Intent(r.intent),r.resultCode,r.resultData,r.resultExtras,false,false,r.userId);
            r.resultTo=null;
          }
 catch (          RemoteException e) {
            r.resultTo=null;
            Slog.w(TAG,"String_Node_Str" + mQueueName + "String_Node_Str"+ r.intent,e);
          }
        }
        if (DEBUG_BROADCAST)         Slog.v(TAG_BROADCAST,"String_Node_Str");
        cancelBroadcastTimeoutLocked();
        if (DEBUG_BROADCAST_LIGHT)         Slog.v(TAG_BROADCAST,"String_Node_Str" + r);
        addBroadcastToHistoryLocked(r);
        if (r.intent.getComponent() == null && r.intent.getPackage() == null && (r.intent.getFlags() & Intent.FLAG_RECEIVER_REGISTERED_ONLY) == 0) {
          mService.addBroadcastStatLocked(r.intent.getAction(),r.callerPackage,r.manifestCount,r.manifestSkipCount,r.finishTime - r.dispatchTime);
        }
        mOrderedBroadcasts.remove(0);
        r=null;
        looped=true;
        continue;
      }
    }
 while (r == null);
    int recIdx=r.nextReceiver++;
    r.receiverTime=SystemClock.uptimeMillis();
    if (recIdx == 0) {
      r.dispatchTime=r.receiverTime;
      r.dispatchClockTime=System.currentTimeMillis();
      if (DEBUG_BROADCAST_LIGHT)       Slog.v(TAG_BROADCAST,"String_Node_Str" + mQueueName + "String_Node_Str"+ r);
    }
    if (!mPendingBroadcastTimeoutMessage) {
      long timeoutTime=r.receiverTime + mTimeoutPeriod;
      if (DEBUG_BROADCAST)       Slog.v(TAG_BROADCAST,"String_Node_Str" + mQueueName + "String_Node_Str"+ r+ "String_Node_Str"+ timeoutTime);
      setBroadcastTimeoutLocked(timeoutTime);
    }
    final BroadcastOptions brOptions=r.options;
    final Object nextReceiver=r.receivers.get(recIdx);
    if (nextReceiver instanceof BroadcastFilter) {
      BroadcastFilter filter=(BroadcastFilter)nextReceiver;
      if (DEBUG_BROADCAST)       Slog.v(TAG_BROADCAST,"String_Node_Str" + mQueueName + "String_Node_Str"+ filter+ "String_Node_Str"+ r);
      deliverToRegisteredReceiverLocked(r,filter,r.ordered,recIdx);
      if (r.receiver == null || !r.ordered) {
        if (DEBUG_BROADCAST)         Slog.v(TAG_BROADCAST,"String_Node_Str" + mQueueName + "String_Node_Str"+ r.ordered+ "String_Node_Str"+ r.receiver);
        r.state=BroadcastRecord.IDLE;
        scheduleBroadcastsLocked();
      }
 else {
        if (brOptions != null && brOptions.getTemporaryAppWhitelistDuration() > 0) {
          scheduleTempWhitelistLocked(filter.owningUid,brOptions.getTemporaryAppWhitelistDuration(),r);
        }
      }
      return;
    }
    ResolveInfo info=(ResolveInfo)nextReceiver;
    ComponentName component=new ComponentName(info.activityInfo.applicationInfo.packageName,info.activityInfo.name);
    boolean skip=false;
    if (brOptions != null && (info.activityInfo.applicationInfo.targetSdkVersion < brOptions.getMinManifestReceiverApiLevel() || info.activityInfo.applicationInfo.targetSdkVersion > brOptions.getMaxManifestReceiverApiLevel())) {
      skip=true;
    }
    int perm=mService.checkComponentPermission(info.activityInfo.permission,r.callingPid,r.callingUid,info.activityInfo.applicationInfo.uid,info.activityInfo.exported);
    if (!skip && perm != PackageManager.PERMISSION_GRANTED) {
      if (!info.activityInfo.exported) {
        Slog.w(TAG,"String_Node_Str" + r.intent.toString() + "String_Node_Str"+ r.callerPackage+ "String_Node_Str"+ r.callingPid+ "String_Node_Str"+ r.callingUid+ "String_Node_Str"+ "String_Node_Str"+ info.activityInfo.applicationInfo.uid+ "String_Node_Str"+ component.flattenToShortString());
      }
 else {
        Slog.w(TAG,"String_Node_Str" + r.intent.toString() + "String_Node_Str"+ r.callerPackage+ "String_Node_Str"+ r.callingPid+ "String_Node_Str"+ r.callingUid+ "String_Node_Str"+ "String_Node_Str"+ info.activityInfo.permission+ "String_Node_Str"+ component.flattenToShortString());
      }
      skip=true;
    }
 else     if (!skip && info.activityInfo.permission != null) {
      final int opCode=AppOpsManager.permissionToOpCode(info.activityInfo.permission);
      if (opCode != AppOpsManager.OP_NONE && mService.mAppOpsService.noteOperation(opCode,r.callingUid,r.callerPackage) != AppOpsManager.MODE_ALLOWED) {
        Slog.w(TAG,"String_Node_Str" + r.intent.toString() + "String_Node_Str"+ r.callerPackage+ "String_Node_Str"+ r.callingPid+ "String_Node_Str"+ r.callingUid+ "String_Node_Str"+ "String_Node_Str"+ AppOpsManager.permissionToOp(info.activityInfo.permission)+ "String_Node_Str"+ component.flattenToShortString());
        skip=true;
      }
    }
    if (!skip && info.activityInfo.applicationInfo.uid != Process.SYSTEM_UID && r.requiredPermissions != null && r.requiredPermissions.length > 0) {
      for (int i=0; i < r.requiredPermissions.length; i++) {
        String requiredPermission=r.requiredPermissions[i];
        try {
          perm=AppGlobals.getPackageManager().checkPermission(requiredPermission,info.activityInfo.applicationInfo.packageName,UserHandle.getUserId(info.activityInfo.applicationInfo.uid));
        }
 catch (        RemoteException e) {
          perm=PackageManager.PERMISSION_DENIED;
        }
        if (perm != PackageManager.PERMISSION_GRANTED) {
          Slog.w(TAG,"String_Node_Str" + r.intent + "String_Node_Str"+ component.flattenToShortString()+ "String_Node_Str"+ requiredPermission+ "String_Node_Str"+ r.callerPackage+ "String_Node_Str"+ r.callingUid+ "String_Node_Str");
          skip=true;
          break;
        }
        int appOp=AppOpsManager.permissionToOpCode(requiredPermission);
        if (appOp != AppOpsManager.OP_NONE && appOp != r.appOp && mService.mAppOpsService.noteOperation(appOp,info.activityInfo.applicationInfo.uid,info.activityInfo.packageName) != AppOpsManager.MODE_ALLOWED) {
          Slog.w(TAG,"String_Node_Str" + r.intent + "String_Node_Str"+ component.flattenToShortString()+ "String_Node_Str"+ AppOpsManager.permissionToOp(requiredPermission)+ "String_Node_Str"+ r.callerPackage+ "String_Node_Str"+ r.callingUid+ "String_Node_Str");
          skip=true;
          break;
        }
      }
    }
    if (!skip && r.appOp != AppOpsManager.OP_NONE && mService.mAppOpsService.noteOperation(r.appOp,info.activityInfo.applicationInfo.uid,info.activityInfo.packageName) != AppOpsManager.MODE_ALLOWED) {
      Slog.w(TAG,"String_Node_Str" + r.intent + "String_Node_Str"+ component.flattenToShortString()+ "String_Node_Str"+ AppOpsManager.opToName(r.appOp)+ "String_Node_Str"+ r.callerPackage+ "String_Node_Str"+ r.callingUid+ "String_Node_Str");
      skip=true;
    }
    if (!skip) {
      skip=!mService.mIntentFirewall.checkBroadcast(r.intent,r.callingUid,r.callingPid,r.resolvedType,info.activityInfo.applicationInfo.uid);
    }
    boolean isSingleton=false;
    try {
      isSingleton=mService.isSingleton(info.activityInfo.processName,info.activityInfo.applicationInfo,info.activityInfo.name,info.activityInfo.flags);
    }
 catch (    SecurityException e) {
      Slog.w(TAG,e.getMessage());
      skip=true;
    }
    if ((info.activityInfo.flags & ActivityInfo.FLAG_SINGLE_USER) != 0) {
      if (ActivityManager.checkUidPermission(android.Manifest.permission.INTERACT_ACROSS_USERS,info.activityInfo.applicationInfo.uid) != PackageManager.PERMISSION_GRANTED) {
        Slog.w(TAG,"String_Node_Str" + component.flattenToShortString() + "String_Node_Str"+ android.Manifest.permission.INTERACT_ACROSS_USERS);
        skip=true;
      }
    }
    if (!skip) {
      r.manifestCount++;
    }
 else {
      r.manifestSkipCount++;
    }
    if (r.curApp != null && r.curApp.crashing) {
      Slog.w(TAG,"String_Node_Str" + mQueueName + "String_Node_Str"+ r+ "String_Node_Str"+ r.curApp+ "String_Node_Str");
      skip=true;
    }
    if (!skip) {
      boolean isAvailable=false;
      try {
        isAvailable=AppGlobals.getPackageManager().isPackageAvailable(info.activityInfo.packageName,UserHandle.getUserId(info.activityInfo.applicationInfo.uid));
      }
 catch (      Exception e) {
        Slog.w(TAG,"String_Node_Str" + info.activityInfo.packageName,e);
      }
      if (!isAvailable) {
        if (DEBUG_BROADCAST)         Slog.v(TAG_BROADCAST,"String_Node_Str" + info.activityInfo.packageName + "String_Node_Str"+ info.activityInfo.applicationInfo.uid+ "String_Node_Str");
        skip=true;
      }
    }
    if (Build.PERMISSIONS_REVIEW_REQUIRED && !skip) {
      if (!requestStartTargetPermissionsReviewIfNeededLocked(r,info.activityInfo.packageName,UserHandle.getUserId(info.activityInfo.applicationInfo.uid))) {
        skip=true;
      }
    }
    final int receiverUid=info.activityInfo.applicationInfo.uid;
    if (r.callingUid != Process.SYSTEM_UID && isSingleton && mService.isValidSingletonCall(r.callingUid,receiverUid)) {
      info.activityInfo=mService.getActivityInfoForUser(info.activityInfo,0);
    }
    String targetProcess=info.activityInfo.processName;
    ProcessRecord app=mService.getProcessRecordLocked(targetProcess,info.activityInfo.applicationInfo.uid,false);
    if (!skip) {
      final int allowed=mService.checkAllowBackgroundLocked(info.activityInfo.applicationInfo.uid,info.activityInfo.packageName,-1,false);
      if (allowed != ActivityManager.APP_START_MODE_NORMAL) {
        if (allowed == ActivityManager.APP_START_MODE_DISABLED) {
          Slog.w(TAG,"String_Node_Str" + r.intent + "String_Node_Str"+ component.flattenToShortString());
          skip=true;
        }
 else         if (((r.intent.getFlags() & Intent.FLAG_RECEIVER_EXCLUDE_BACKGROUND) != 0) || (r.intent.getComponent() == null && r.intent.getPackage() == null && ((r.intent.getFlags() & Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND) == 0))) {
          Slog.w(TAG,"String_Node_Str" + r.intent + "String_Node_Str"+ component.flattenToShortString());
          skip=true;
        }
      }
    }
    if (skip) {
      if (DEBUG_BROADCAST)       Slog.v(TAG_BROADCAST,"String_Node_Str" + mQueueName + "String_Node_Str"+ r+ "String_Node_Str");
      r.delivery[recIdx]=BroadcastRecord.DELIVERY_SKIPPED;
      r.receiver=null;
      r.curFilter=null;
      r.state=BroadcastRecord.IDLE;
      scheduleBroadcastsLocked();
      return;
    }
    r.delivery[recIdx]=BroadcastRecord.DELIVERY_DELIVERED;
    r.state=BroadcastRecord.APP_RECEIVE;
    r.curComponent=component;
    r.curReceiver=info.activityInfo;
    if (DEBUG_MU && r.callingUid > UserHandle.PER_USER_RANGE) {
      Slog.v(TAG_MU,"String_Node_Str" + info.activityInfo + "String_Node_Str"+ r.callingUid+ "String_Node_Str"+ info.activityInfo.applicationInfo.uid);
    }
    if (brOptions != null && brOptions.getTemporaryAppWhitelistDuration() > 0) {
      scheduleTempWhitelistLocked(receiverUid,brOptions.getTemporaryAppWhitelistDuration(),r);
    }
    try {
      AppGlobals.getPackageManager().setPackageStoppedState(r.curComponent.getPackageName(),false,UserHandle.getUserId(r.callingUid));
    }
 catch (    RemoteException e) {
    }
catch (    IllegalArgumentException e) {
      Slog.w(TAG,"String_Node_Str" + r.curComponent.getPackageName() + "String_Node_Str"+ e);
    }
    if (app != null && app.thread != null) {
      try {
        app.addPackage(info.activityInfo.packageName,info.activityInfo.applicationInfo.versionCode,mService.mProcessStats);
        processCurBroadcastLocked(r,app);
        return;
      }
 catch (      RemoteException e) {
        Slog.w(TAG,"String_Node_Str" + r.curComponent,e);
      }
catch (      RuntimeException e) {
        Slog.wtf(TAG,"String_Node_Str" + r.curComponent + "String_Node_Str"+ r.intent,e);
        logBroadcastReceiverDiscardLocked(r);
        finishReceiverLocked(r,r.resultCode,r.resultData,r.resultExtras,r.resultAbort,false);
        scheduleBroadcastsLocked();
        r.state=BroadcastRecord.IDLE;
        return;
      }
    }
    if (DEBUG_BROADCAST)     Slog.v(TAG_BROADCAST,"String_Node_Str" + mQueueName + "String_Node_Str"+ targetProcess+ "String_Node_Str"+ r);
    if ((r.curApp=mService.startProcessLocked(targetProcess,info.activityInfo.applicationInfo,true,r.intent.getFlags() | Intent.FLAG_FROM_BACKGROUND,"String_Node_Str",r.curComponent,(r.intent.getFlags() & Intent.FLAG_RECEIVER_BOOT_UPGRADE) != 0,false,false)) == null) {
      Slog.w(TAG,"String_Node_Str" + info.activityInfo.applicationInfo.packageName + "String_Node_Str"+ info.activityInfo.applicationInfo.uid+ "String_Node_Str"+ r.intent+ "String_Node_Str");
      logBroadcastReceiverDiscardLocked(r);
      finishReceiverLocked(r,r.resultCode,r.resultData,r.resultExtras,r.resultAbort,false);
      scheduleBroadcastsLocked();
      r.state=BroadcastRecord.IDLE;
      return;
    }
    mPendingBroadcast=r;
    mPendingBroadcastRecvIndex=recIdx;
  }
}