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.text.TextUtils;
20 import com.android.voicemail.impl.OmtpVvmCarrierConfigHelper;
21 import com.android.voicemail.impl.VvmLog;
22 import com.android.voicemail.impl.sms.OmtpMessageSender;
23 
24 public class ProtocolHelper {
25 
26   private static final String TAG = "ProtocolHelper";
27 
getMessageSender( VisualVoicemailProtocol protocol, OmtpVvmCarrierConfigHelper config)28   public static OmtpMessageSender getMessageSender(
29       VisualVoicemailProtocol protocol, OmtpVvmCarrierConfigHelper config) {
30 
31     int applicationPort = config.getApplicationPort();
32     String destinationNumber = config.getDestinationNumber();
33     if (TextUtils.isEmpty(destinationNumber)) {
34       VvmLog.w(TAG, "No destination number for this carrier.");
35       return null;
36     }
37 
38     return protocol.createMessageSender(
39         config.getContext(),
40         config.getPhoneAccountHandle(),
41         (short) applicationPort,
42         destinationNumber);
43   }
44 }
45