Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ba70b643 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 4716599 from 1f88e209 to pi-release

Change-Id: Ia07f982ad69ac9f66d88cfeab52c14a1ce75db55
parents 22448b38 1f88e209
Loading
Loading
Loading
Loading
+26 −0
Original line number Diff line number Diff line
//
// Copyright (C) 2018 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

cc_test {
    name: "VtsHalBluetoothA2dpV1_0TargetTest",
    defaults: ["VtsHalTargetTestDefaults"],
    srcs: ["VtsHalBluetoothA2dpV1_0TargetTest.cpp"],
    static_libs: [
        "android.hardware.bluetooth@1.0",
        "android.hardware.bluetooth.a2dp@1.0",
        "libbluetooth-types",
    ],
}
+126 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#define LOG_TAG "bluetooth_a2dp_hidl_hal_test"

#include <android-base/logging.h>
#include <android/hardware/bluetooth/a2dp/1.0/IBluetoothAudioHost.h>
#include <android/hardware/bluetooth/a2dp/1.0/IBluetoothAudioOffload.h>
#include <hardware/bluetooth.h>
#include <utils/Log.h>

#include <VtsHalHidlTargetCallbackBase.h>
#include <VtsHalHidlTargetTestBase.h>
#include <VtsHalHidlTargetTestEnvBase.h>

using ::android::hardware::bluetooth::a2dp::V1_0::IBluetoothAudioHost;
using ::android::hardware::bluetooth::a2dp::V1_0::IBluetoothAudioOffload;
using ::android::hardware::bluetooth::a2dp::V1_0::Status;
using ::android::hardware::bluetooth::a2dp::V1_0::CodecType;
using ::android::hardware::bluetooth::a2dp::V1_0::SampleRate;
using ::android::hardware::bluetooth::a2dp::V1_0::BitsPerSample;
using ::android::hardware::bluetooth::a2dp::V1_0::ChannelMode;
using ::android::hardware::bluetooth::a2dp::V1_0::CodecConfiguration;
using ::android::hardware::Return;
using ::android::hardware::Void;
using ::android::sp;

// Test environment for Bluetooth HIDL A2DP HAL.
class BluetoothA2dpHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
   public:
    // get the test environment singleton
    static BluetoothA2dpHidlEnvironment* Instance() {
        static BluetoothA2dpHidlEnvironment* instance = new BluetoothA2dpHidlEnvironment;
        return instance;
    }

    virtual void registerTestServices() override { registerTestService<IBluetoothAudioOffload>(); }

   private:
    BluetoothA2dpHidlEnvironment() {}
};

// The main test class for Bluetooth A2DP HIDL HAL.
class BluetoothA2dpHidlTest : public ::testing::VtsHalHidlTargetTestBase {
   public:
    virtual void SetUp() override {
        // currently test passthrough mode only
        audio_offload = ::testing::VtsHalHidlTargetTestBase::getService<IBluetoothAudioOffload>(
            BluetoothA2dpHidlEnvironment::Instance()->getServiceName<IBluetoothAudioOffload>());
        ASSERT_NE(audio_offload, nullptr);

        audio_host = new BluetoothAudioHost(*this);
        ASSERT_NE(audio_host, nullptr);

        codec.codecType = CodecType::AAC;
        codec.sampleRate = SampleRate::RATE_44100;
        codec.bitsPerSample = BitsPerSample::BITS_16;
        codec.channelMode = ChannelMode::STEREO;
        codec.encodedAudioBitrate = 320000;
        codec.peerMtu = 1000;
    }

    virtual void TearDown() override {}

    // A simple test implementation of IBluetoothAudioHost.
    class BluetoothAudioHost
        : public ::testing::VtsHalHidlTargetCallbackBase<BluetoothA2dpHidlTest>,
          public IBluetoothAudioHost {
        BluetoothA2dpHidlTest& parent_;

       public:
        BluetoothAudioHost(BluetoothA2dpHidlTest& parent) : parent_(parent){};
        virtual ~BluetoothAudioHost() = default;

        Return<void> startStream() override {
            parent_.audio_offload->streamStarted(Status::SUCCESS);
            return Void();
        };

        Return<void> suspendStream() override {
            parent_.audio_offload->streamSuspended(Status::SUCCESS);
            return Void();
        };

        Return<void> stopStream() override { return Void(); };
    };

    // audio_host is for the Audio HAL to send stream start/suspend/stop commands to Bluetooth
    sp<IBluetoothAudioHost> audio_host;
    // audio_offload is for the Bluetooth HAL to report session started/ended and handled audio
    // stream started/suspended
    sp<IBluetoothAudioOffload> audio_offload;
    // codec is the currently used codec
    CodecConfiguration codec;
};

// Empty test: Initialize()/Close() are called in SetUp()/TearDown().
TEST_F(BluetoothA2dpHidlTest, InitializeAndClose) {}

// Test start and end session
TEST_F(BluetoothA2dpHidlTest, StartAndEndSession) {
    EXPECT_EQ(Status::SUCCESS, audio_offload->startSession(audio_host, codec));
    audio_offload->endSession();
}

int main(int argc, char** argv) {
    ::testing::AddGlobalTestEnvironment(BluetoothA2dpHidlEnvironment::Instance());
    ::testing::InitGoogleTest(&argc, argv);
    BluetoothA2dpHidlEnvironment::Instance()->init(&argc, argv);
    int status = RUN_ALL_TESTS();
    LOG(INFO) << "Test result = " << status;
    return status;
}
+6 −4
Original line number Diff line number Diff line
@@ -241,11 +241,11 @@ a432d6d9200248dc2126827bcd6cdea31dd65eff39b939f64585d27d915a5857 android.hardwar
86ba9c03978b79a742e990420bc5ced0673d25a939f82572996bef92621e2014 android.hardware.cas@1.0::IMediaCasService
503da837d1a67cbdb7c08a033e927e5430ae1b159d98bf72c6336b4dcc5e76f5 android.hardware.cas.native@1.0::types
619600109232ed64b827c8a11beed8070b1827ae464547d7aa146cf0473b4bca android.hardware.cas.native@1.0::IDescrambler
246a56d37d57a47224562c9d077b4a2886ce6242b9311bd98a17325944c280d7 android.hardware.neuralnetworks@1.0::types
93eb3757ceaf21590fa4cd1d4a7dfe3b3794af5396100a6d25630879352abce9 android.hardware.neuralnetworks@1.0::IDevice
f66f9a38541bf92001d3adcce678cd7e3da2262124befb460b1c9aea9492813b android.hardware.neuralnetworks@1.0::IExecutionCallback
953607822954435874f4b81686440a604e2a88cdd2d9164c6293f3d5772510d7 android.hardware.neuralnetworks@1.0::IPreparedModel
73e03573494ba96f0e711ab7f1956c5b2d54c3da690cd7ecf4d6d0f287447730 android.hardware.neuralnetworks@1.0::IPreparedModelCallback
246a56d37d57a47224562c9d077b4a2886ce6242b9311bd98a17325944c280d7 android.hardware.neuralnetworks@1.0::types
f4945e397b5dea41bb64518dfde59be71245d8a125fd1e0acffeb57ac7b08fed android.hardware.thermal@1.1::IThermal
c8bc853546dd55584611def2a9fa1d99f657e3366c976d2f60fe6b8aa6d2cb87 android.hardware.thermal@1.1::IThermalCallback

@@ -258,7 +258,9 @@ cf72ff5a52bfa4d08e9e1000cf3ab5952a2d280c7f13cdad5ab7905c08050766 android.hardwar
fb92e2b40f8e9d494e8fd3b4ac18499a3216342e7cff160714c3bbf3660b6e79 android.hardware.gnss@1.0::IGnssConfiguration
251594ea9b27447bfa005ebd806e58fb0ae4aad84a69938129c9800ec0c64eda android.hardware.gnss@1.0::IGnssMeasurementCallback
4e7169919d24fbe5573e5bcd683d0bd7abf553a4e6c34c41f9dfc1e12050db07 android.hardware.gnss@1.0::IGnssNavigationMessageCallback
1488db5ffb8a7979488d1084761aab8bca2f59bc9a02d75cdefc296afeaf591b android.hardware.neuralnetworks@1.0::types
5804ca86611d72e5481f022b3a0c1b334217f2e4988dad25730c42af2d1f4d1c android.hardware.neuralnetworks@1.0::IDevice
12e8dca4ab7d8aadd0ef8f1b438021938e2396139e85db2ed65783b08800aa52 android.hardware.neuralnetworks@1.0::IExecutionCallback
702f9a4cd3b7486a4b04f7155b737757ac2ca4b3548976d5782ad3cae9ff9780 android.hardware.neuralnetworks@1.0::types
d4840db8efabdf1e4b344fc981cd36e5fe81a39aff6e199f6d06c1c8da413efd android.hardware.radio@1.0::types
b280c4704dfcc548a9bf127b59b7c3578f460c50cce70a06b66fe0df8b27cff0 android.hardware.wifi@1.0::types

@@ -336,8 +338,8 @@ e15ebdf1e0a326ff5b8a59668d4d8cd3852bd88388eae91de13f5f7e1af50ed1 android.hardwar
b8c7ed58aa8740361e63d0ce9e7c94227572a629f356958840b34809d2393a7c android.hardware.media.bufferpool@1.0::IClientManager
4a2c0dc82780e6c90731725a103feab8ab6ecf85a64e049b9cbd2b2c61620fe1 android.hardware.media.bufferpool@1.0::IConnection
6aef1218e5949f867b0104752ac536c1b707222a403341720de90141df129e3e android.hardware.media.bufferpool@1.0::types
1529409ed76ae87facab152b770495e9e62544fcc5215daabf146c28d588bab9 android.hardware.neuralnetworks@1.1::IDevice
e808a6f61cd7b47887c599d8843e67a2dcbf4ec5aadd5d22fdce93020070ef1b android.hardware.neuralnetworks@1.1::types
3e4d8e0085ebe8549efb8ad4b8b400a141a3fa3f47ae23696b3e05a1612eb003 android.hardware.neuralnetworks@1.1::IDevice
50db076b03a6760557fc60ef433ba9dd2ff983cf3305eeb504b0fff3eaa604ff android.hardware.neuralnetworks@1.1::types
8d3d86da0bfa4bf070970d8303c659f67f35d670c287d45a3f542e4fedadd578 android.hardware.nfc@1.1::INfc
e85f566698d2a2c28100e264fcf2c691a066756ddf8dd341d009ff50cfe10614 android.hardware.nfc@1.1::INfcClientCallback
5e278fcaa3287d397d8eebe1c22aaa28150f5caae1cf9381cd6dc32cb37899c5 android.hardware.nfc@1.1::types
+0 −22
Original line number Diff line number Diff line
@@ -2917,28 +2917,6 @@ TEST_F(EncryptionOperationsTest, AesEcbRoundTripSuccess) {
    EXPECT_EQ(message, plaintext);
}

/*
 * EncryptionOperationsTest.AesEcbWithUserId
 *
 * Verifies that AES ECB mode works when Tag::USER_ID is specified.
 */
TEST_F(EncryptionOperationsTest, AesEcbWithUserId) {
    string key = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
    ASSERT_EQ(ErrorCode::OK, ImportKey(AuthorizationSetBuilder()
                                           .Authorization(TAG_NO_AUTH_REQUIRED)
                                           .Authorization(TAG_USER_ID, 0)
                                           .AesEncryptionKey(key.size() * 8)
                                           .EcbMode()
                                           .Padding(PaddingMode::PKCS7),
                                       KeyFormat::RAW, key));

    string message = "Hello World!";
    auto params = AuthorizationSetBuilder().BlockMode(BlockMode::ECB).Padding(PaddingMode::PKCS7);
    string ciphertext = EncryptMessage(message, params);
    string plaintext = DecryptMessage(ciphertext, params);
    EXPECT_EQ(message, plaintext);
}

/*
 * EncryptionOperationsTest.AesEcbRoundTripSuccess
 *
+1 −1
Original line number Diff line number Diff line
@@ -36,7 +36,7 @@ interface IDevice {
    /**
     * Gets the supported operations in a model.
     *
     * getSupportedSubgraph indicates which operations of a model are fully
     * getSupportedOperations indicates which operations of a model are fully
     * supported by the vendor driver. If an operation may not be supported for
     * any reason, getSupportedOperations must return false for that operation.
     *
Loading