Home | History | Annotate | Download | only in protocol
      1 /*
      2  * Copyright (C) 2016 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License
     15  */
     16 
     17 package com.android.voicemail.impl.protocol;
     18 
     19 import android.content.Context;
     20 import android.telecom.PhoneAccountHandle;
     21 import com.android.voicemail.impl.OmtpConstants;
     22 import com.android.voicemail.impl.sms.OmtpCvvmMessageSender;
     23 import com.android.voicemail.impl.sms.OmtpMessageSender;
     24 
     25 /**
     26  * A flavor of OMTP protocol with a different mobile originated (MO) format
     27  *
     28  * <p>Used by carriers such as T-Mobile
     29  */
     30 public class CvvmProtocol extends VisualVoicemailProtocol {
     31 
     32   private static String IMAP_CHANGE_TUI_PWD_FORMAT = "CHANGE_TUI_PWD PWD=%1$s OLD_PWD=%2$s";
     33   private static String IMAP_CHANGE_VM_LANG_FORMAT = "CHANGE_VM_LANG Lang=%1$s";
     34   private static String IMAP_CLOSE_NUT = "CLOSE_NUT";
     35 
     36   @Override
     37   public OmtpMessageSender createMessageSender(
     38       Context context,
     39       PhoneAccountHandle phoneAccountHandle,
     40       short applicationPort,
     41       String destinationNumber) {
     42     return new OmtpCvvmMessageSender(
     43         context, phoneAccountHandle, applicationPort, destinationNumber);
     44   }
     45 
     46   @Override
     47   public String getCommand(String command) {
     48     if (command == OmtpConstants.IMAP_CHANGE_TUI_PWD_FORMAT) {
     49       return IMAP_CHANGE_TUI_PWD_FORMAT;
     50     }
     51     if (command == OmtpConstants.IMAP_CLOSE_NUT) {
     52       return IMAP_CLOSE_NUT;
     53     }
     54     if (command == OmtpConstants.IMAP_CHANGE_VM_LANG_FORMAT) {
     55       return IMAP_CHANGE_VM_LANG_FORMAT;
     56     }
     57     return super.getCommand(command);
     58   }
     59 }
     60