Program: 32224
Project: 32224
Buggy source:
@Override public void onReceive(Context context,Intent intent){
  String action=intent.getAction();
  if (action.equalsIgnoreCase(Intent.ACTION_PACKAGE_ADDED) || action.equalsIgnoreCase(Intent.ACTION_PACKAGE_REPLACED)) {
    RouterServiceValidator.invalidateList(context);
    return;
  }
  if (!(action.equalsIgnoreCase(BOOT_COMPLETE) || action.equalsIgnoreCase(ACL_CONNECTED) || action.equalsIgnoreCase(STATE_CHANGED)|| action.equalsIgnoreCase(USBTransport.ACTION_USB_ACCESSORY_ATTACHED)|| action.equalsIgnoreCase(TransportConstants.START_ROUTER_SERVICE_ACTION))) {
    return;
  }
  if (action.equalsIgnoreCase(USBTransport.ACTION_USB_ACCESSORY_ATTACHED)) {
    Log.d(TAG,"String_Node_Str");
    intent.setAction(null);
    onSdlEnabled(context,intent);
    return;
  }
  boolean didStart=false;
  if (localRouterClass == null) {
    localRouterClass=defineLocalSdlRouterClass();
    ResolveInfo info=context.getPackageManager().resolveService(new Intent(context,localRouterClass),PackageManager.GET_META_DATA);
    if (info == null || info.serviceInfo.metaData == null || !info.serviceInfo.metaData.containsKey(context.getString(R.string.sdl_router_service_version_name))) {
      Log.w(TAG,"String_Node_Str");
    }
  }
  if (action.equalsIgnoreCase(TransportConstants.START_ROUTER_SERVICE_ACTION)) {
    if (intent.hasExtra(TransportConstants.START_ROUTER_SERVICE_SDL_ENABLED_EXTRA)) {
      if (intent.getBooleanExtra(TransportConstants.START_ROUTER_SERVICE_SDL_ENABLED_EXTRA,false)) {
        String packageName=intent.getStringExtra(TransportConstants.START_ROUTER_SERVICE_SDL_ENABLED_APP_PACKAGE);
        final ComponentName componentName=intent.getParcelableExtra(TransportConstants.START_ROUTER_SERVICE_SDL_ENABLED_CMP_NAME);
        if (componentName != null) {
          final Intent finalIntent=intent;
          final Context finalContext=context;
          RouterServiceValidator.createTrustedListRequest(context,false,new TrustedListCallback(){
            @Override public void onListObtained(            boolean successful){
              queuedService=componentName;
              finalIntent.setAction("String_Node_Str");
              onSdlEnabled(finalContext,finalIntent);
            }
          }
);
        }
      }
 else {
      }
      return;
    }
 else     if (intent.getBooleanExtra(TransportConstants.PING_ROUTER_SERVICE_EXTRA,false)) {
      boolean altServiceWake=intent.getBooleanExtra(TransportConstants.BIND_REQUEST_TYPE_ALT_TRANSPORT,false);
      didStart=wakeUpRouterService(context,false,altServiceWake);
    }
  }
  if (intent.getAction().contains("String_Node_Str")) {
    int state=intent.getIntExtra("String_Node_Str",-1);
    if (state == BluetoothAdapter.STATE_OFF || state == BluetoothAdapter.STATE_TURNING_OFF) {
      return;
    }
  }
  Log.d(TAG,"String_Node_Str");
  if (localRouterClass != null) {
    if (!didStart) {
      Log.d(TAG,"String_Node_Str");
      didStart=wakeUpRouterService(context,true,false);
    }
    Intent serviceIntent=new Intent(context,localRouterClass);
    SdlRouterService.LocalRouterService self=SdlRouterService.getLocalRouterService(serviceIntent,serviceIntent.getComponent());
    Intent restart=new Intent(SdlRouterService.REGISTER_NEWER_SERVER_INSTANCE_ACTION);
    restart.putExtra(LOCAL_ROUTER_SERVICE_EXTRA,self);
    restart.putExtra(LOCAL_ROUTER_SERVICE_DID_START_OWN,didStart);
    context.sendBroadcast(restart);
  }
}

Fixed version (ground truth):
@Override public void onReceive(Context context,Intent intent){
  String action=intent.getAction();
  if (action.equalsIgnoreCase(Intent.ACTION_PACKAGE_ADDED) || action.equalsIgnoreCase(Intent.ACTION_PACKAGE_REPLACED)) {
    RouterServiceValidator.invalidateList(context);
    return;
  }
  if (!(action.equalsIgnoreCase(BOOT_COMPLETE) || action.equalsIgnoreCase(ACL_CONNECTED) || action.equalsIgnoreCase(STATE_CHANGED)|| action.equalsIgnoreCase(USBTransport.ACTION_USB_ACCESSORY_ATTACHED)|| action.equalsIgnoreCase(TransportConstants.START_ROUTER_SERVICE_ACTION))) {
    return;
  }
  if (action.equalsIgnoreCase(USBTransport.ACTION_USB_ACCESSORY_ATTACHED)) {
    Log.d(TAG,"String_Node_Str");
    intent.setAction(null);
    onSdlEnabled(context,intent);
    return;
  }
  boolean didStart=false;
  if (localRouterClass == null) {
    localRouterClass=defineLocalSdlRouterClass();
    ResolveInfo info=context.getPackageManager().resolveService(new Intent(context,localRouterClass),PackageManager.GET_META_DATA);
    if (info != null) {
      if (info.filter == null || !info.filter.hasAction(TransportConstants.ROUTER_SERVICE_ACTION)) {
        Log.e(TAG,"String_Node_Str");
      }
      if (info.serviceInfo.metaData == null || !info.serviceInfo.metaData.containsKey(context.getString(R.string.sdl_router_service_version_name))) {
        Log.e(TAG,"String_Node_Str");
      }
    }
 else {
      Log.e(TAG,"String_Node_Str");
    }
  }
  if (action.equalsIgnoreCase(TransportConstants.START_ROUTER_SERVICE_ACTION)) {
    if (intent.hasExtra(TransportConstants.START_ROUTER_SERVICE_SDL_ENABLED_EXTRA)) {
      if (intent.getBooleanExtra(TransportConstants.START_ROUTER_SERVICE_SDL_ENABLED_EXTRA,false)) {
        String packageName=intent.getStringExtra(TransportConstants.START_ROUTER_SERVICE_SDL_ENABLED_APP_PACKAGE);
        final ComponentName componentName=intent.getParcelableExtra(TransportConstants.START_ROUTER_SERVICE_SDL_ENABLED_CMP_NAME);
        if (componentName != null) {
          final Intent finalIntent=intent;
          final Context finalContext=context;
          RouterServiceValidator.createTrustedListRequest(context,false,new TrustedListCallback(){
            @Override public void onListObtained(            boolean successful){
              queuedService=componentName;
              finalIntent.setAction("String_Node_Str");
              onSdlEnabled(finalContext,finalIntent);
            }
          }
);
        }
      }
 else {
      }
      return;
    }
 else     if (intent.getBooleanExtra(TransportConstants.PING_ROUTER_SERVICE_EXTRA,false)) {
      boolean altServiceWake=intent.getBooleanExtra(TransportConstants.BIND_REQUEST_TYPE_ALT_TRANSPORT,false);
      didStart=wakeUpRouterService(context,false,altServiceWake);
    }
  }
  if (intent.getAction().contains("String_Node_Str")) {
    int state=intent.getIntExtra("String_Node_Str",-1);
    if (state == BluetoothAdapter.STATE_OFF || state == BluetoothAdapter.STATE_TURNING_OFF) {
      return;
    }
  }
  Log.d(TAG,"String_Node_Str");
  if (localRouterClass != null) {
    if (!didStart) {
      Log.d(TAG,"String_Node_Str");
      didStart=wakeUpRouterService(context,true,false);
    }
    Intent serviceIntent=new Intent(context,localRouterClass);
    SdlRouterService.LocalRouterService self=SdlRouterService.getLocalRouterService(serviceIntent,serviceIntent.getComponent());
    Intent restart=new Intent(SdlRouterService.REGISTER_NEWER_SERVER_INSTANCE_ACTION);
    restart.putExtra(LOCAL_ROUTER_SERVICE_EXTRA,self);
    restart.putExtra(LOCAL_ROUTER_SERVICE_DID_START_OWN,didStart);
    context.sendBroadcast(restart);
  }
}