Program: 192217
Project: 192217
Buggy source:
@Override public void onStart(){
  final PackageManager pm=getContext().getPackageManager();
synchronized (this) {
    mLightEnabled=mDeepEnabled=getContext().getResources().getBoolean(com.android.internal.R.bool.config_enableAutoPowerModes);
    SystemConfig sysConfig=SystemConfig.getInstance();
    ArraySet<String> allowPowerExceptIdle=sysConfig.getAllowInPowerSaveExceptIdle();
    for (int i=0; i < allowPowerExceptIdle.size(); i++) {
      String pkg=allowPowerExceptIdle.valueAt(i);
      try {
        ApplicationInfo ai=pm.getApplicationInfo(pkg,PackageManager.MATCH_SYSTEM_ONLY);
        int appid=UserHandle.getAppId(ai.uid);
        mPowerSaveWhitelistAppsExceptIdle.put(ai.packageName,appid);
        mPowerSaveWhitelistSystemAppIdsExceptIdle.put(appid,true);
      }
 catch (      PackageManager.NameNotFoundException e) {
      }
    }
    ArraySet<String> allowPower=sysConfig.getAllowInPowerSave();
    for (int i=0; i < allowPower.size(); i++) {
      String pkg=allowPower.valueAt(i);
      try {
        ApplicationInfo ai=pm.getApplicationInfo(pkg,PackageManager.MATCH_SYSTEM_ONLY);
        int appid=UserHandle.getAppId(ai.uid);
        mPowerSaveWhitelistAppsExceptIdle.put(ai.packageName,appid);
        mPowerSaveWhitelistSystemAppIdsExceptIdle.put(appid,true);
        mPowerSaveWhitelistApps.put(ai.packageName,appid);
        mPowerSaveWhitelistSystemAppIds.put(appid,true);
      }
 catch (      PackageManager.NameNotFoundException e) {
      }
    }
    mConstants=new Constants(mHandler,getContext().getContentResolver());
    readConfigFileLocked();
    updateWhitelistAppIdsLocked();
    mScreenOn=true;
    mCharging=true;
    mState=STATE_ACTIVE;
    mLightState=LIGHT_STATE_ACTIVE;
    mInactiveTimeout=mConstants.INACTIVE_TIMEOUT;
  }
  mBinderService=new BinderService();
  publishBinderService(Context.DEVICE_IDLE_CONTROLLER,mBinderService);
  publishLocalService(LocalService.class,new LocalService());
}

Fixed version (ground truth):
@Override public void onStart(){
  final PackageManager pm=getContext().getPackageManager();
synchronized (this) {
    mLightEnabled=mDeepEnabled=getContext().getResources().getBoolean(com.android.internal.R.bool.config_enableAutoPowerModes);
    SystemConfig sysConfig=SystemConfig.getInstance();
    ArraySet<String> allowPowerExceptIdle=sysConfig.getAllowInPowerSaveExceptIdle();
    for (int i=0; i < allowPowerExceptIdle.size(); i++) {
      String pkg=allowPowerExceptIdle.valueAt(i);
      try {
        ApplicationInfo ai=pm.getApplicationInfo(pkg,PackageManager.MATCH_SYSTEM_ONLY);
        int appid=UserHandle.getAppId(ai.uid);
        mPowerSaveWhitelistAppsExceptIdle.put(ai.packageName,appid);
        mPowerSaveWhitelistSystemAppIdsExceptIdle.put(appid,true);
      }
 catch (      PackageManager.NameNotFoundException e) {
      }
    }
    ArraySet<String> allowPower=sysConfig.getAllowInPowerSave();
    for (int i=0; i < allowPower.size(); i++) {
      String pkg=allowPower.valueAt(i);
      try {
        ApplicationInfo ai=pm.getApplicationInfo(pkg,PackageManager.MATCH_SYSTEM_ONLY);
        int appid=UserHandle.getAppId(ai.uid);
        mPowerSaveWhitelistAppsExceptIdle.put(ai.packageName,appid);
        mPowerSaveWhitelistSystemAppIdsExceptIdle.put(appid,true);
        mPowerSaveWhitelistApps.put(ai.packageName,appid);
        mPowerSaveWhitelistSystemAppIds.put(appid,true);
      }
 catch (      PackageManager.NameNotFoundException e) {
      }
    }
    mConstants=new Constants(mHandler,getContext().getContentResolver());
    readConfigFileLocked();
    updateWhitelistAppIdsLocked();
    mNetworkConnected=true;
    mScreenOn=true;
    mCharging=true;
    mState=STATE_ACTIVE;
    mLightState=LIGHT_STATE_ACTIVE;
    mInactiveTimeout=mConstants.INACTIVE_TIMEOUT;
  }
  mBinderService=new BinderService();
  publishBinderService(Context.DEVICE_IDLE_CONTROLLER,mBinderService);
  publishLocalService(LocalService.class,new LocalService());
}