Program: 13535
Project: 13535
Buggy source:
/** 
 * Set up both primary toolbar for navigation and search, and secondary toolbar for master switch.
 */
private void setUpToolbars(){
  Toolbar toolbar=findViewById(R.id.toolbar_with_search);
  if (toolbar != null) {
    setSupportActionBar(toolbar);
  }
  ActionBar actionBar=getSupportActionBar();
  if (actionBar != null) {
    actionBar.setTitle(R.string.notification_settings);
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setDisplayShowTitleEnabled(true);
  }
  boolean isMasterChecked=mSharedPreferences.getBoolean(getString(R.string.wp_pref_notifications_master),true);
  hideDisabledView(isMasterChecked);
  mToolbarSwitch=findViewById(R.id.toolbar_with_switch);
  mToolbarSwitch.inflateMenu(R.menu.notifications_settings_secondary);
  mToolbarSwitch.setContentDescription(getString(R.string.notification_settings_switch_desc));
  mToolbarSwitch.setTitle(isMasterChecked ? getString(R.string.notification_settings_master_status_on) : getString(R.string.notification_settings_master_status_off));
  MenuItem menuItem=mToolbarSwitch.getMenu().findItem(R.id.master_switch);
  mMasterSwitch=(SwitchCompat)menuItem.getActionView();
  mToolbarSwitch.setLabelFor(mMasterSwitch.getId());
  mMasterSwitch.setChecked(isMasterChecked);
  mMasterSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener(){
    @Override public void onCheckedChanged(    CompoundButton buttonView,    boolean isChecked){
      hideDisabledView(isChecked);
      mToolbarSwitch.setContentDescription(getString(R.string.notification_settings_switch_desc));
      mToolbarSwitch.setTitle(isChecked ? getString(R.string.notification_settings_master_status_on) : getString(R.string.notification_settings_master_status_off));
      mSharedPreferences.edit().putBoolean(getString(R.string.wp_pref_notifications_master),isChecked).apply();
      if (isChecked) {
        AnalyticsTracker.track(AnalyticsTracker.Stat.NOTIFICATION_SETTINGS_APP_NOTIFICATIONS_ENABLED);
      }
 else {
        AnalyticsTracker.track(AnalyticsTracker.Stat.NOTIFICATION_SETTINGS_APP_NOTIFICATIONS_DISABLED);
      }
    }
  }
);
  mMasterSwitch.setOnLongClickListener(new View.OnLongClickListener(){
    @Override public boolean onLongClick(    View view){
      Toast.makeText(NotificationsSettingsActivity.this,mMasterSwitch.isChecked() ? getString(R.string.notification_settings_master_hint_on) : getString(R.string.notification_settings_master_hint_off),Toast.LENGTH_SHORT).show();
      return true;
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Set up both primary toolbar for navigation and search, and secondary toolbar for master switch.
 */
private void setUpToolbars(){
  Toolbar toolbar=findViewById(R.id.toolbar_with_search);
  if (toolbar != null) {
    setSupportActionBar(toolbar);
  }
  ActionBar actionBar=getSupportActionBar();
  if (actionBar != null) {
    actionBar.setTitle(R.string.notification_settings);
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setDisplayShowTitleEnabled(true);
  }
  boolean isMasterChecked=mSharedPreferences.getBoolean(getString(R.string.wp_pref_notifications_master),true);
  hideDisabledView(isMasterChecked);
  mToolbarSwitch=findViewById(R.id.toolbar_with_switch);
  mToolbarSwitch.inflateMenu(R.menu.notifications_settings_secondary);
  mToolbarSwitch.setContentDescription(getString(R.string.notification_settings_switch_desc));
  mToolbarSwitch.setTitle(isMasterChecked ? getString(R.string.notification_settings_master_status_on) : getString(R.string.notification_settings_master_status_off));
  MenuItem menuItem=mToolbarSwitch.getMenu().findItem(R.id.master_switch);
  mMasterSwitch=(SwitchCompat)menuItem.getActionView();
  ViewCompat.setLabelFor(mToolbarSwitch,mMasterSwitch.getId());
  mMasterSwitch.setChecked(isMasterChecked);
  mMasterSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener(){
    @Override public void onCheckedChanged(    CompoundButton buttonView,    boolean isChecked){
      hideDisabledView(isChecked);
      mToolbarSwitch.setContentDescription(getString(R.string.notification_settings_switch_desc));
      mToolbarSwitch.setTitle(isChecked ? getString(R.string.notification_settings_master_status_on) : getString(R.string.notification_settings_master_status_off));
      mSharedPreferences.edit().putBoolean(getString(R.string.wp_pref_notifications_master),isChecked).apply();
      if (isChecked) {
        AnalyticsTracker.track(AnalyticsTracker.Stat.NOTIFICATION_SETTINGS_APP_NOTIFICATIONS_ENABLED);
      }
 else {
        AnalyticsTracker.track(AnalyticsTracker.Stat.NOTIFICATION_SETTINGS_APP_NOTIFICATIONS_DISABLED);
      }
    }
  }
);
  mMasterSwitch.setOnLongClickListener(new View.OnLongClickListener(){
    @Override public boolean onLongClick(    View view){
      Toast.makeText(NotificationsSettingsActivity.this,mMasterSwitch.isChecked() ? getString(R.string.notification_settings_master_hint_on) : getString(R.string.notification_settings_master_hint_off),Toast.LENGTH_SHORT).show();
      return true;
    }
  }
);
}