Program: 197144
Project: 197144
Buggy source:
/** 
 * Starts the "new version setup screen" if appropriate.
 */
void startSetupActivityLocked(){
  if (mCheckedForSetup) {
    return;
  }
  final ContentResolver resolver=mContext.getContentResolver();
  if (mFactoryTest != FactoryTest.FACTORY_TEST_LOW_LEVEL && Settings.Global.getInt(resolver,Settings.Global.DEVICE_PROVISIONED,0) != 0) {
    mCheckedForSetup=true;
    Intent intent=new Intent(Intent.ACTION_UPGRADE_SETUP);
    List<ResolveInfo> ris=mContext.getPackageManager().queryIntentActivities(intent,PackageManager.GET_META_DATA);
    ResolveInfo ri=null;
    for (int i=0; ris != null && i < ris.size(); i++) {
      if ((ris.get(i).activityInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
        ri=ris.get(i);
        break;
      }
    }
    if (ri != null) {
      String vers=ri.activityInfo.metaData != null ? ri.activityInfo.metaData.getString(Intent.METADATA_SETUP_VERSION) : null;
      if (vers == null && ri.activityInfo.applicationInfo.metaData != null) {
        vers=ri.activityInfo.applicationInfo.metaData.getString(Intent.METADATA_SETUP_VERSION);
      }
      String lastVers=Settings.Secure.getString(resolver,Settings.Secure.LAST_SETUP_SHOWN);
      if (vers != null && !vers.equals(lastVers)) {
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.setComponent(new ComponentName(ri.activityInfo.packageName,ri.activityInfo.name));
        mStackSupervisor.startActivityLocked(null,intent,null,ri.activityInfo,null,null,null,null,0,0,0,null,0,null,false,null,null,null);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Starts the "new version setup screen" if appropriate.
 */
void startSetupActivityLocked(){
  if (mCheckedForSetup) {
    return;
  }
  final ContentResolver resolver=mContext.getContentResolver();
  if (mFactoryTest != FactoryTest.FACTORY_TEST_LOW_LEVEL && Settings.Global.getInt(resolver,Settings.Global.DEVICE_PROVISIONED,0) != 0) {
    mCheckedForSetup=true;
    Intent intent=new Intent(Intent.ACTION_UPGRADE_SETUP);
    List<ResolveInfo> ris=mContext.getPackageManager().queryIntentActivities(intent,PackageManager.GET_META_DATA);
    ResolveInfo ri=null;
    for (int i=0; ris != null && i < ris.size(); i++) {
      if ((ris.get(i).activityInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
        ri=ris.get(i);
        break;
      }
    }
    if (ri != null) {
      String vers=ri.activityInfo.metaData != null ? ri.activityInfo.metaData.getString(Intent.METADATA_SETUP_VERSION) : null;
      if (vers == null && ri.activityInfo.applicationInfo.metaData != null) {
        vers=ri.activityInfo.applicationInfo.metaData.getString(Intent.METADATA_SETUP_VERSION);
      }
      String lastVers=Settings.Secure.getString(resolver,Settings.Secure.LAST_SETUP_SHOWN);
      if (vers != null && !vers.equals(lastVers)) {
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.setComponent(new ComponentName(ri.activityInfo.packageName,ri.activityInfo.name));
        mStackSupervisor.startActivityLocked(null,intent,null,ri.activityInfo,null,null,null,null,0,0,0,null,0,0,0,null,false,null,null,null);
      }
    }
  }
}