1c9cc8b3915eac1676daf3ed067179f90eba21166Nancy Chen/* 2c9cc8b3915eac1676daf3ed067179f90eba21166Nancy Chen * Copyright (C) 2015 Google Inc. All Rights Reserved. 3c9cc8b3915eac1676daf3ed067179f90eba21166Nancy Chen * 4c9cc8b3915eac1676daf3ed067179f90eba21166Nancy Chen * Licensed under the Apache License, Version 2.0 (the "License"); 5c9cc8b3915eac1676daf3ed067179f90eba21166Nancy Chen * you may not use this file except in compliance with the License. 6c9cc8b3915eac1676daf3ed067179f90eba21166Nancy Chen * You may obtain a copy of the License at 7c9cc8b3915eac1676daf3ed067179f90eba21166Nancy Chen * 8c9cc8b3915eac1676daf3ed067179f90eba21166Nancy Chen * http://www.apache.org/licenses/LICENSE-2.0 9c9cc8b3915eac1676daf3ed067179f90eba21166Nancy Chen * 10c9cc8b3915eac1676daf3ed067179f90eba21166Nancy Chen * Unless required by applicable law or agreed to in writing, software 11c9cc8b3915eac1676daf3ed067179f90eba21166Nancy Chen * distributed under the License is distributed on an "AS IS" BASIS, 12c9cc8b3915eac1676daf3ed067179f90eba21166Nancy Chen * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13c9cc8b3915eac1676daf3ed067179f90eba21166Nancy Chen * See the License for the specific language governing permissions and 14c9cc8b3915eac1676daf3ed067179f90eba21166Nancy Chen * limitations under the License 15c9cc8b3915eac1676daf3ed067179f90eba21166Nancy Chen */ 16c9cc8b3915eac1676daf3ed067179f90eba21166Nancy Chenpackage com.android.phone.vvm.omtp.sms; 17c9cc8b3915eac1676daf3ed067179f90eba21166Nancy Chen 18c9cc8b3915eac1676daf3ed067179f90eba21166Nancy Chenimport android.annotation.Nullable; 19c9cc8b3915eac1676daf3ed067179f90eba21166Nancy Chenimport android.app.PendingIntent; 20c9cc8b3915eac1676daf3ed067179f90eba21166Nancy Chenimport android.telephony.SmsManager; 21c9cc8b3915eac1676daf3ed067179f90eba21166Nancy Chen 22c9cc8b3915eac1676daf3ed067179f90eba21166Nancy Chenimport com.android.phone.vvm.omtp.OmtpConstants; 23c9cc8b3915eac1676daf3ed067179f90eba21166Nancy Chen 24c9cc8b3915eac1676daf3ed067179f90eba21166Nancy Chen/** 25c9cc8b3915eac1676daf3ed067179f90eba21166Nancy Chen * An implementation of the OmtpMessageSender for T-Mobile. 26c9cc8b3915eac1676daf3ed067179f90eba21166Nancy Chen */ 27c9cc8b3915eac1676daf3ed067179f90eba21166Nancy Chenpublic class OmtpCvvmMessageSender extends OmtpMessageSender { 28c9cc8b3915eac1676daf3ed067179f90eba21166Nancy Chen public OmtpCvvmMessageSender(SmsManager smsManager, short applicationPort, 29c9cc8b3915eac1676daf3ed067179f90eba21166Nancy Chen String destinationNumber) { 30c9cc8b3915eac1676daf3ed067179f90eba21166Nancy Chen super(smsManager, applicationPort, destinationNumber); 31c9cc8b3915eac1676daf3ed067179f90eba21166Nancy Chen } 32c9cc8b3915eac1676daf3ed067179f90eba21166Nancy Chen 33c9cc8b3915eac1676daf3ed067179f90eba21166Nancy Chen @Override 34c9cc8b3915eac1676daf3ed067179f90eba21166Nancy Chen public void requestVvmActivation(@Nullable PendingIntent sentIntent) { 35c9cc8b3915eac1676daf3ed067179f90eba21166Nancy Chen sendCvvmMessage(OmtpConstants.ACTIVATE_REQUEST, sentIntent); 36c9cc8b3915eac1676daf3ed067179f90eba21166Nancy Chen } 37c9cc8b3915eac1676daf3ed067179f90eba21166Nancy Chen 38c9cc8b3915eac1676daf3ed067179f90eba21166Nancy Chen @Override 39c9cc8b3915eac1676daf3ed067179f90eba21166Nancy Chen public void requestVvmDeactivation(@Nullable PendingIntent sentIntent) { 40c9cc8b3915eac1676daf3ed067179f90eba21166Nancy Chen sendCvvmMessage(OmtpConstants.DEACTIVATE_REQUEST, sentIntent); 41c9cc8b3915eac1676daf3ed067179f90eba21166Nancy Chen } 42c9cc8b3915eac1676daf3ed067179f90eba21166Nancy Chen 43c9cc8b3915eac1676daf3ed067179f90eba21166Nancy Chen @Override 44c9cc8b3915eac1676daf3ed067179f90eba21166Nancy Chen public void requestVvmStatus(@Nullable PendingIntent sentIntent) { 45c9cc8b3915eac1676daf3ed067179f90eba21166Nancy Chen sendCvvmMessage(OmtpConstants.STATUS_REQUEST, sentIntent); 46c9cc8b3915eac1676daf3ed067179f90eba21166Nancy Chen } 47c9cc8b3915eac1676daf3ed067179f90eba21166Nancy Chen 48c9cc8b3915eac1676daf3ed067179f90eba21166Nancy Chen private void sendCvvmMessage(String request, PendingIntent sentIntent) { 49c9cc8b3915eac1676daf3ed067179f90eba21166Nancy Chen StringBuilder sb = new StringBuilder().append(request); 50c9cc8b3915eac1676daf3ed067179f90eba21166Nancy Chen sb.append(OmtpConstants.SMS_PREFIX_SEPARATOR); 51c9cc8b3915eac1676daf3ed067179f90eba21166Nancy Chen appendField(sb, "dt", "6"); 52c9cc8b3915eac1676daf3ed067179f90eba21166Nancy Chen sendSms(sb.toString(), sentIntent); 53c9cc8b3915eac1676daf3ed067179f90eba21166Nancy Chen } 54c9cc8b3915eac1676daf3ed067179f90eba21166Nancy Chen} 55