Home | History | Annotate | Download | only in sms
      1 /*
      2  * Copyright (C) 2015 Google Inc. All Rights Reserved.
      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 package com.android.phone.vvm.omtp.sms;
     17 
     18 import android.annotation.Nullable;
     19 import android.app.PendingIntent;
     20 import android.telephony.SmsManager;
     21 
     22 import com.android.phone.vvm.omtp.OmtpConstants;
     23 
     24 /**
     25  * An implementation of the OmtpMessageSender for T-Mobile.
     26  */
     27 public class OmtpCvvmMessageSender extends OmtpMessageSender {
     28     public OmtpCvvmMessageSender(SmsManager smsManager, short applicationPort,
     29             String destinationNumber) {
     30         super(smsManager, applicationPort, destinationNumber);
     31     }
     32 
     33     @Override
     34     public void requestVvmActivation(@Nullable PendingIntent sentIntent) {
     35         sendCvvmMessage(OmtpConstants.ACTIVATE_REQUEST, sentIntent);
     36     }
     37 
     38     @Override
     39     public void requestVvmDeactivation(@Nullable PendingIntent sentIntent) {
     40         sendCvvmMessage(OmtpConstants.DEACTIVATE_REQUEST, sentIntent);
     41     }
     42 
     43     @Override
     44     public void requestVvmStatus(@Nullable PendingIntent sentIntent) {
     45         sendCvvmMessage(OmtpConstants.STATUS_REQUEST, sentIntent);
     46     }
     47 
     48     private void sendCvvmMessage(String request, PendingIntent sentIntent) {
     49         StringBuilder sb = new StringBuilder().append(request);
     50         sb.append(OmtpConstants.SMS_PREFIX_SEPARATOR);
     51         appendField(sb, "dt", "6");
     52         sendSms(sb.toString(), sentIntent);
     53     }
     54 }
     55