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.dialer.enrichedcall.extensions;
18 
19 import android.support.annotation.NonNull;
20 import com.android.dialer.common.Assert;
21 import com.android.dialer.enrichedcall.EnrichedCallManager;
22 import com.android.dialer.enrichedcall.EnrichedCallManager.State;
23 
24 /** Extends the {@link State} to include a toString method. */
25 public class StateExtension {
26 
27   /** Returns the string representation for the given {@link State}. */
28   @NonNull
toString(@tate int callComposerState)29   public static String toString(@State int callComposerState) {
30     if (callComposerState == EnrichedCallManager.STATE_NONE) {
31       return "STATE_NONE";
32     }
33     if (callComposerState == EnrichedCallManager.STATE_STARTING) {
34       return "STATE_STARTING";
35     }
36     if (callComposerState == EnrichedCallManager.STATE_STARTED) {
37       return "STATE_STARTED";
38     }
39     if (callComposerState == EnrichedCallManager.STATE_START_FAILED) {
40       return "STATE_START_FAILED";
41     }
42     if (callComposerState == EnrichedCallManager.STATE_MESSAGE_SENT) {
43       return "STATE_MESSAGE_SENT";
44     }
45     if (callComposerState == EnrichedCallManager.STATE_MESSAGE_FAILED) {
46       return "STATE_MESSAGE_FAILED";
47     }
48     if (callComposerState == EnrichedCallManager.STATE_CLOSED) {
49       return "STATE_CLOSED";
50     }
51     Assert.checkArgument(false, "Unexpected callComposerState: %d", callComposerState);
52     return null;
53   }
54 }
55