1ccca31529c07970e89419fb85a9e8153a5396838Eric Erfanian/*
2ccca31529c07970e89419fb85a9e8153a5396838Eric Erfanian * Copyright (C) 2016 The Android Open Source Project
3ccca31529c07970e89419fb85a9e8153a5396838Eric Erfanian *
4ccca31529c07970e89419fb85a9e8153a5396838Eric Erfanian * Licensed under the Apache License, Version 2.0 (the "License");
5ccca31529c07970e89419fb85a9e8153a5396838Eric Erfanian * you may not use this file except in compliance with the License.
6ccca31529c07970e89419fb85a9e8153a5396838Eric Erfanian * You may obtain a copy of the License at
7ccca31529c07970e89419fb85a9e8153a5396838Eric Erfanian *
8ccca31529c07970e89419fb85a9e8153a5396838Eric Erfanian *      http://www.apache.org/licenses/LICENSE-2.0
9ccca31529c07970e89419fb85a9e8153a5396838Eric Erfanian *
10ccca31529c07970e89419fb85a9e8153a5396838Eric Erfanian * Unless required by applicable law or agreed to in writing, software
11ccca31529c07970e89419fb85a9e8153a5396838Eric Erfanian * distributed under the License is distributed on an "AS IS" BASIS,
12ccca31529c07970e89419fb85a9e8153a5396838Eric Erfanian * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13ccca31529c07970e89419fb85a9e8153a5396838Eric Erfanian * See the License for the specific language governing permissions and
14ccca31529c07970e89419fb85a9e8153a5396838Eric Erfanian * limitations under the License
15ccca31529c07970e89419fb85a9e8153a5396838Eric Erfanian */
16ccca31529c07970e89419fb85a9e8153a5396838Eric Erfanian
17ccca31529c07970e89419fb85a9e8153a5396838Eric Erfanianpackage com.android.dialer.enrichedcall.extensions;
18ccca31529c07970e89419fb85a9e8153a5396838Eric Erfanian
19ccca31529c07970e89419fb85a9e8153a5396838Eric Erfanianimport android.support.annotation.NonNull;
20ccca31529c07970e89419fb85a9e8153a5396838Eric Erfanianimport com.android.dialer.common.Assert;
218e3d56ca5de3ca651d27d560eba406be21eb7aa1maxwelbimport com.android.dialer.enrichedcall.Session;
228e3d56ca5de3ca651d27d560eba406be21eb7aa1maxwelbimport com.android.dialer.enrichedcall.Session.State;
23ccca31529c07970e89419fb85a9e8153a5396838Eric Erfanian
24ccca31529c07970e89419fb85a9e8153a5396838Eric Erfanian/** Extends the {@link State} to include a toString method. */
25ccca31529c07970e89419fb85a9e8153a5396838Eric Erfanianpublic class StateExtension {
26ccca31529c07970e89419fb85a9e8153a5396838Eric Erfanian
27ccca31529c07970e89419fb85a9e8153a5396838Eric Erfanian  /** Returns the string representation for the given {@link State}. */
28ccca31529c07970e89419fb85a9e8153a5396838Eric Erfanian  @NonNull
29ccca31529c07970e89419fb85a9e8153a5396838Eric Erfanian  public static String toString(@State int callComposerState) {
308e3d56ca5de3ca651d27d560eba406be21eb7aa1maxwelb    if (callComposerState == Session.STATE_NONE) {
31ccca31529c07970e89419fb85a9e8153a5396838Eric Erfanian      return "STATE_NONE";
32ccca31529c07970e89419fb85a9e8153a5396838Eric Erfanian    }
338e3d56ca5de3ca651d27d560eba406be21eb7aa1maxwelb    if (callComposerState == Session.STATE_STARTING) {
34ccca31529c07970e89419fb85a9e8153a5396838Eric Erfanian      return "STATE_STARTING";
35ccca31529c07970e89419fb85a9e8153a5396838Eric Erfanian    }
368e3d56ca5de3ca651d27d560eba406be21eb7aa1maxwelb    if (callComposerState == Session.STATE_STARTED) {
37ccca31529c07970e89419fb85a9e8153a5396838Eric Erfanian      return "STATE_STARTED";
38ccca31529c07970e89419fb85a9e8153a5396838Eric Erfanian    }
398e3d56ca5de3ca651d27d560eba406be21eb7aa1maxwelb    if (callComposerState == Session.STATE_START_FAILED) {
40ccca31529c07970e89419fb85a9e8153a5396838Eric Erfanian      return "STATE_START_FAILED";
41ccca31529c07970e89419fb85a9e8153a5396838Eric Erfanian    }
428e3d56ca5de3ca651d27d560eba406be21eb7aa1maxwelb    if (callComposerState == Session.STATE_MESSAGE_SENT) {
43ccca31529c07970e89419fb85a9e8153a5396838Eric Erfanian      return "STATE_MESSAGE_SENT";
44ccca31529c07970e89419fb85a9e8153a5396838Eric Erfanian    }
458e3d56ca5de3ca651d27d560eba406be21eb7aa1maxwelb    if (callComposerState == Session.STATE_MESSAGE_FAILED) {
46ccca31529c07970e89419fb85a9e8153a5396838Eric Erfanian      return "STATE_MESSAGE_FAILED";
47ccca31529c07970e89419fb85a9e8153a5396838Eric Erfanian    }
488e3d56ca5de3ca651d27d560eba406be21eb7aa1maxwelb    if (callComposerState == Session.STATE_CLOSED) {
49ccca31529c07970e89419fb85a9e8153a5396838Eric Erfanian      return "STATE_CLOSED";
50ccca31529c07970e89419fb85a9e8153a5396838Eric Erfanian    }
51ccca31529c07970e89419fb85a9e8153a5396838Eric Erfanian    Assert.checkArgument(false, "Unexpected callComposerState: %d", callComposerState);
52ccca31529c07970e89419fb85a9e8153a5396838Eric Erfanian    return null;
53ccca31529c07970e89419fb85a9e8153a5396838Eric Erfanian  }
54ccca31529c07970e89419fb85a9e8153a5396838Eric Erfanian}
55