nus-yam/ex-repair huggingface dataset:
Program: 194489
Project: 194489
Buggy source:
@SmallTest public void testIpAddress() throws Exception {
  byte[] slash11Netmask=new byte[]{(byte)0xff,(byte)0xe0,0x00,0x00};
  byte[] slash24Netmask=new byte[]{(byte)0xff,(byte)0xff,(byte)0xff,0x00};
  byte[] invalidNetmask=new byte[]{(byte)0xff,(byte)0xfb,(byte)0xff,0x00};
  Inet4Address example1=(Inet4Address)NetworkUtils.numericToInetAddress("String_Node_Str");
  Inet4Address example2=(Inet4Address)NetworkUtils.numericToInetAddress("String_Node_Str");
  checkIpAddress(null,ANY,ANY,slash24Netmask);
  checkIpAddress("String_Node_Str",example2,example1,slash24Netmask);
  checkIpAddress("String_Node_Str",example2,ANY,slash11Netmask);
  checkIpAddress("String_Node_Str",ANY,example2,slash11Netmask);
  checkIpAddress(null,example2,ANY,invalidNetmask);
  checkIpAddress("String_Node_Str",ANY,example2,null);
}

Fixed version (ground truth):
@SmallTest public void testIpAddress() throws Exception {
  byte[] slash11Netmask=new byte[]{(byte)0xff,(byte)0xe0,0x00,0x00};
  byte[] slash24Netmask=new byte[]{(byte)0xff,(byte)0xff,(byte)0xff,0x00};
  byte[] invalidNetmask=new byte[]{(byte)0xff,(byte)0xfb,(byte)0xff,0x00};
  Inet4Address example1=v4Address("String_Node_Str");
  Inet4Address example2=v4Address("String_Node_Str");
  checkIpAddress(null,ANY,ANY,slash24Netmask);
  checkIpAddress("String_Node_Str",example2,example1,slash24Netmask);
  checkIpAddress("String_Node_Str",example2,ANY,slash11Netmask);
  checkIpAddress("String_Node_Str",ANY,example2,slash11Netmask);
  checkIpAddress(null,example2,ANY,invalidNetmask);
  checkIpAddress("String_Node_Str",ANY,example2,null);
}
Program: 194490
Project: 194490
Buggy source:
private void assertDomainAndVendorInfoParses(String expectedDomain,byte[] domainBytes,String expectedVendorInfo,byte[] vendorInfoBytes){
  ByteBuffer packet=new TestDhcpPacket(DHCP_MESSAGE_TYPE_OFFER).setDomainBytes(domainBytes).setVendorInfoBytes(vendorInfoBytes).build();
  DhcpPacket offerPacket=DhcpPacket.decodeFullPacket(packet,ENCAP_BOOTP);
  assertEquals(expectedDomain,offerPacket.mDomainName);
  assertEquals(expectedVendorInfo,offerPacket.mVendorId);
}

Fixed version (ground truth):
private void assertDomainAndVendorInfoParses(String expectedDomain,byte[] domainBytes,String expectedVendorInfo,byte[] vendorInfoBytes){
  ByteBuffer packet=new TestDhcpPacket(DHCP_MESSAGE_TYPE_OFFER).setDomainBytes(domainBytes).setVendorInfoBytes(vendorInfoBytes).build();
  DhcpPacket offerPacket=DhcpPacket.decodeFullPacket(packet,ENCAP_BOOTP);
  assertEquals(expectedDomain,offerPacket.mDomainName);
  assertEquals(expectedVendorInfo,offerPacket.mVendorInfo);
}
Program: 194491
Project: 194491
Buggy source:
public void finishPacket(ByteBuffer buffer){
  addTlv(buffer,DHCP_MESSAGE_TYPE,mType);
  if (mDomainBytes != null) {
    addTlv(buffer,DHCP_DOMAIN_NAME,mDomainBytes);
  }
  if (mVendorInfoBytes != null) {
    addTlv(buffer,DHCP_VENDOR_CLASS_ID,mVendorInfoBytes);
  }
  if (mLeaseTimeBytes != null) {
    addTlv(buffer,DHCP_LEASE_TIME,mLeaseTimeBytes);
  }
  if (mNetmaskBytes != null) {
    addTlv(buffer,DHCP_SUBNET_MASK,mNetmaskBytes);
  }
  addTlvEnd(buffer);
}

Fixed version (ground truth):
public void finishPacket(ByteBuffer buffer){
  addTlv(buffer,DHCP_MESSAGE_TYPE,mType);
  if (mDomainBytes != null) {
    addTlv(buffer,DHCP_DOMAIN_NAME,mDomainBytes);
  }
  if (mVendorInfoBytes != null) {
    addTlv(buffer,DHCP_VENDOR_INFO,mVendorInfoBytes);
  }
  if (mLeaseTimeBytes != null) {
    addTlv(buffer,DHCP_LEASE_TIME,mLeaseTimeBytes);
  }
  if (mNetmaskBytes != null) {
    addTlv(buffer,DHCP_SUBNET_MASK,mNetmaskBytes);
  }
  addTlvEnd(buffer);
}
Program: 194492
Project: 194492
Buggy source:
/** 
 * Construct a DhcpResults object from a DHCP reply packet.
 */
public DhcpResults toDhcpResults(){
  Inet4Address ipAddress=mYourIp;
  if (ipAddress.equals(Inet4Address.ANY)) {
    ipAddress=mClientIp;
    if (ipAddress.equals(Inet4Address.ANY)) {
      return null;
    }
  }
  int prefixLength;
  if (mSubnetMask != null) {
    try {
      prefixLength=NetworkUtils.netmaskToPrefixLength(mSubnetMask);
    }
 catch (    IllegalArgumentException e) {
      return null;
    }
  }
 else {
    prefixLength=NetworkUtils.getImplicitNetmask(ipAddress);
  }
  DhcpResults results=new DhcpResults();
  try {
    results.ipAddress=new LinkAddress(ipAddress,prefixLength);
  }
 catch (  IllegalArgumentException e) {
    return null;
  }
  results.gateway=mGateway;
  results.dnsServers.addAll(mDnsServers);
  results.domains=mDomainName;
  results.serverAddress=mServerIdentifier;
  results.vendorInfo=mVendorId;
  results.leaseDuration=(mLeaseTime != null) ? mLeaseTime : INFINITE_LEASE;
  return results;
}

Fixed version (ground truth):
/** 
 * Construct a DhcpResults object from a DHCP reply packet.
 */
public DhcpResults toDhcpResults(){
  Inet4Address ipAddress=mYourIp;
  if (ipAddress.equals(Inet4Address.ANY)) {
    ipAddress=mClientIp;
    if (ipAddress.equals(Inet4Address.ANY)) {
      return null;
    }
  }
  int prefixLength;
  if (mSubnetMask != null) {
    try {
      prefixLength=NetworkUtils.netmaskToPrefixLength(mSubnetMask);
    }
 catch (    IllegalArgumentException e) {
      return null;
    }
  }
 else {
    prefixLength=NetworkUtils.getImplicitNetmask(ipAddress);
  }
  DhcpResults results=new DhcpResults();
  try {
    results.ipAddress=new LinkAddress(ipAddress,prefixLength);
  }
 catch (  IllegalArgumentException e) {
    return null;
  }
  results.gateway=mGateway;
  results.dnsServers.addAll(mDnsServers);
  results.domains=mDomainName;
  results.serverAddress=mServerIdentifier;
  results.vendorInfo=mVendorInfo;
  results.leaseDuration=(mLeaseTime != null) ? mLeaseTime : INFINITE_LEASE;
  return results;
}
Program: 194493
Project: 194493
Buggy source:
@SmallTest public void testIpAddress() throws Exception {
  byte[] slash11Netmask=new byte[]{(byte)0xff,(byte)0xe0,0x00,0x00};
  byte[] slash24Netmask=new byte[]{(byte)0xff,(byte)0xff,(byte)0xff,0x00};
  byte[] invalidNetmask=new byte[]{(byte)0xff,(byte)0xfb,(byte)0xff,0x00};
  Inet4Address example1=(Inet4Address)NetworkUtils.numericToInetAddress("String_Node_Str");
  Inet4Address example2=(Inet4Address)NetworkUtils.numericToInetAddress("String_Node_Str");
  checkIpAddress(null,ANY,ANY,slash24Netmask);
  checkIpAddress("String_Node_Str",example2,example1,slash24Netmask);
  checkIpAddress("String_Node_Str",example2,ANY,slash11Netmask);
  checkIpAddress("String_Node_Str",ANY,example2,slash11Netmask);
  checkIpAddress(null,example2,ANY,invalidNetmask);
  checkIpAddress("String_Node_Str",ANY,example2,null);
}

Fixed version (ground truth):
@SmallTest public void testIpAddress() throws Exception {
  byte[] slash11Netmask=new byte[]{(byte)0xff,(byte)0xe0,0x00,0x00};
  byte[] slash24Netmask=new byte[]{(byte)0xff,(byte)0xff,(byte)0xff,0x00};
  byte[] invalidNetmask=new byte[]{(byte)0xff,(byte)0xfb,(byte)0xff,0x00};
  Inet4Address example1=v4Address("String_Node_Str");
  Inet4Address example2=v4Address("String_Node_Str");
  checkIpAddress(null,ANY,ANY,slash24Netmask);
  checkIpAddress("String_Node_Str",example2,example1,slash24Netmask);
  checkIpAddress("String_Node_Str",example2,ANY,slash11Netmask);
  checkIpAddress("String_Node_Str",ANY,example2,slash11Netmask);
  checkIpAddress(null,example2,ANY,invalidNetmask);
  checkIpAddress("String_Node_Str",ANY,example2,null);
}
Program: 194494
Project: 194494
Buggy source:
private void assertDomainAndVendorInfoParses(String expectedDomain,byte[] domainBytes,String expectedVendorInfo,byte[] vendorInfoBytes){
  ByteBuffer packet=new TestDhcpPacket(DHCP_MESSAGE_TYPE_OFFER).setDomainBytes(domainBytes).setVendorInfoBytes(vendorInfoBytes).build();
  DhcpPacket offerPacket=DhcpPacket.decodeFullPacket(packet,ENCAP_BOOTP);
  assertEquals(expectedDomain,offerPacket.mDomainName);
  assertEquals(expectedVendorInfo,offerPacket.mVendorId);
}

Fixed version (ground truth):
private void assertDomainAndVendorInfoParses(String expectedDomain,byte[] domainBytes,String expectedVendorInfo,byte[] vendorInfoBytes){
  ByteBuffer packet=new TestDhcpPacket(DHCP_MESSAGE_TYPE_OFFER).setDomainBytes(domainBytes).setVendorInfoBytes(vendorInfoBytes).build();
  DhcpPacket offerPacket=DhcpPacket.decodeFullPacket(packet,ENCAP_BOOTP);
  assertEquals(expectedDomain,offerPacket.mDomainName);
  assertEquals(expectedVendorInfo,offerPacket.mVendorInfo);
}
Program: 194495
Project: 194495
Buggy source:
public void finishPacket(ByteBuffer buffer){
  addTlv(buffer,DHCP_MESSAGE_TYPE,mType);
  if (mDomainBytes != null) {
    addTlv(buffer,DHCP_DOMAIN_NAME,mDomainBytes);
  }
  if (mVendorInfoBytes != null) {
    addTlv(buffer,DHCP_VENDOR_CLASS_ID,mVendorInfoBytes);
  }
  if (mLeaseTimeBytes != null) {
    addTlv(buffer,DHCP_LEASE_TIME,mLeaseTimeBytes);
  }
  if (mNetmaskBytes != null) {
    addTlv(buffer,DHCP_SUBNET_MASK,mNetmaskBytes);
  }
  addTlvEnd(buffer);
}

Fixed version (ground truth):
public void finishPacket(ByteBuffer buffer){
  addTlv(buffer,DHCP_MESSAGE_TYPE,mType);
  if (mDomainBytes != null) {
    addTlv(buffer,DHCP_DOMAIN_NAME,mDomainBytes);
  }
  if (mVendorInfoBytes != null) {
    addTlv(buffer,DHCP_VENDOR_INFO,mVendorInfoBytes);
  }
  if (mLeaseTimeBytes != null) {
    addTlv(buffer,DHCP_LEASE_TIME,mLeaseTimeBytes);
  }
  if (mNetmaskBytes != null) {
    addTlv(buffer,DHCP_SUBNET_MASK,mNetmaskBytes);
  }
  addTlvEnd(buffer);
}
Program: 194496
Project: 194496
Buggy source:
/** 
 * Adds an app to the temporary whitelist and resets the endTime for granting the app an exemption to access network and acquire wakelocks.
 */
public void addPowerSaveTempWhitelistAppDirectInternal(int appId,long duration){
  final long timeNow=SystemClock.elapsedRealtime();
synchronized (this) {
    duration=Math.min(duration,mConstants.MAX_TEMP_APP_WHITELIST_DURATION);
    long currentEndTime=mTempWhitelistAppIdEndTimes.get(appId);
    mTempWhitelistAppIdEndTimes.put(appId,timeNow + duration);
    if (DEBUG) {
      Slog.d(TAG,"String_Node_Str" + appId + "String_Node_Str");
    }
    if (currentEndTime == 0) {
      postTempActiveTimeoutMessage(appId,duration);
      updateTempWhitelistAppIdsLocked();
      reportTempWhitelistChangedLocked();
    }
  }
}

Fixed version (ground truth):
/** 
 * Adds an app to the temporary whitelist and resets the endTime for granting the app an exemption to access network and acquire wakelocks.
 */
public void addPowerSaveTempWhitelistAppDirectInternal(int callingUid,int appId,long duration){
  final long timeNow=SystemClock.elapsedRealtime();
synchronized (this) {
    int callingAppId=UserHandle.getAppId(callingUid);
    if (callingAppId >= Process.FIRST_APPLICATION_UID) {
      if (!mPowerSaveWhitelistSystemAppIds.get(callingAppId)) {
        throw new SecurityException("String_Node_Str" + UserHandle.formatUid(callingUid) + "String_Node_Str");
      }
    }
    duration=Math.min(duration,mConstants.MAX_TEMP_APP_WHITELIST_DURATION);
    long currentEndTime=mTempWhitelistAppIdEndTimes.get(appId);
    mTempWhitelistAppIdEndTimes.put(appId,timeNow + duration);
    if (DEBUG) {
      Slog.d(TAG,"String_Node_Str" + appId + "String_Node_Str");
    }
    if (currentEndTime == 0) {
      postTempActiveTimeoutMessage(appId,duration);
      updateTempWhitelistAppIdsLocked();
      reportTempWhitelistChangedLocked();
    }
  }
}
Program: 194497
Project: 194497
Buggy source:
@Override public void onStart(){
  final PackageManager pm=getContext().getPackageManager();
synchronized (this) {
    mEnabled=getContext().getResources().getBoolean(com.android.internal.R.bool.config_enableAutoPowerModes);
    SystemConfig sysConfig=SystemConfig.getInstance();
    ArraySet<String> allowPower=sysConfig.getAllowInPowerSave();
    for (int i=0; i < allowPower.size(); i++) {
      String pkg=allowPower.valueAt(i);
      try {
        ApplicationInfo ai=pm.getApplicationInfo(pkg,0);
        if ((ai.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
          mPowerSaveWhitelistApps.put(ai.packageName,UserHandle.getAppId(ai.uid));
        }
      }
 catch (      PackageManager.NameNotFoundException e) {
      }
    }
    mConstants=new Constants(mHandler,getContext().getContentResolver());
    readConfigFileLocked();
    updateWhitelistAppIdsLocked();
    mScreenOn=true;
    mCharging=true;
    mState=STATE_ACTIVE;
    mInactiveTimeout=mConstants.INACTIVE_TIMEOUT;
  }
  publishBinderService(Context.DEVICE_IDLE_CONTROLLER,new BinderService());
  publishLocalService(LocalService.class,new LocalService());
}

Fixed version (ground truth):
@Override public void onStart(){
  final PackageManager pm=getContext().getPackageManager();
synchronized (this) {
    mEnabled=getContext().getResources().getBoolean(com.android.internal.R.bool.config_enableAutoPowerModes);
    SystemConfig sysConfig=SystemConfig.getInstance();
    ArraySet<String> allowPower=sysConfig.getAllowInPowerSave();
    for (int i=0; i < allowPower.size(); i++) {
      String pkg=allowPower.valueAt(i);
      try {
        ApplicationInfo ai=pm.getApplicationInfo(pkg,0);
        if ((ai.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
          int appid=UserHandle.getAppId(ai.uid);
          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;
    mInactiveTimeout=mConstants.INACTIVE_TIMEOUT;
  }
  publishBinderService(Context.DEVICE_IDLE_CONTROLLER,new BinderService());
  publishLocalService(LocalService.class,new LocalService());
}
Program: 194498
Project: 194498
Buggy source:
private void updateWhitelistAppIdsLocked(){
  mPowerSaveWhitelistAppIds.clear();
  for (int i=0; i < mPowerSaveWhitelistApps.size(); i++) {
    mPowerSaveWhitelistAppIds.put(mPowerSaveWhitelistApps.valueAt(i),true);
  }
  for (int i=0; i < mPowerSaveWhitelistUserApps.size(); i++) {
    mPowerSaveWhitelistAppIds.put(mPowerSaveWhitelistUserApps.valueAt(i),true);
  }
  int size=mPowerSaveWhitelistAppIds.size();
  int[] appids=new int[size];
  for (int i=0; i < size; i++) {
    appids[i]=mPowerSaveWhitelistAppIds.keyAt(i);
  }
  mPowerSaveWhitelistAppIdArray=appids;
  if (mLocalPowerManager != null) {
    if (DEBUG) {
      Slog.d(TAG,"String_Node_Str" + Arrays.toString(mPowerSaveWhitelistAppIdArray));
    }
    mLocalPowerManager.setDeviceIdleWhitelist(mPowerSaveWhitelistAppIdArray);
  }
}

Fixed version (ground truth):
private void updateWhitelistAppIdsLocked(){
  mPowerSaveWhitelistAllAppIds.clear();
  for (int i=0; i < mPowerSaveWhitelistApps.size(); i++) {
    mPowerSaveWhitelistAllAppIds.put(mPowerSaveWhitelistApps.valueAt(i),true);
  }
  for (int i=0; i < mPowerSaveWhitelistUserApps.size(); i++) {
    mPowerSaveWhitelistAllAppIds.put(mPowerSaveWhitelistUserApps.valueAt(i),true);
  }
  int size=mPowerSaveWhitelistAllAppIds.size();
  int[] appids=new int[size];
  for (int i=0; i < size; i++) {
    appids[i]=mPowerSaveWhitelistAllAppIds.keyAt(i);
  }
  mPowerSaveWhitelistAllAppIdArray=appids;
  if (mLocalPowerManager != null) {
    if (DEBUG) {
      Slog.d(TAG,"String_Node_Str" + Arrays.toString(mPowerSaveWhitelistAllAppIdArray));
    }
    mLocalPowerManager.setDeviceIdleWhitelist(mPowerSaveWhitelistAllAppIdArray);
  }
}
Program: 194499
Project: 194499
Buggy source:
/** 
 * Adds an app to the temporary whitelist and resets the endTime for granting the app an exemption to access network and acquire wakelocks.
 */
public void addPowerSaveTempWhitelistAppInternal(String packageName,long duration,int userId){
  try {
    int uid=getContext().getPackageManager().getPackageUid(packageName,userId);
    int appId=UserHandle.getAppId(uid);
    addPowerSaveTempWhitelistAppDirectInternal(appId,duration);
  }
 catch (  NameNotFoundException e) {
  }
}

Fixed version (ground truth):
/** 
 * Adds an app to the temporary whitelist and resets the endTime for granting the app an exemption to access network and acquire wakelocks.
 */
public void addPowerSaveTempWhitelistAppInternal(int callingUid,String packageName,long duration,int userId){
  try {
    int uid=getContext().getPackageManager().getPackageUid(packageName,userId);
    int appId=UserHandle.getAppId(uid);
    addPowerSaveTempWhitelistAppDirectInternal(callingUid,appId,duration);
  }
 catch (  NameNotFoundException e) {
  }
}
Program: 194500
Project: 194500
Buggy source:
public int[] getAppIdWhitelistInternal(){
synchronized (this) {
    return mPowerSaveWhitelistAppIdArray;
  }
}

Fixed version (ground truth):
public int[] getAppIdWhitelistInternal(){
synchronized (this) {
    return mPowerSaveWhitelistAllAppIdArray;
  }
}
Program: 194503
Project: 194503
Buggy source:
@Override public void handleMessage(Message msg){
  if (DEBUG)   Slog.d(TAG,"String_Node_Str" + msg.what + "String_Node_Str");
switch (msg.what) {
case MSG_WRITE_CONFIG:
{
      handleWriteConfigFile();
    }
  break;
case MSG_REPORT_IDLE_ON:
{
  mLocalPowerManager.setDeviceIdleMode(true);
  try {
    mNetworkPolicyManager.setDeviceIdleMode(true);
    mBatteryStats.noteDeviceIdleMode(true,null,Process.myUid());
  }
 catch (  RemoteException e) {
  }
  getContext().sendBroadcastAsUser(mIdleIntent,UserHandle.ALL);
}
break;
case MSG_REPORT_IDLE_OFF:
{
mLocalPowerManager.setDeviceIdleMode(false);
try {
mNetworkPolicyManager.setDeviceIdleMode(false);
mBatteryStats.noteDeviceIdleMode(false,null,Process.myUid());
}
 catch (RemoteException e) {
}
getContext().sendBroadcastAsUser(mIdleIntent,UserHandle.ALL);
}
break;
case MSG_REPORT_ACTIVE:
{
String activeReason=(String)msg.obj;
int activeUid=msg.arg1;
boolean needBroadcast=msg.arg2 != 0;
mLocalPowerManager.setDeviceIdleMode(false);
try {
mNetworkPolicyManager.setDeviceIdleMode(false);
mBatteryStats.noteDeviceIdleMode(false,activeReason,activeUid);
}
 catch (RemoteException e) {
}
if (needBroadcast) {
getContext().sendBroadcastAsUser(mIdleIntent,UserHandle.ALL);
}
}
break;
case MSG_TEMP_APP_WHITELIST_TIMEOUT:
{
int uid=msg.arg1;
checkTempAppWhitelistTimeout(uid);
}
break;
}
}

Fixed version (ground truth):
@Override public void handleMessage(Message msg){
  if (DEBUG)   Slog.d(TAG,"String_Node_Str" + msg.what + "String_Node_Str");
switch (msg.what) {
case MSG_WRITE_CONFIG:
{
      handleWriteConfigFile();
    }
  break;
case MSG_REPORT_IDLE_ON:
{
  EventLogTags.writeDeviceIdleOnStart();
  mLocalPowerManager.setDeviceIdleMode(true);
  try {
    mNetworkPolicyManager.setDeviceIdleMode(true);
    mBatteryStats.noteDeviceIdleMode(true,null,Process.myUid());
  }
 catch (  RemoteException e) {
  }
  getContext().sendBroadcastAsUser(mIdleIntent,UserHandle.ALL);
  EventLogTags.writeDeviceIdleOnComplete();
}
break;
case MSG_REPORT_IDLE_OFF:
{
EventLogTags.writeDeviceIdleOffStart("String_Node_Str");
mLocalPowerManager.setDeviceIdleMode(false);
try {
mNetworkPolicyManager.setDeviceIdleMode(false);
mBatteryStats.noteDeviceIdleMode(false,null,Process.myUid());
}
 catch (RemoteException e) {
}
getContext().sendBroadcastAsUser(mIdleIntent,UserHandle.ALL);
EventLogTags.writeDeviceIdleOffComplete();
}
break;
case MSG_REPORT_ACTIVE:
{
String activeReason=(String)msg.obj;
int activeUid=msg.arg1;
boolean needBroadcast=msg.arg2 != 0;
EventLogTags.writeDeviceIdleOffStart(activeReason != null ? activeReason : "String_Node_Str");
mLocalPowerManager.setDeviceIdleMode(false);
try {
mNetworkPolicyManager.setDeviceIdleMode(false);
mBatteryStats.noteDeviceIdleMode(false,activeReason,activeUid);
}
 catch (RemoteException e) {
}
if (needBroadcast) {
getContext().sendBroadcastAsUser(mIdleIntent,UserHandle.ALL);
}
EventLogTags.writeDeviceIdleOffComplete();
}
break;
case MSG_TEMP_APP_WHITELIST_TIMEOUT:
{
int uid=msg.arg1;
checkTempAppWhitelistTimeout(uid);
}
break;
}
}
Program: 194504
Project: 194504
Buggy source:
@Override public void addPowerSaveTempWhitelistApp(String packageName,long duration,int userId) throws RemoteException {
  getContext().enforceCallingPermission(Manifest.permission.CHANGE_DEVICE_IDLE_TEMP_WHITELIST,"String_Node_Str");
  userId=ActivityManagerNative.getDefault().handleIncomingUser(Binder.getCallingPid(),Binder.getCallingUid(),userId,false,false,"String_Node_Str",null);
  final long token=Binder.clearCallingIdentity();
  try {
    DeviceIdleController.this.addPowerSaveTempWhitelistAppInternal(packageName,duration,userId);
  }
  finally {
    Binder.restoreCallingIdentity(token);
  }
}

Fixed version (ground truth):
@Override public void addPowerSaveTempWhitelistApp(String packageName,long duration,int userId) throws RemoteException {
  getContext().enforceCallingPermission(Manifest.permission.CHANGE_DEVICE_IDLE_TEMP_WHITELIST,"String_Node_Str");
  final int callingUid=Binder.getCallingUid();
  userId=ActivityManagerNative.getDefault().handleIncomingUser(Binder.getCallingPid(),callingUid,userId,false,false,"String_Node_Str",null);
  final long token=Binder.clearCallingIdentity();
  try {
    DeviceIdleController.this.addPowerSaveTempWhitelistAppInternal(callingUid,packageName,duration,userId);
  }
  finally {
    Binder.restoreCallingIdentity(token);
  }
}
Program: 194505
Project: 194505
Buggy source:
public void addPowerSaveTempWhitelistAppDirect(int appId,long duration){
  DeviceIdleController.this.addPowerSaveTempWhitelistAppDirectInternal(appId,duration);
}

Fixed version (ground truth):
public void addPowerSaveTempWhitelistAppDirect(int appId,long duration){
  addPowerSaveTempWhitelistAppDirectInternal(0,appId,duration);
}
Program: 194506
Project: 194506
Buggy source:
/** 
 * Adds an app to the temporary whitelist and resets the endTime for granting the app an exemption to access network and acquire wakelocks.
 */
public void addPowerSaveTempWhitelistAppDirectInternal(int appId,long duration){
  final long timeNow=SystemClock.elapsedRealtime();
synchronized (this) {
    duration=Math.min(duration,mConstants.MAX_TEMP_APP_WHITELIST_DURATION);
    long currentEndTime=mTempWhitelistAppIdEndTimes.get(appId);
    mTempWhitelistAppIdEndTimes.put(appId,timeNow + duration);
    if (DEBUG) {
      Slog.d(TAG,"String_Node_Str" + appId + "String_Node_Str");
    }
    if (currentEndTime == 0) {
      postTempActiveTimeoutMessage(appId,duration);
      updateTempWhitelistAppIdsLocked();
      reportTempWhitelistChangedLocked();
    }
  }
}

Fixed version (ground truth):
/** 
 * Adds an app to the temporary whitelist and resets the endTime for granting the app an exemption to access network and acquire wakelocks.
 */
public void addPowerSaveTempWhitelistAppDirectInternal(int callingUid,int appId,long duration){
  final long timeNow=SystemClock.elapsedRealtime();
synchronized (this) {
    int callingAppId=UserHandle.getAppId(callingUid);
    if (callingAppId >= Process.FIRST_APPLICATION_UID) {
      if (!mPowerSaveWhitelistSystemAppIds.get(callingAppId)) {
        throw new SecurityException("String_Node_Str" + UserHandle.formatUid(callingUid) + "String_Node_Str");
      }
    }
    duration=Math.min(duration,mConstants.MAX_TEMP_APP_WHITELIST_DURATION);
    long currentEndTime=mTempWhitelistAppIdEndTimes.get(appId);
    mTempWhitelistAppIdEndTimes.put(appId,timeNow + duration);
    if (DEBUG) {
      Slog.d(TAG,"String_Node_Str" + appId + "String_Node_Str");
    }
    if (currentEndTime == 0) {
      postTempActiveTimeoutMessage(appId,duration);
      updateTempWhitelistAppIdsLocked();
      reportTempWhitelistChangedLocked();
    }
  }
}
Program: 194507
Project: 194507
Buggy source:
@Override public void onStart(){
  final PackageManager pm=getContext().getPackageManager();
synchronized (this) {
    mEnabled=getContext().getResources().getBoolean(com.android.internal.R.bool.config_enableAutoPowerModes);
    SystemConfig sysConfig=SystemConfig.getInstance();
    ArraySet<String> allowPower=sysConfig.getAllowInPowerSave();
    for (int i=0; i < allowPower.size(); i++) {
      String pkg=allowPower.valueAt(i);
      try {
        ApplicationInfo ai=pm.getApplicationInfo(pkg,0);
        if ((ai.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
          mPowerSaveWhitelistApps.put(ai.packageName,UserHandle.getAppId(ai.uid));
        }
      }
 catch (      PackageManager.NameNotFoundException e) {
      }
    }
    mConstants=new Constants(mHandler,getContext().getContentResolver());
    readConfigFileLocked();
    updateWhitelistAppIdsLocked();
    mScreenOn=true;
    mCharging=true;
    mState=STATE_ACTIVE;
    mInactiveTimeout=mConstants.INACTIVE_TIMEOUT;
  }
  publishBinderService(Context.DEVICE_IDLE_CONTROLLER,new BinderService());
  publishLocalService(LocalService.class,new LocalService());
}

Fixed version (ground truth):
@Override public void onStart(){
  final PackageManager pm=getContext().getPackageManager();
synchronized (this) {
    mEnabled=getContext().getResources().getBoolean(com.android.internal.R.bool.config_enableAutoPowerModes);
    SystemConfig sysConfig=SystemConfig.getInstance();
    ArraySet<String> allowPower=sysConfig.getAllowInPowerSave();
    for (int i=0; i < allowPower.size(); i++) {
      String pkg=allowPower.valueAt(i);
      try {
        ApplicationInfo ai=pm.getApplicationInfo(pkg,0);
        if ((ai.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
          int appid=UserHandle.getAppId(ai.uid);
          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;
    mInactiveTimeout=mConstants.INACTIVE_TIMEOUT;
  }
  publishBinderService(Context.DEVICE_IDLE_CONTROLLER,new BinderService());
  publishLocalService(LocalService.class,new LocalService());
}
Program: 194508
Project: 194508
Buggy source:
private void updateWhitelistAppIdsLocked(){
  mPowerSaveWhitelistAppIds.clear();
  for (int i=0; i < mPowerSaveWhitelistApps.size(); i++) {
    mPowerSaveWhitelistAppIds.put(mPowerSaveWhitelistApps.valueAt(i),true);
  }
  for (int i=0; i < mPowerSaveWhitelistUserApps.size(); i++) {
    mPowerSaveWhitelistAppIds.put(mPowerSaveWhitelistUserApps.valueAt(i),true);
  }
  int size=mPowerSaveWhitelistAppIds.size();
  int[] appids=new int[size];
  for (int i=0; i < size; i++) {
    appids[i]=mPowerSaveWhitelistAppIds.keyAt(i);
  }
  mPowerSaveWhitelistAppIdArray=appids;
  if (mLocalPowerManager != null) {
    if (DEBUG) {
      Slog.d(TAG,"String_Node_Str" + Arrays.toString(mPowerSaveWhitelistAppIdArray));
    }
    mLocalPowerManager.setDeviceIdleWhitelist(mPowerSaveWhitelistAppIdArray);
  }
}

Fixed version (ground truth):
private void updateWhitelistAppIdsLocked(){
  mPowerSaveWhitelistAllAppIds.clear();
  for (int i=0; i < mPowerSaveWhitelistApps.size(); i++) {
    mPowerSaveWhitelistAllAppIds.put(mPowerSaveWhitelistApps.valueAt(i),true);
  }
  for (int i=0; i < mPowerSaveWhitelistUserApps.size(); i++) {
    mPowerSaveWhitelistAllAppIds.put(mPowerSaveWhitelistUserApps.valueAt(i),true);
  }
  int size=mPowerSaveWhitelistAllAppIds.size();
  int[] appids=new int[size];
  for (int i=0; i < size; i++) {
    appids[i]=mPowerSaveWhitelistAllAppIds.keyAt(i);
  }
  mPowerSaveWhitelistAllAppIdArray=appids;
  if (mLocalPowerManager != null) {
    if (DEBUG) {
      Slog.d(TAG,"String_Node_Str" + Arrays.toString(mPowerSaveWhitelistAllAppIdArray));
    }
    mLocalPowerManager.setDeviceIdleWhitelist(mPowerSaveWhitelistAllAppIdArray);
  }
}
Program: 194509
Project: 194509
Buggy source:
/** 
 * Adds an app to the temporary whitelist and resets the endTime for granting the app an exemption to access network and acquire wakelocks.
 */
public void addPowerSaveTempWhitelistAppInternal(String packageName,long duration,int userId){
  try {
    int uid=getContext().getPackageManager().getPackageUid(packageName,userId);
    int appId=UserHandle.getAppId(uid);
    addPowerSaveTempWhitelistAppDirectInternal(appId,duration);
  }
 catch (  NameNotFoundException e) {
  }
}

Fixed version (ground truth):
/** 
 * Adds an app to the temporary whitelist and resets the endTime for granting the app an exemption to access network and acquire wakelocks.
 */
public void addPowerSaveTempWhitelistAppInternal(int callingUid,String packageName,long duration,int userId){
  try {
    int uid=getContext().getPackageManager().getPackageUid(packageName,userId);
    int appId=UserHandle.getAppId(uid);
    addPowerSaveTempWhitelistAppDirectInternal(callingUid,appId,duration);
  }
 catch (  NameNotFoundException e) {
  }
}
Program: 194510
Project: 194510
Buggy source:
public int[] getAppIdWhitelistInternal(){
synchronized (this) {
    return mPowerSaveWhitelistAppIdArray;
  }
}

Fixed version (ground truth):
public int[] getAppIdWhitelistInternal(){
synchronized (this) {
    return mPowerSaveWhitelistAllAppIdArray;
  }
}
Program: 194513
Project: 194513
Buggy source:
@Override public void handleMessage(Message msg){
  if (DEBUG)   Slog.d(TAG,"String_Node_Str" + msg.what + "String_Node_Str");
switch (msg.what) {
case MSG_WRITE_CONFIG:
{
      handleWriteConfigFile();
    }
  break;
case MSG_REPORT_IDLE_ON:
{
  mLocalPowerManager.setDeviceIdleMode(true);
  try {
    mNetworkPolicyManager.setDeviceIdleMode(true);
    mBatteryStats.noteDeviceIdleMode(true,null,Process.myUid());
  }
 catch (  RemoteException e) {
  }
  getContext().sendBroadcastAsUser(mIdleIntent,UserHandle.ALL);
}
break;
case MSG_REPORT_IDLE_OFF:
{
mLocalPowerManager.setDeviceIdleMode(false);
try {
mNetworkPolicyManager.setDeviceIdleMode(false);
mBatteryStats.noteDeviceIdleMode(false,null,Process.myUid());
}
 catch (RemoteException e) {
}
getContext().sendBroadcastAsUser(mIdleIntent,UserHandle.ALL);
}
break;
case MSG_REPORT_ACTIVE:
{
String activeReason=(String)msg.obj;
int activeUid=msg.arg1;
boolean needBroadcast=msg.arg2 != 0;
mLocalPowerManager.setDeviceIdleMode(false);
try {
mNetworkPolicyManager.setDeviceIdleMode(false);
mBatteryStats.noteDeviceIdleMode(false,activeReason,activeUid);
}
 catch (RemoteException e) {
}
if (needBroadcast) {
getContext().sendBroadcastAsUser(mIdleIntent,UserHandle.ALL);
}
}
break;
case MSG_TEMP_APP_WHITELIST_TIMEOUT:
{
int uid=msg.arg1;
checkTempAppWhitelistTimeout(uid);
}
break;
}
}

Fixed version (ground truth):
@Override public void handleMessage(Message msg){
  if (DEBUG)   Slog.d(TAG,"String_Node_Str" + msg.what + "String_Node_Str");
switch (msg.what) {
case MSG_WRITE_CONFIG:
{
      handleWriteConfigFile();
    }
  break;
case MSG_REPORT_IDLE_ON:
{
  EventLogTags.writeDeviceIdleOnStart();
  mLocalPowerManager.setDeviceIdleMode(true);
  try {
    mNetworkPolicyManager.setDeviceIdleMode(true);
    mBatteryStats.noteDeviceIdleMode(true,null,Process.myUid());
  }
 catch (  RemoteException e) {
  }
  getContext().sendBroadcastAsUser(mIdleIntent,UserHandle.ALL);
  EventLogTags.writeDeviceIdleOnComplete();
}
break;
case MSG_REPORT_IDLE_OFF:
{
EventLogTags.writeDeviceIdleOffStart("String_Node_Str");
mLocalPowerManager.setDeviceIdleMode(false);
try {
mNetworkPolicyManager.setDeviceIdleMode(false);
mBatteryStats.noteDeviceIdleMode(false,null,Process.myUid());
}
 catch (RemoteException e) {
}
getContext().sendBroadcastAsUser(mIdleIntent,UserHandle.ALL);
EventLogTags.writeDeviceIdleOffComplete();
}
break;
case MSG_REPORT_ACTIVE:
{
String activeReason=(String)msg.obj;
int activeUid=msg.arg1;
boolean needBroadcast=msg.arg2 != 0;
EventLogTags.writeDeviceIdleOffStart(activeReason != null ? activeReason : "String_Node_Str");
mLocalPowerManager.setDeviceIdleMode(false);
try {
mNetworkPolicyManager.setDeviceIdleMode(false);
mBatteryStats.noteDeviceIdleMode(false,activeReason,activeUid);
}
 catch (RemoteException e) {
}
if (needBroadcast) {
getContext().sendBroadcastAsUser(mIdleIntent,UserHandle.ALL);
}
EventLogTags.writeDeviceIdleOffComplete();
}
break;
case MSG_TEMP_APP_WHITELIST_TIMEOUT:
{
int uid=msg.arg1;
checkTempAppWhitelistTimeout(uid);
}
break;
}
}
Program: 194514
Project: 194514
Buggy source:
@Override public void addPowerSaveTempWhitelistApp(String packageName,long duration,int userId) throws RemoteException {
  getContext().enforceCallingPermission(Manifest.permission.CHANGE_DEVICE_IDLE_TEMP_WHITELIST,"String_Node_Str");
  userId=ActivityManagerNative.getDefault().handleIncomingUser(Binder.getCallingPid(),Binder.getCallingUid(),userId,false,false,"String_Node_Str",null);
  final long token=Binder.clearCallingIdentity();
  try {
    DeviceIdleController.this.addPowerSaveTempWhitelistAppInternal(packageName,duration,userId);
  }
  finally {
    Binder.restoreCallingIdentity(token);
  }
}

Fixed version (ground truth):
@Override public void addPowerSaveTempWhitelistApp(String packageName,long duration,int userId) throws RemoteException {
  getContext().enforceCallingPermission(Manifest.permission.CHANGE_DEVICE_IDLE_TEMP_WHITELIST,"String_Node_Str");
  final int callingUid=Binder.getCallingUid();
  userId=ActivityManagerNative.getDefault().handleIncomingUser(Binder.getCallingPid(),callingUid,userId,false,false,"String_Node_Str",null);
  final long token=Binder.clearCallingIdentity();
  try {
    DeviceIdleController.this.addPowerSaveTempWhitelistAppInternal(callingUid,packageName,duration,userId);
  }
  finally {
    Binder.restoreCallingIdentity(token);
  }
}
Program: 194515
Project: 194515
Buggy source:
public void addPowerSaveTempWhitelistAppDirect(int appId,long duration){
  DeviceIdleController.this.addPowerSaveTempWhitelistAppDirectInternal(appId,duration);
}

Fixed version (ground truth):
public void addPowerSaveTempWhitelistAppDirect(int appId,long duration){
  addPowerSaveTempWhitelistAppDirectInternal(0,appId,duration);
}
Program: 194516
Project: 194516
Buggy source:
/** 
 * Adds an app to the temporary whitelist and resets the endTime for granting the app an exemption to access network and acquire wakelocks.
 */
public void addPowerSaveTempWhitelistAppDirectInternal(int appId,long duration){
  final long timeNow=SystemClock.elapsedRealtime();
synchronized (this) {
    duration=Math.min(duration,mConstants.MAX_TEMP_APP_WHITELIST_DURATION);
    long currentEndTime=mTempWhitelistAppIdEndTimes.get(appId);
    mTempWhitelistAppIdEndTimes.put(appId,timeNow + duration);
    if (DEBUG) {
      Slog.d(TAG,"String_Node_Str" + appId + "String_Node_Str");
    }
    if (currentEndTime == 0) {
      postTempActiveTimeoutMessage(appId,duration);
      updateTempWhitelistAppIdsLocked();
      reportTempWhitelistChangedLocked();
    }
  }
}

Fixed version (ground truth):
/** 
 * Adds an app to the temporary whitelist and resets the endTime for granting the app an exemption to access network and acquire wakelocks.
 */
public void addPowerSaveTempWhitelistAppDirectInternal(int callingUid,int appId,long duration){
  final long timeNow=SystemClock.elapsedRealtime();
synchronized (this) {
    int callingAppId=UserHandle.getAppId(callingUid);
    if (callingAppId >= Process.FIRST_APPLICATION_UID) {
      if (!mPowerSaveWhitelistSystemAppIds.get(callingAppId)) {
        throw new SecurityException("String_Node_Str" + UserHandle.formatUid(callingUid) + "String_Node_Str");
      }
    }
    duration=Math.min(duration,mConstants.MAX_TEMP_APP_WHITELIST_DURATION);
    long currentEndTime=mTempWhitelistAppIdEndTimes.get(appId);
    mTempWhitelistAppIdEndTimes.put(appId,timeNow + duration);
    if (DEBUG) {
      Slog.d(TAG,"String_Node_Str" + appId + "String_Node_Str");
    }
    if (currentEndTime == 0) {
      postTempActiveTimeoutMessage(appId,duration);
      updateTempWhitelistAppIdsLocked();
      reportTempWhitelistChangedLocked();
    }
  }
}
Program: 194517
Project: 194517
Buggy source:
@Override public void onStart(){
  final PackageManager pm=getContext().getPackageManager();
synchronized (this) {
    mEnabled=getContext().getResources().getBoolean(com.android.internal.R.bool.config_enableAutoPowerModes);
    SystemConfig sysConfig=SystemConfig.getInstance();
    ArraySet<String> allowPower=sysConfig.getAllowInPowerSave();
    for (int i=0; i < allowPower.size(); i++) {
      String pkg=allowPower.valueAt(i);
      try {
        ApplicationInfo ai=pm.getApplicationInfo(pkg,0);
        if ((ai.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
          mPowerSaveWhitelistApps.put(ai.packageName,UserHandle.getAppId(ai.uid));
        }
      }
 catch (      PackageManager.NameNotFoundException e) {
      }
    }
    mConstants=new Constants(mHandler,getContext().getContentResolver());
    readConfigFileLocked();
    updateWhitelistAppIdsLocked();
    mScreenOn=true;
    mCharging=true;
    mState=STATE_ACTIVE;
    mInactiveTimeout=mConstants.INACTIVE_TIMEOUT;
  }
  publishBinderService(Context.DEVICE_IDLE_CONTROLLER,new BinderService());
  publishLocalService(LocalService.class,new LocalService());
}

Fixed version (ground truth):
@Override public void onStart(){
  final PackageManager pm=getContext().getPackageManager();
synchronized (this) {
    mEnabled=getContext().getResources().getBoolean(com.android.internal.R.bool.config_enableAutoPowerModes);
    SystemConfig sysConfig=SystemConfig.getInstance();
    ArraySet<String> allowPower=sysConfig.getAllowInPowerSave();
    for (int i=0; i < allowPower.size(); i++) {
      String pkg=allowPower.valueAt(i);
      try {
        ApplicationInfo ai=pm.getApplicationInfo(pkg,0);
        if ((ai.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
          int appid=UserHandle.getAppId(ai.uid);
          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;
    mInactiveTimeout=mConstants.INACTIVE_TIMEOUT;
  }
  publishBinderService(Context.DEVICE_IDLE_CONTROLLER,new BinderService());
  publishLocalService(LocalService.class,new LocalService());
}
Program: 194518
Project: 194518
Buggy source:
private void updateWhitelistAppIdsLocked(){
  mPowerSaveWhitelistAppIds.clear();
  for (int i=0; i < mPowerSaveWhitelistApps.size(); i++) {
    mPowerSaveWhitelistAppIds.put(mPowerSaveWhitelistApps.valueAt(i),true);
  }
  for (int i=0; i < mPowerSaveWhitelistUserApps.size(); i++) {
    mPowerSaveWhitelistAppIds.put(mPowerSaveWhitelistUserApps.valueAt(i),true);
  }
  int size=mPowerSaveWhitelistAppIds.size();
  int[] appids=new int[size];
  for (int i=0; i < size; i++) {
    appids[i]=mPowerSaveWhitelistAppIds.keyAt(i);
  }
  mPowerSaveWhitelistAppIdArray=appids;
  if (mLocalPowerManager != null) {
    if (DEBUG) {
      Slog.d(TAG,"String_Node_Str" + Arrays.toString(mPowerSaveWhitelistAppIdArray));
    }
    mLocalPowerManager.setDeviceIdleWhitelist(mPowerSaveWhitelistAppIdArray);
  }
}

Fixed version (ground truth):
private void updateWhitelistAppIdsLocked(){
  mPowerSaveWhitelistAllAppIds.clear();
  for (int i=0; i < mPowerSaveWhitelistApps.size(); i++) {
    mPowerSaveWhitelistAllAppIds.put(mPowerSaveWhitelistApps.valueAt(i),true);
  }
  for (int i=0; i < mPowerSaveWhitelistUserApps.size(); i++) {
    mPowerSaveWhitelistAllAppIds.put(mPowerSaveWhitelistUserApps.valueAt(i),true);
  }
  int size=mPowerSaveWhitelistAllAppIds.size();
  int[] appids=new int[size];
  for (int i=0; i < size; i++) {
    appids[i]=mPowerSaveWhitelistAllAppIds.keyAt(i);
  }
  mPowerSaveWhitelistAllAppIdArray=appids;
  if (mLocalPowerManager != null) {
    if (DEBUG) {
      Slog.d(TAG,"String_Node_Str" + Arrays.toString(mPowerSaveWhitelistAllAppIdArray));
    }
    mLocalPowerManager.setDeviceIdleWhitelist(mPowerSaveWhitelistAllAppIdArray);
  }
}
Program: 194519
Project: 194519
Buggy source:
/** 
 * Adds an app to the temporary whitelist and resets the endTime for granting the app an exemption to access network and acquire wakelocks.
 */
public void addPowerSaveTempWhitelistAppInternal(String packageName,long duration,int userId){
  try {
    int uid=getContext().getPackageManager().getPackageUid(packageName,userId);
    int appId=UserHandle.getAppId(uid);
    addPowerSaveTempWhitelistAppDirectInternal(appId,duration);
  }
 catch (  NameNotFoundException e) {
  }
}

Fixed version (ground truth):
/** 
 * Adds an app to the temporary whitelist and resets the endTime for granting the app an exemption to access network and acquire wakelocks.
 */
public void addPowerSaveTempWhitelistAppInternal(int callingUid,String packageName,long duration,int userId){
  try {
    int uid=getContext().getPackageManager().getPackageUid(packageName,userId);
    int appId=UserHandle.getAppId(uid);
    addPowerSaveTempWhitelistAppDirectInternal(callingUid,appId,duration);
  }
 catch (  NameNotFoundException e) {
  }
}
Program: 194520
Project: 194520
Buggy source:
public int[] getAppIdWhitelistInternal(){
synchronized (this) {
    return mPowerSaveWhitelistAppIdArray;
  }
}

Fixed version (ground truth):
public int[] getAppIdWhitelistInternal(){
synchronized (this) {
    return mPowerSaveWhitelistAllAppIdArray;
  }
}
Program: 194523
Project: 194523
Buggy source:
@Override public void handleMessage(Message msg){
  if (DEBUG)   Slog.d(TAG,"String_Node_Str" + msg.what + "String_Node_Str");
switch (msg.what) {
case MSG_WRITE_CONFIG:
{
      handleWriteConfigFile();
    }
  break;
case MSG_REPORT_IDLE_ON:
{
  mLocalPowerManager.setDeviceIdleMode(true);
  try {
    mNetworkPolicyManager.setDeviceIdleMode(true);
    mBatteryStats.noteDeviceIdleMode(true,null,Process.myUid());
  }
 catch (  RemoteException e) {
  }
  getContext().sendBroadcastAsUser(mIdleIntent,UserHandle.ALL);
}
break;
case MSG_REPORT_IDLE_OFF:
{
mLocalPowerManager.setDeviceIdleMode(false);
try {
mNetworkPolicyManager.setDeviceIdleMode(false);
mBatteryStats.noteDeviceIdleMode(false,null,Process.myUid());
}
 catch (RemoteException e) {
}
getContext().sendBroadcastAsUser(mIdleIntent,UserHandle.ALL);
}
break;
case MSG_REPORT_ACTIVE:
{
String activeReason=(String)msg.obj;
int activeUid=msg.arg1;
boolean needBroadcast=msg.arg2 != 0;
mLocalPowerManager.setDeviceIdleMode(false);
try {
mNetworkPolicyManager.setDeviceIdleMode(false);
mBatteryStats.noteDeviceIdleMode(false,activeReason,activeUid);
}
 catch (RemoteException e) {
}
if (needBroadcast) {
getContext().sendBroadcastAsUser(mIdleIntent,UserHandle.ALL);
}
}
break;
case MSG_TEMP_APP_WHITELIST_TIMEOUT:
{
int uid=msg.arg1;
checkTempAppWhitelistTimeout(uid);
}
break;
}
}

Fixed version (ground truth):
@Override public void handleMessage(Message msg){
  if (DEBUG)   Slog.d(TAG,"String_Node_Str" + msg.what + "String_Node_Str");
switch (msg.what) {
case MSG_WRITE_CONFIG:
{
      handleWriteConfigFile();
    }
  break;
case MSG_REPORT_IDLE_ON:
{
  EventLogTags.writeDeviceIdleOnStart();
  mLocalPowerManager.setDeviceIdleMode(true);
  try {
    mNetworkPolicyManager.setDeviceIdleMode(true);
    mBatteryStats.noteDeviceIdleMode(true,null,Process.myUid());
  }
 catch (  RemoteException e) {
  }
  getContext().sendBroadcastAsUser(mIdleIntent,UserHandle.ALL);
  EventLogTags.writeDeviceIdleOnComplete();
}
break;
case MSG_REPORT_IDLE_OFF:
{
EventLogTags.writeDeviceIdleOffStart("String_Node_Str");
mLocalPowerManager.setDeviceIdleMode(false);
try {
mNetworkPolicyManager.setDeviceIdleMode(false);
mBatteryStats.noteDeviceIdleMode(false,null,Process.myUid());
}
 catch (RemoteException e) {
}
getContext().sendBroadcastAsUser(mIdleIntent,UserHandle.ALL);
EventLogTags.writeDeviceIdleOffComplete();
}
break;
case MSG_REPORT_ACTIVE:
{
String activeReason=(String)msg.obj;
int activeUid=msg.arg1;
boolean needBroadcast=msg.arg2 != 0;
EventLogTags.writeDeviceIdleOffStart(activeReason != null ? activeReason : "String_Node_Str");
mLocalPowerManager.setDeviceIdleMode(false);
try {
mNetworkPolicyManager.setDeviceIdleMode(false);
mBatteryStats.noteDeviceIdleMode(false,activeReason,activeUid);
}
 catch (RemoteException e) {
}
if (needBroadcast) {
getContext().sendBroadcastAsUser(mIdleIntent,UserHandle.ALL);
}
EventLogTags.writeDeviceIdleOffComplete();
}
break;
case MSG_TEMP_APP_WHITELIST_TIMEOUT:
{
int uid=msg.arg1;
checkTempAppWhitelistTimeout(uid);
}
break;
}
}
Program: 194524
Project: 194524
Buggy source:
@Override public void addPowerSaveTempWhitelistApp(String packageName,long duration,int userId) throws RemoteException {
  getContext().enforceCallingPermission(Manifest.permission.CHANGE_DEVICE_IDLE_TEMP_WHITELIST,"String_Node_Str");
  userId=ActivityManagerNative.getDefault().handleIncomingUser(Binder.getCallingPid(),Binder.getCallingUid(),userId,false,false,"String_Node_Str",null);
  final long token=Binder.clearCallingIdentity();
  try {
    DeviceIdleController.this.addPowerSaveTempWhitelistAppInternal(packageName,duration,userId);
  }
  finally {
    Binder.restoreCallingIdentity(token);
  }
}

Fixed version (ground truth):
@Override public void addPowerSaveTempWhitelistApp(String packageName,long duration,int userId) throws RemoteException {
  getContext().enforceCallingPermission(Manifest.permission.CHANGE_DEVICE_IDLE_TEMP_WHITELIST,"String_Node_Str");
  final int callingUid=Binder.getCallingUid();
  userId=ActivityManagerNative.getDefault().handleIncomingUser(Binder.getCallingPid(),callingUid,userId,false,false,"String_Node_Str",null);
  final long token=Binder.clearCallingIdentity();
  try {
    DeviceIdleController.this.addPowerSaveTempWhitelistAppInternal(callingUid,packageName,duration,userId);
  }
  finally {
    Binder.restoreCallingIdentity(token);
  }
}
Program: 194525
Project: 194525
Buggy source:
public void addPowerSaveTempWhitelistAppDirect(int appId,long duration){
  DeviceIdleController.this.addPowerSaveTempWhitelistAppDirectInternal(appId,duration);
}

Fixed version (ground truth):
public void addPowerSaveTempWhitelistAppDirect(int appId,long duration){
  addPowerSaveTempWhitelistAppDirectInternal(0,appId,duration);
}
Program: 194526
Project: 194526
Buggy source:
@Override public void startAccessPoint(WifiConfiguration wifiConfig,String wlanIface){
  mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL,TAG);
  try {
    wifiFirmwareReload(wlanIface,"String_Node_Str");
    if (wifiConfig == null) {
      mConnector.execute("String_Node_Str","String_Node_Str",wlanIface);
    }
 else {
      mConnector.execute("String_Node_Str","String_Node_Str",wlanIface,wifiConfig.SSID,"String_Node_Str",Integer.toString(wifiConfig.apChannel),getSecurityType(wifiConfig),new SensitiveArg(wifiConfig.preSharedKey));
    }
    mConnector.execute("String_Node_Str","String_Node_Str");
  }
 catch (  NativeDaemonConnectorException e) {
    throw e.rethrowAsParcelableException();
  }
}

Fixed version (ground truth):
@Override public void startAccessPoint(WifiConfiguration wifiConfig,String wlanIface){
  mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL,TAG);
  try {
    if (wifiConfig == null) {
      mConnector.execute("String_Node_Str","String_Node_Str",wlanIface);
    }
 else {
      mConnector.execute("String_Node_Str","String_Node_Str",wlanIface,wifiConfig.SSID,"String_Node_Str",Integer.toString(wifiConfig.apChannel),getSecurityType(wifiConfig),new SensitiveArg(wifiConfig.preSharedKey));
    }
    mConnector.execute("String_Node_Str","String_Node_Str");
  }
 catch (  NativeDaemonConnectorException e) {
    throw e.rethrowAsParcelableException();
  }
}