private void setTitle(VpnProfile profile) {
   String formatString =
       mAddingProfile
           ? getString(R.string.vpn_edit_title_add)
           : getString(R.string.vpn_edit_title_edit);
   setTitle(String.format(formatString, profile.getType().getDisplayName()));
 }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    VpnProfile p =
        (VpnProfile)
            ((savedInstanceState == null)
                ? getIntent().getParcelableExtra(VpnSettings.KEY_VPN_PROFILE)
                : savedInstanceState.getParcelable(KEY_PROFILE));
    mProfileEditor = getEditor(p);
    mAddingProfile = TextUtils.isEmpty(p.getName());

    // Loads the XML preferences file
    addPreferencesFromResource(R.xml.vpn_edit);

    initViewFor(p);

    Parcel parcel = Parcel.obtain();
    p.writeToParcel(parcel, 0);
    mOriginalProfileData = parcel.marshall();
  }
  private VpnProfileEditor getEditor(VpnProfile p) {
    switch (p.getType()) {
      case L2TP_IPSEC:
        return new L2tpIpsecEditor((L2tpIpsecProfile) p);

      case L2TP_IPSEC_PSK:
        return new L2tpIpsecPskEditor((L2tpIpsecPskProfile) p);

      case L2TP:
        return new L2tpEditor((L2tpProfile) p);

      case OPENVPN:
        return new OpenvpnEditor((OpenvpnProfile) p);

      case PPTP:
        return new PptpEditor((PptpProfile) p);

      default:
        return new VpnProfileEditor(p);
    }
  }