Program: 192370
Project: 192370
Buggy source:
private void deliverToRegisteredReceiverLocked(BroadcastRecord r,BroadcastFilter filter,boolean ordered,int index){
  boolean skip=false;
  if (filter.requiredPermission != null) {
    int perm=mService.checkComponentPermission(filter.requiredPermission,r.callingPid,r.callingUid,-1,true);
    if (perm != PackageManager.PERMISSION_GRANTED) {
      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"+ filter.requiredPermission+ "String_Node_Str"+ filter);
      skip=true;
    }
 else {
      final int opCode=AppOpsManager.permissionToOpCode(filter.requiredPermission);
      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(filter.requiredPermission)+ "String_Node_Str"+ filter);
        skip=true;
      }
    }
  }
  if (!skip && r.requiredPermissions != null && r.requiredPermissions.length > 0) {
    for (int i=0; i < r.requiredPermissions.length; i++) {
      String requiredPermission=r.requiredPermissions[i];
      int perm=mService.checkComponentPermission(requiredPermission,filter.receiverList.pid,filter.receiverList.uid,-1,true);
      if (perm != PackageManager.PERMISSION_GRANTED) {
        Slog.w(TAG,"String_Node_Str" + r.intent.toString() + "String_Node_Str"+ filter.receiverList.app+ "String_Node_Str"+ filter.receiverList.pid+ "String_Node_Str"+ filter.receiverList.uid+ "String_Node_Str"+ "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,filter.receiverList.uid,filter.packageName) != AppOpsManager.MODE_ALLOWED) {
        Slog.w(TAG,"String_Node_Str" + r.intent.toString() + "String_Node_Str"+ filter.receiverList.app+ "String_Node_Str"+ filter.receiverList.pid+ "String_Node_Str"+ filter.receiverList.uid+ "String_Node_Str"+ "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.requiredPermissions == null || r.requiredPermissions.length == 0)) {
    int perm=mService.checkComponentPermission(null,filter.receiverList.pid,filter.receiverList.uid,-1,true);
    if (perm != PackageManager.PERMISSION_GRANTED) {
      Slog.w(TAG,"String_Node_Str" + r.intent.toString() + "String_Node_Str"+ filter.receiverList.app+ "String_Node_Str"+ filter.receiverList.pid+ "String_Node_Str"+ filter.receiverList.uid+ "String_Node_Str"+ "String_Node_Str"+ r.callerPackage+ "String_Node_Str"+ r.callingUid+ "String_Node_Str");
      skip=true;
    }
  }
  if (!skip && r.appOp != AppOpsManager.OP_NONE && mService.mAppOpsService.noteOperation(r.appOp,filter.receiverList.uid,filter.packageName) != AppOpsManager.MODE_ALLOWED) {
    Slog.w(TAG,"String_Node_Str" + r.intent.toString() + "String_Node_Str"+ filter.receiverList.app+ "String_Node_Str"+ filter.receiverList.pid+ "String_Node_Str"+ filter.receiverList.uid+ "String_Node_Str"+ "String_Node_Str"+ AppOpsManager.opToName(r.appOp)+ "String_Node_Str"+ r.callerPackage+ "String_Node_Str"+ r.callingUid+ "String_Node_Str");
    skip=true;
  }
  if (!skip) {
    final int allowed=mService.checkAllowBackgroundLocked(filter.receiverList.uid,filter.packageName,-1);
    if (allowed == ActivityManager.APP_START_MODE_DISABLED) {
      Slog.w(TAG,"String_Node_Str" + r.intent + "String_Node_Str"+ filter.receiverList.app+ "String_Node_Str"+ filter.receiverList.pid+ "String_Node_Str"+ filter.receiverList.uid+ "String_Node_Str");
      skip=true;
    }
  }
  if (!mService.mIntentFirewall.checkBroadcast(r.intent,r.callingUid,r.callingPid,r.resolvedType,filter.receiverList.uid)) {
    skip=true;
  }
  if (!skip && (filter.receiverList.app == null || filter.receiverList.app.crashing)) {
    Slog.w(TAG,"String_Node_Str" + mQueueName + "String_Node_Str"+ r+ "String_Node_Str"+ filter.receiverList+ "String_Node_Str");
    skip=true;
  }
  if (skip) {
    r.delivery[index]=BroadcastRecord.DELIVERY_SKIPPED;
    return;
  }
  if (Build.PERMISSIONS_REVIEW_REQUIRED) {
    if (!requestStartTargetPermissionsReviewIfNeededLocked(r,filter.packageName,filter.owningUserId)) {
      r.delivery[index]=BroadcastRecord.DELIVERY_SKIPPED;
      return;
    }
  }
  r.delivery[index]=BroadcastRecord.DELIVERY_DELIVERED;
  if (ordered) {
    r.receiver=filter.receiverList.receiver.asBinder();
    r.curFilter=filter;
    filter.receiverList.curBroadcast=r;
    r.state=BroadcastRecord.CALL_IN_RECEIVE;
    if (filter.receiverList.app != null) {
      r.curApp=filter.receiverList.app;
      filter.receiverList.app.curReceiver=r;
      mService.updateOomAdjLocked(r.curApp);
    }
  }
  try {
    if (DEBUG_BROADCAST_LIGHT)     Slog.i(TAG_BROADCAST,"String_Node_Str" + filter + "String_Node_Str"+ r);
    performReceiveLocked(filter.receiverList.app,filter.receiverList.receiver,new Intent(r.intent),r.resultCode,r.resultData,r.resultExtras,r.ordered,r.initialSticky,r.userId);
    if (ordered) {
      r.state=BroadcastRecord.CALL_DONE_RECEIVE;
    }
  }
 catch (  RemoteException e) {
    Slog.w(TAG,"String_Node_Str" + r.intent,e);
    if (ordered) {
      r.receiver=null;
      r.curFilter=null;
      filter.receiverList.curBroadcast=null;
      if (filter.receiverList.app != null) {
        filter.receiverList.app.curReceiver=null;
      }
    }
  }
}

Fixed version (ground truth):
private void deliverToRegisteredReceiverLocked(BroadcastRecord r,BroadcastFilter filter,boolean ordered,int index){
  boolean skip=false;
  if (filter.requiredPermission != null) {
    int perm=mService.checkComponentPermission(filter.requiredPermission,r.callingPid,r.callingUid,-1,true);
    if (perm != PackageManager.PERMISSION_GRANTED) {
      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"+ filter.requiredPermission+ "String_Node_Str"+ filter);
      skip=true;
    }
 else {
      final int opCode=AppOpsManager.permissionToOpCode(filter.requiredPermission);
      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(filter.requiredPermission)+ "String_Node_Str"+ filter);
        skip=true;
      }
    }
  }
  if (!skip && r.requiredPermissions != null && r.requiredPermissions.length > 0) {
    for (int i=0; i < r.requiredPermissions.length; i++) {
      String requiredPermission=r.requiredPermissions[i];
      int perm=mService.checkComponentPermission(requiredPermission,filter.receiverList.pid,filter.receiverList.uid,-1,true);
      if (perm != PackageManager.PERMISSION_GRANTED) {
        Slog.w(TAG,"String_Node_Str" + r.intent.toString() + "String_Node_Str"+ filter.receiverList.app+ "String_Node_Str"+ filter.receiverList.pid+ "String_Node_Str"+ filter.receiverList.uid+ "String_Node_Str"+ "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,filter.receiverList.uid,filter.packageName) != AppOpsManager.MODE_ALLOWED) {
        Slog.w(TAG,"String_Node_Str" + r.intent.toString() + "String_Node_Str"+ filter.receiverList.app+ "String_Node_Str"+ filter.receiverList.pid+ "String_Node_Str"+ filter.receiverList.uid+ "String_Node_Str"+ "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.requiredPermissions == null || r.requiredPermissions.length == 0)) {
    int perm=mService.checkComponentPermission(null,filter.receiverList.pid,filter.receiverList.uid,-1,true);
    if (perm != PackageManager.PERMISSION_GRANTED) {
      Slog.w(TAG,"String_Node_Str" + r.intent.toString() + "String_Node_Str"+ filter.receiverList.app+ "String_Node_Str"+ filter.receiverList.pid+ "String_Node_Str"+ filter.receiverList.uid+ "String_Node_Str"+ "String_Node_Str"+ r.callerPackage+ "String_Node_Str"+ r.callingUid+ "String_Node_Str");
      skip=true;
    }
  }
  if (!skip && r.appOp != AppOpsManager.OP_NONE && mService.mAppOpsService.noteOperation(r.appOp,filter.receiverList.uid,filter.packageName) != AppOpsManager.MODE_ALLOWED) {
    Slog.w(TAG,"String_Node_Str" + r.intent.toString() + "String_Node_Str"+ filter.receiverList.app+ "String_Node_Str"+ filter.receiverList.pid+ "String_Node_Str"+ filter.receiverList.uid+ "String_Node_Str"+ "String_Node_Str"+ AppOpsManager.opToName(r.appOp)+ "String_Node_Str"+ r.callerPackage+ "String_Node_Str"+ r.callingUid+ "String_Node_Str");
    skip=true;
  }
  if (!skip) {
    final int allowed=mService.checkAllowBackgroundLocked(filter.receiverList.uid,filter.packageName,-1,true);
    if (allowed == ActivityManager.APP_START_MODE_DISABLED) {
      Slog.w(TAG,"String_Node_Str" + r.intent + "String_Node_Str"+ filter.receiverList.app+ "String_Node_Str"+ filter.receiverList.pid+ "String_Node_Str"+ filter.receiverList.uid+ "String_Node_Str");
      skip=true;
    }
  }
  if (!mService.mIntentFirewall.checkBroadcast(r.intent,r.callingUid,r.callingPid,r.resolvedType,filter.receiverList.uid)) {
    skip=true;
  }
  if (!skip && (filter.receiverList.app == null || filter.receiverList.app.crashing)) {
    Slog.w(TAG,"String_Node_Str" + mQueueName + "String_Node_Str"+ r+ "String_Node_Str"+ filter.receiverList+ "String_Node_Str");
    skip=true;
  }
  if (skip) {
    r.delivery[index]=BroadcastRecord.DELIVERY_SKIPPED;
    return;
  }
  if (Build.PERMISSIONS_REVIEW_REQUIRED) {
    if (!requestStartTargetPermissionsReviewIfNeededLocked(r,filter.packageName,filter.owningUserId)) {
      r.delivery[index]=BroadcastRecord.DELIVERY_SKIPPED;
      return;
    }
  }
  r.delivery[index]=BroadcastRecord.DELIVERY_DELIVERED;
  if (ordered) {
    r.receiver=filter.receiverList.receiver.asBinder();
    r.curFilter=filter;
    filter.receiverList.curBroadcast=r;
    r.state=BroadcastRecord.CALL_IN_RECEIVE;
    if (filter.receiverList.app != null) {
      r.curApp=filter.receiverList.app;
      filter.receiverList.app.curReceiver=r;
      mService.updateOomAdjLocked(r.curApp);
    }
  }
  try {
    if (DEBUG_BROADCAST_LIGHT)     Slog.i(TAG_BROADCAST,"String_Node_Str" + filter + "String_Node_Str"+ r);
    performReceiveLocked(filter.receiverList.app,filter.receiverList.receiver,new Intent(r.intent),r.resultCode,r.resultData,r.resultExtras,r.ordered,r.initialSticky,r.userId);
    if (ordered) {
      r.state=BroadcastRecord.CALL_DONE_RECEIVE;
    }
  }
 catch (  RemoteException e) {
    Slog.w(TAG,"String_Node_Str" + r.intent,e);
    if (ordered) {
      r.receiver=null;
      r.curFilter=null;
      filter.receiverList.curBroadcast=null;
      if (filter.receiverList.app != null) {
        filter.receiverList.app.curReceiver=null;
      }
    }
  }
}