目录

Initiating and Releasing Multi-Network Concurrency (C/C++)

Starting from version 6.0.2(22), this kit supports initiation and release of multi-network concurrency.

Use Case

Your app can initiate multi-network concurrency for network acceleration based on the service needs and relevant suggestions provided by the device, and promptly release it when the use is complete. Wi-Fi–cellular and primary–secondary SIM combinations are supported for concurrency. Connection paths cannot be freely combined. All combinations are determined by the device.

  • Primary–secondary SIM concurrency requires that Smart Data Switch be enabled and depends on the frequencies of the networks the two SIM cards reside on. If concurrency conditions are not met (for example, when both SIM cards are from the same carrier), multi-network concurrency initiation will fail.

  • Due to hardware restrictions, some devices do not support multi-network concurrency in dual-SIM scenarios. You can check the returned error code for details.

  • If the current transmission protocol does not support a specific network to be added for multi-network concurrency, that network cannot be used. For example, if HTTP supports only the default network, but does not support the added network, multi-network concurrency is not available.

Preparations

To initiate multi-network concurrency, ensure that the network acceleration switch is enabled under Settings > Mobile network > Network acceleration on the device. If you cannot find this switch on a device, the device/ROM does not support multi-network concurrency.

API Description

For details about the APIs, please refer to API Reference.

API Description
int32_t HMS_NetworkBoost_RequestMultiPath(HMS_NetworkBoost_OnMultiPathRequestResult result) Initiates a multi-network concurrency request.
int32_t HMS_NetworkBoost_ReleaseMultiPath() Releases multi-network concurrency.

Development Procedure

  1. Import the Network Boost Kit module.

    #include "NetworkBoostKit/network_boost_handover.h"
    #include <cstdio>
  2. Add the following library to the CMakeLists.txt file. For details, please refer to Preparations for C API Development.

    libnetwork_boost.so
  3. Initiate a multi-network concurrency request and listen for multi-network concurrency status changes.

    void onMultiPathRequestResultCallback(NetworkBoost_MultiPathRequestResult* result)
    {
        // Process the multi-network concurrency request result.
    }
    
    int32_t RequestMultiPath()
    {
        // Initiate a multi-network concurrency request.
        int32_t ret = HMS_NetworkBoost_RequestMultiPath(onMultiPathRequestResultCallback);
        printf("Result of registering the callback for multi-network concurrency suggestion changes: %d\n", ret);
        return ret;
    }
  4. Call the ReleasetMultipath API to release multi-network concurrency after your app process ends.

    int32_t ReleasetMultipath()
    {
        // Release multi-network concurrency.
        int32_t ret = HMS_NetworkBoost_ReleaseMultiPath();
        printf("Result of releasing multi-network concurrency: %d\n", ret);
        return ret;
    }