1 /* 2 * Copyright (C) 2012 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 * use this file except in compliance with the License. You may obtain a copy of 6 * 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, WITHOUT 12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 * License for the specific language governing permissions and limitations under 14 * the License. 15 */ 16 17 #include "Log.h" 18 19 #include "Adb.h" 20 #include "ClientImpl.h" 21 22 23 ClientImpl::ClientImpl() 24 : mAudio(new RemoteAudio(mSocket)) 25 { 26 27 } 28 29 ClientImpl::~ClientImpl() 30 { 31 mAudio->release(); 32 } 33 34 bool ClientImpl::init(const android::String8& param) 35 { 36 Adb adb(param); 37 if (!adb.setPortForwarding(HOST_TCP_PORT, CLIENT_TCP_PORT)) { 38 LOGE("adb port forwarding failed"); 39 return false; 40 } 41 android::String8 clientBinary("client/CtsAudioClient.apk"); 42 android::String8 componentName("com.android.cts.audiotest/.CtsAudioClientActivity"); 43 if (!adb.launchClient(clientBinary, componentName)) { 44 LOGE("cannot install or launch client"); 45 return false; 46 } 47 // now socket connection 48 return mAudio->init(HOST_TCP_PORT); 49 } 50 51 52