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 android.voiceinteraction.cts; 18 19 import android.app.Activity; 20 import android.content.Intent; 21 import android.content.ComponentName; 22 import android.content.Context; 23 import android.os.Bundle; 24 import android.util.Log; 25 import android.voiceinteraction.common.Utils; 26 27 import java.util.concurrent.CountDownLatch; 28 29 public class TestLocalInteractionActivity extends Activity { 30 static final String TAG = "TestLocalInteractionActivity"; 31 32 private CountDownLatch mStarted; 33 private CountDownLatch mStopped; 34 35 @Override 36 public void onCreate(Bundle savedInstanceState) { 37 super.onCreate(savedInstanceState); 38 Log.i(TAG, " in onCreate"); 39 } 40 41 void startLocalInteraction(CountDownLatch counter) { 42 Bundle privateOptions = new Bundle(); 43 privateOptions.putString(Utils.PRIVATE_OPTIONS_KEY, Utils.PRIVATE_OPTIONS_VALUE); 44 mStarted = counter; 45 startLocalVoiceInteraction(privateOptions); 46 } 47 48 @Override 49 public void onLocalVoiceInteractionStarted() { 50 Log.i(TAG, " in onLocalVoiceInteractionStarted"); 51 if (mStarted != null) { 52 mStarted.countDown(); 53 } 54 } 55 56 void stopLocalInteraction(CountDownLatch counter) { 57 mStopped = counter; 58 stopLocalVoiceInteraction(); 59 } 60 61 @Override 62 public void onLocalVoiceInteractionStopped() { 63 Log.i(TAG, " in onLocalVoiceInteractionStarted"); 64 if (mStopped != null) { 65 mStopped.countDown(); 66 } 67 } 68 } 69