• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.phone.vvm.omtp.protocol;
18 
19 import android.annotation.Nullable;
20 import android.content.res.Resources;
21 import android.telephony.TelephonyManager;
22 
23 import com.android.phone.R;
24 import com.android.phone.vvm.omtp.VvmLog;
25 
26 public class VisualVoicemailProtocolFactory {
27 
28     private static final String TAG = "VvmProtocolFactory";
29 
30     private static final String VVM_TYPE_VVM3 = "vvm_type_vvm3";
31 
32     @Nullable
create(Resources resources, String type)33     public static VisualVoicemailProtocol create(Resources resources, String type) {
34         if (type == null) {
35             return null;
36         }
37         switch (type) {
38             case TelephonyManager.VVM_TYPE_OMTP:
39                 return new OmtpProtocol();
40             case TelephonyManager.VVM_TYPE_CVVM:
41                 return new CvvmProtocol();
42             case VVM_TYPE_VVM3:
43                 if (resources.getBoolean(R.bool.vvm3_enabled)) {
44                     return new Vvm3Protocol();
45                 } else {
46                     VvmLog.e(TAG, "VVM3 is disabled");
47                     return null;
48                 }
49             default:
50                 VvmLog.e(TAG, "Unexpected visual voicemail type: " + type);
51         }
52         return null;
53     }
54 }
55