Home | History | Annotate | Download | only in transcribe
      1 /*
      2  * Copyright (C) 2017 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 package com.android.voicemail.impl.transcribe;
     17 
     18 import android.content.Context;
     19 import com.android.dialer.configprovider.ConfigProviderBindings;
     20 
     21 /** Provides configuration values needed to connect to the transcription server. */
     22 public class TranscriptionConfigProvider {
     23   private final Context context;
     24 
     25   public TranscriptionConfigProvider(Context context) {
     26     this.context = context;
     27   }
     28 
     29   public boolean isVoicemailTranscriptionEnabled() {
     30     return ConfigProviderBindings.get(context).getBoolean("voicemail_transcription_enabled", false);
     31   }
     32 
     33   public String getServerAddress() {
     34     // Private voicemail transcription service
     35     return ConfigProviderBindings.get(context)
     36         .getString(
     37             "voicemail_transcription_server_address", "voicemailtranscription-pa.googleapis.com");
     38   }
     39 
     40   public String getApiKey() {
     41     // Android API key restricted to com.google.android.dialer
     42     return ConfigProviderBindings.get(context)
     43         .getString(
     44             "voicemail_transcription_client_api_key", "AIzaSyAXdDnif6B7sBYxU8hzw9qAp3pRPVHs060");
     45   }
     46 
     47   public String getAuthToken() {
     48     return null;
     49   }
     50 
     51   public boolean shouldUsePlaintext() {
     52     return ConfigProviderBindings.get(context)
     53         .getBoolean("voicemail_transcription_server_use_plaintext", false);
     54   }
     55 
     56   @Override
     57   public String toString() {
     58     return String.format(
     59         "{ address: %s, api key: %s, auth token: %s, plaintext: %b }",
     60         getServerAddress(), getApiKey(), getAuthToken(), shouldUsePlaintext());
     61   }
     62 }
     63