gts 蓝牙 testA2dpSinkGetConnectionPolicy测试失败问题分析

run gts -m GtsGmscoreHostTestCases -t com.google.android.gts.bluetooth.BluetoothHostTest#testA2dpSinkGetConnectionPolicy

问题log:

01-14 10:41:10.529  4101  4101 I AdapterServiceConfig: addAudioProfiles isA2dpSink :false
01-14 10:41:10.546  4101  4101 I droid.bluetoot: [0114/104110.546092:INFO:com_android_bluetooth_btservice_AdapterService.cpp(644)] hal_util_load_bt_library loaded HAL: btinterface=0x6e23086c18, handle=0x343bbfe84aa79c2d
01-14 10:41:10.546  4101  4101 D BluetoothAdapterService: getAdapterService() - returning null
01-14 10:41:10.546  4101  4101 E AdapterServiceConfig: adapterService is null
01-14 10:41:10.546  4101  4101 V AdapterServiceConfig: Adding HeadsetService
01-14 10:41:10.546  4101  4101 D AdapterServiceConfig:  addAudioProfiles profileA2dpService
01-14 10:41:10.546  4101  4101 I AdapterServiceConfig: addAudioProfiles isA2dpSink :false
01-14 10:41:10.546  4101  4101 D BluetoothAdapterService: getAdapterService() - returning null
01-14 10:41:10.546  4101  4101 E AdapterServiceConfig: adapterService is null
01-14 10:41:10.546  4101  4101 V AdapterServiceConfig: Adding A2dpService
01-14 10:41:10.547  4101  4101 D AdapterServiceConfig:  addAudioProfiles profileA2dpSinkService
01-14 10:41:10.547  4101  4101 I AdapterServiceConfig: addAudioProfiles isA2dpSink :false
01-14 10:41:10.547  4101  4101 I AdapterServiceConfig:  Profile A2dpSinkService Not added
01-14 10:41:10.547  4101  4101 D AdapterServiceConfig:  addAudioProfiles profileHidHostService
01-14 10:41:10.547  4101  4101 I AdapterServiceConfig: addAudioProfiles isA2dpSink :false
01-14 10:41:10.547  4101  4101 D BluetoothAdapterService: getAdapterService() - returning null

从上面的log看到  Profile A2dpSinkService Not added, 从代码可以看到:isA2dpSink :false, Profile A2dpSinkService Not added

对应的代码如下:

/android/vendor/qcom/opensource/commonsys/packages/apps/Bluetooth/src/com/android/bluetooth/btservice/Config.java

private static synchronized boolean addAudioProfiles(String serviceName) {
173          Log.d(TAG," addAudioProfiles profile" + serviceName);
174          boolean isA2dpSink = SystemProperties.getBoolean(
175                  "persist.vendor.service.bt.a2dp.sink", false);
176          Log.i(TAG, "addAudioProfiles isA2dpSink :" + isA2dpSink);
177          /* If property not enabled and request is for A2DPSinkService, don't add */
178          if ((serviceName.equals("A2dpSinkService")) && (!isA2dpSink))
179              return false;
180          if ((serviceName.equals("A2dpService")) && (isA2dpSink))
181              return false;
182  
183          boolean isBAEnabled = SystemProperties.getBoolean("persist.vendor.service.bt.bca", false);
184  
185          // Split A2dp will be enabled by default
186          boolean isSplitA2dpEnabled = true;
187          AdapterService adapterService = AdapterService.getAdapterService();
188  
189          if (adapterService != null){
190              isSplitA2dpEnabled = adapterService.isSplitA2dpEnabled();
191              Log.v(TAG,"isSplitA2dpEnabled: " + isSplitA2dpEnabled);
192          } else {
193              Log.e(TAG,"adapterService is null");
194          }
195  
196          if(serviceName.equals("BATService")) {
197              Log.d(TAG," isBAEnabled = " + isBAEnabled
198                            + " isSplitEnabled " + isSplitA2dpEnabled);
199              return isBAEnabled && isSplitA2dpEnabled;
200          }
201          // always return true for other profiles
202          return true;
203      }

可以看到persist.vendor.service.bt.a2dp.sink 为false导致的。

查看代码为true的地方如下:

/sm4350/android/vendor/qcom/opensource/commonsys/system/bt/btif/src/btif_a2dp_sink.cc

bool btif_a2dp_sink_startup(void) {

#if (OFF_TARGET_TEST_ENABLED == TRUE)
184    property_set("persist.vendor.service.bt.a2dp.sink", "true");
185  #endif

}

因此该问题的修改办法是屏蔽这个if 判断或者检查关闭sink这个功能。

gts测试case的地方有如下判断:

super.setUp();
    if (ApiLevelUtil.isAtLeast(30))
    {
      boolean bool1 = getContext().getPackageManager().hasSystemFeature("android.hardware.bluetooth");
      this.mHasBluetooth = bool1;
      if (!bool1) {
        return;
      }
      BluetoothAdapter localBluetoothAdapter = ((BluetoothManager)getContext().getSystemService(BluetoothManager.class)).getAdapter();
      this.mAdapter = localBluetoothAdapter;
      assertTrue(BluetoothTestUtils.enableAdapter(localBluetoothAdapter, this.mContext));
      ReentrantLock localReentrantLock = new ReentrantLock();
      this.mProfileConnectedlock = localReentrantLock;
      this.mConditionProfileIsConnected = localReentrantLock.newCondition();
      this.mIsProfileReady = false;
      this.mBluetoothA2dpSink = null;
      Resources localResources = this.mContext.getPackageManager().getResourcesForApplication("com.android.bluetooth");
      int i = localResources.getIdentifier("profile_supported_a2dp_sink", "bool", "com.android.bluetooth");
      boolean bool2 = false;
      if (i != 0) {
        bool2 = true;
      }
      assertTrue("resource profile_supported_a2dp_sink not found", bool2);
      boolean bool3 = localResources.getBoolean(i);
      this.mIsA2dpSinkSupported = bool3;
      if (!bool3) {
        return;
      }
      this.mAdapter.getProfileProxy(getContext(), new BluetoothA2dpSinkServiceListener(null), 11);
    }
  }

从上面的判断可以看出profile_supported_a2dp_sink为false的时候会直接return,测试结果pass 。

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值