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#pragma once 18 19#include <android/hardware/wifi/1.0/IWifi.h> 20#include <android/hardware/wifi/1.0/IWifiApIface.h> 21#include <android/hardware/wifi/1.0/IWifiChip.h> 22#include <android/hardware/wifi/1.0/IWifiNanIface.h> 23#include <android/hardware/wifi/1.0/IWifiP2pIface.h> 24#include <android/hardware/wifi/1.0/IWifiRttController.h> 25#include <android/hardware/wifi/1.0/IWifiStaIface.h> 26 27#include <getopt.h> 28 29#include <VtsHalHidlTargetTestEnvBase.h> 30// Helper functions to obtain references to the various HIDL interface objects. 31// Note: We only have a single instance of each of these objects currently. 32// These helper functions should be modified to return vectors if we support 33// multiple instances. 34android::sp<android::hardware::wifi::V1_0::IWifi> getWifi(); 35android::sp<android::hardware::wifi::V1_0::IWifiChip> getWifiChip(); 36android::sp<android::hardware::wifi::V1_0::IWifiApIface> getWifiApIface(); 37android::sp<android::hardware::wifi::V1_0::IWifiNanIface> getWifiNanIface(); 38android::sp<android::hardware::wifi::V1_0::IWifiP2pIface> getWifiP2pIface(); 39android::sp<android::hardware::wifi::V1_0::IWifiStaIface> getWifiStaIface(); 40android::sp<android::hardware::wifi::V1_0::IWifiRttController> 41getWifiRttController(); 42// Configure the chip in a mode to support the creation of the provided 43// iface type. 44bool configureChipToSupportIfaceType( 45 const android::sp<android::hardware::wifi::V1_0::IWifiChip>& wifi_chip, 46 android::hardware::wifi::V1_0::IfaceType type, 47 android::hardware::wifi::V1_0::ChipModeId* configured_mode_id); 48// Used to trigger IWifi.stop() at the end of every test. 49void stopWifi(); 50 51class WifiHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase { 52 protected: 53 virtual void HidlSetUp() override { 54 stopWifi(); 55 sleep(5); 56 } 57 58 public: 59 // Whether NaN feature is supported on the device. 60 bool isNanOn = false; 61 62 void usage(char* me, char* arg) { 63 fprintf(stderr, 64 "unrecognized option: %s\n\n" 65 "usage: %s <gtest options> <test options>\n\n" 66 "test options are:\n\n" 67 "-N, --nan_on: Whether NAN feature is supported\n", 68 arg, me); 69 } 70 71 int initFromOptions(int argc, char** argv) { 72 static struct option options[] = {{"nan_on", no_argument, 0, 'N'}, 73 {0, 0, 0, 0}}; 74 75 int c; 76 while ((c = getopt_long(argc, argv, "N", options, NULL)) >= 0) { 77 switch (c) { 78 case 'N': 79 isNanOn = true; 80 break; 81 default: 82 usage(argv[0], argv[optind]); 83 return 2; 84 } 85 } 86 87 if (optind < argc) { 88 usage(argv[0], argv[optind]); 89 return 2; 90 } 91 92 return 0; 93 } 94}; 95