Program: 86967
Project: 86967
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_smart_lock_screen_settings);
  if (savedInstanceState == null) {
    getFragmentManager().beginTransaction().add(R.id.container,new ManageEnvironmentFragment()).commit();
  }
  OneTimeInitializer.initialize(this,MASTER_PASSWORD_REQUEST);
  startService(BaseService.getServiceIntent(this,null,null));
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2 && !NotificationService.isInstanceCreated()) {
    Intent intent=new Intent(this,NotificationService.class);
    startService(intent);
  }
  setUpActionBar();
  setUpNavDrawer();
  drawerLayout=(DrawerLayout)findViewById(R.id.drawer_layout_main_settings);
  actionBarDrawerToggle=new ActionBarDrawerToggle(this,drawerLayout,0,0){
    /** 
 * Called when a drawer has settled in a completely closed state. 
 */
    public void onDrawerClosed(    View view){
      super.onDrawerClosed(view);
      if (position == prevPosition) {
        if (mTitle != null) {
          setTitle(mTitle);
        }
        return;
      }
switch (listAdapter.getItemViewType(position)) {
case NavigationDrawerListAdapter.ITEM_TYPE_PROFILE:
        listAdapter.setSelectedProfileIndex(listAdapter.getItemArrayIndex(position));
      break;
case NavigationDrawerListAdapter.ITEM_TYPE_NEW_PROFILE:
    break;
case NavigationDrawerListAdapter.ITEM_TYPE_MAIN:
  FragmentManager fragmentManager=getFragmentManager();
FragmentTransaction ft;
boolean isValid=true;
int itemArrayIndex=listAdapter.getItemArrayIndex(position);
switch (itemArrayIndex) {
case INDEX_MANAGE_ENVIRONMENTS:
ft=fragmentManager.beginTransaction();
ft.setCustomAnimations(R.animator.fade_in,R.animator.fade_out);
ft.replace(R.id.container,new ManageEnvironmentFragment()).commit();
break;
case INDEX_ENVIRONMENT_OVERLAP:
ft=fragmentManager.beginTransaction();
ft.setCustomAnimations(R.animator.fade_in,R.animator.fade_out);
ft.replace(R.id.container,new OverlappingEnvironmentsFragment()).commit();
break;
case INDEX_MASTER_PASSWORD:
ft=fragmentManager.beginTransaction();
ft.setCustomAnimations(R.animator.fade_in,R.animator.fade_out);
ft.replace(R.id.container,new SetMasterPasswordFragment()).commit();
break;
default :
isValid=false;
}
if (isValid) {
mTitle=mainItemList.get(itemArrayIndex);
listAdapter.setSelectedMainItemIndex(itemArrayIndex);
listAdapter.notifyDataSetChanged();
}
if (position != -1) {
prevPosition=position;
position=-1;
}
break;
case NavigationDrawerListAdapter.ITEM_TYPE_SECONDARY:
switch (listAdapter.getItemArrayIndex(position)) {
case INDEX_SETTINGS:
startActivity(new Intent(SmartLockScreenSettings.this,GeneralSettingsActivity.class));
break;
default :
Toast.makeText(SmartLockScreenSettings.this,"String_Node_Str",Toast.LENGTH_SHORT).show();
}
break;
default :
return;
}
if (mTitle != null) {
setTitle(mTitle);
}
}
/** 
 * Called when a drawer has settled in a completely open state. 
 */
public void onDrawerOpened(View drawerView){
super.onDrawerOpened(drawerView);
mTitle=getTitle().toString();
setTitle(getString(R.string.title_activity_smart_lock_screen_settings));
}
}
;
drawerLayout.setDrawerListener(actionBarDrawerToggle);
drawerLayout.openDrawer(Gravity.START);
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_smart_lock_screen_settings);
  if (savedInstanceState == null) {
    getFragmentManager().beginTransaction().add(R.id.container,new ManageEnvironmentFragment()).commit();
  }
  OneTimeInitializer.initialize(this,MASTER_PASSWORD_REQUEST);
  startService(BaseService.getServiceIntent(this,null,null));
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2 && !NotificationService.isInstanceCreated()) {
    Intent intent=new Intent(this,NotificationService.class);
    startService(intent);
  }
  setUpActionBar();
  setUpNavDrawer();
  drawerLayout=(DrawerLayout)findViewById(R.id.drawer_layout_main_settings);
  actionBarDrawerToggle=new ActionBarDrawerToggle(this,drawerLayout,0,0){
    /** 
 * Called when a drawer has settled in a completely closed state. 
 */
    public void onDrawerClosed(    View view){
      super.onDrawerClosed(view);
      if (position == prevPosition) {
        if (mTitle != null) {
          setTitle(mTitle);
        }
        return;
      }
switch (listAdapter.getItemViewType(position)) {
case NavigationDrawerListAdapter.ITEM_TYPE_PROFILE:
        listAdapter.setSelectedProfileIndex(listAdapter.getItemArrayIndex(position));
      break;
case NavigationDrawerListAdapter.ITEM_TYPE_NEW_PROFILE:
    break;
case NavigationDrawerListAdapter.ITEM_TYPE_MAIN:
  FragmentManager fragmentManager=getFragmentManager();
FragmentTransaction ft;
boolean isValid=true;
int itemArrayIndex=listAdapter.getItemArrayIndex(position);
switch (itemArrayIndex) {
case INDEX_MANAGE_ENVIRONMENTS:
ft=fragmentManager.beginTransaction();
ft.setCustomAnimations(R.animator.fade_in,R.animator.fade_out);
ft.replace(R.id.container,new ManageEnvironmentFragment()).commit();
break;
case INDEX_ENVIRONMENT_OVERLAP:
ft=fragmentManager.beginTransaction();
ft.setCustomAnimations(R.animator.fade_in,R.animator.fade_out);
ft.replace(R.id.container,new OverlappingEnvironmentsFragment()).commit();
break;
case INDEX_MASTER_PASSWORD:
ft=fragmentManager.beginTransaction();
ft.setCustomAnimations(R.animator.fade_in,R.animator.fade_out);
ft.replace(R.id.container,new SetMasterPasswordFragment()).commit();
break;
default :
isValid=false;
}
if (isValid) {
mTitle=mainItemList.get(itemArrayIndex);
listAdapter.setSelectedMainItemIndex(itemArrayIndex);
listAdapter.notifyDataSetChanged();
}
if (position != -1) {
prevPosition=position;
}
break;
case NavigationDrawerListAdapter.ITEM_TYPE_SECONDARY:
switch (listAdapter.getItemArrayIndex(position)) {
case INDEX_SETTINGS:
startActivity(new Intent(SmartLockScreenSettings.this,GeneralSettingsActivity.class));
break;
default :
Toast.makeText(SmartLockScreenSettings.this,"String_Node_Str",Toast.LENGTH_SHORT).show();
}
break;
default :
return;
}
if (mTitle != null) {
setTitle(mTitle);
}
position=-1;
}
/** 
 * Called when a drawer has settled in a completely open state. 
 */
public void onDrawerOpened(View drawerView){
super.onDrawerOpened(drawerView);
mTitle=getTitle().toString();
setTitle(getString(R.string.title_activity_smart_lock_screen_settings));
}
}
;
drawerLayout.setDrawerListener(actionBarDrawerToggle);
drawerLayout.openDrawer(Gravity.START);
}