From 14094488852189a3632b582b2075e78387cfea59 Mon Sep 17 00:00:00 2001 From: Matthew Swartwout Date: Thu, 30 Mar 2023 10:37:22 -0700 Subject: [PATCH] Update Android SDK to 26 (#25856) * Remove support for Android versions less than 24 Matter requires RIO, which is not supported on versions < 26. * Raise Android API version from 21 to 26 * Use 0.6.51 vscode image for android builds --------- Co-authored-by: Andrei Litvin --- .github/workflows/full-android.yaml | 2 +- .github/workflows/smoketest-android.yaml | 2 +- build/config/android/config.gni | 2 +- examples/tv-app/android/BUILD.gn | 4 +- examples/tv-casting-app/android/BUILD.gn | 4 +- gn_build.sh | 2 +- integrations/cloudbuild/build-all.yaml | 6 +- integrations/cloudbuild/chef.yaml | 6 +- integrations/cloudbuild/smoke-test.yaml | 14 +-- src/app/server/java/BUILD.gn | 4 +- src/controller/java/BUILD.gn | 8 +- src/inet/InetInterface.cpp | 145 ----------------------- src/messaging/tests/java/BUILD.gn | 4 +- src/platform/android/BUILD.gn | 2 +- src/setup_payload/java/BUILD.gn | 2 +- 15 files changed, 31 insertions(+), 176 deletions(-) diff --git a/.github/workflows/full-android.yaml b/.github/workflows/full-android.yaml index d28d3fb1679b2d..886a9462de9673 100644 --- a/.github/workflows/full-android.yaml +++ b/.github/workflows/full-android.yaml @@ -37,7 +37,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-android:0.6.47 + image: connectedhomeip/chip-build-android:0.6.51 volumes: - "/tmp/log_output:/tmp/test_logs" diff --git a/.github/workflows/smoketest-android.yaml b/.github/workflows/smoketest-android.yaml index 90987df038cb79..3664cc46aa9de1 100644 --- a/.github/workflows/smoketest-android.yaml +++ b/.github/workflows/smoketest-android.yaml @@ -38,7 +38,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-android:0.6.47 + image: connectedhomeip/chip-build-android:0.6.51 volumes: - "/tmp/log_output:/tmp/test_logs" diff --git a/build/config/android/config.gni b/build/config/android/config.gni index 508543144bc0f0..ca2b0afc9a8171 100644 --- a/build/config/android/config.gni +++ b/build/config/android/config.gni @@ -20,5 +20,5 @@ declare_args() { android_ndk_root = "" # Version of the Android SDK. - android_sdk_version = 21 + android_sdk_version = 26 } diff --git a/examples/tv-app/android/BUILD.gn b/examples/tv-app/android/BUILD.gn index 9d4993c89e2d2d..b414dd4d593746 100644 --- a/examples/tv-app/android/BUILD.gn +++ b/examples/tv-app/android/BUILD.gn @@ -151,11 +151,11 @@ android_library("java") { javac_flags = [ "-Xlint:deprecation" ] # TODO: add classpath support (we likely need to add something like - # ..../platforms/android-21/android.jar to access BLE items) + # ..../platforms/android-26/android.jar to access BLE items) } java_prebuilt("android") { - jar_path = "${android_sdk_root}/platforms/android-21/android.jar" + jar_path = "${android_sdk_root}/platforms/android-26/android.jar" } group("default") { diff --git a/examples/tv-casting-app/android/BUILD.gn b/examples/tv-casting-app/android/BUILD.gn index 033ff3aff14e53..35a77c84e027f3 100644 --- a/examples/tv-casting-app/android/BUILD.gn +++ b/examples/tv-casting-app/android/BUILD.gn @@ -86,11 +86,11 @@ android_library("java") { javac_flags = [ "-Xlint:deprecation" ] # TODO: add classpath support (we likely need to add something like - # ..../platforms/android-21/android.jar to access BLE items) + # ..../platforms/android-26/android.jar to access BLE items) } java_prebuilt("android") { - jar_path = "${android_sdk_root}/platforms/android-21/android.jar" + jar_path = "${android_sdk_root}/platforms/android-26/android.jar" } group("default") { diff --git a/gn_build.sh b/gn_build.sh index 18473f34f6d517..9f6c76571da593 100755 --- a/gn_build.sh +++ b/gn_build.sh @@ -126,7 +126,7 @@ else echo echo "Hint: Set \$ANDROID_HOME and \$ANDROID_NDK_HOME to enable building for Android" echo " The required android sdk platform version is 21. It can be obtained from" - echo " https://dl.google.com/android/repository/android-21_r02.zip" + echo " https://dl.google.com/android/repository/platform-26_r02.zip" fi echo diff --git a/integrations/cloudbuild/build-all.yaml b/integrations/cloudbuild/build-all.yaml index 09a7f34edda33f..8bee7b8b446e88 100644 --- a/integrations/cloudbuild/build-all.yaml +++ b/integrations/cloudbuild/build-all.yaml @@ -6,7 +6,7 @@ steps: - "--init" - "--recursive" id: Submodules - - name: "connectedhomeip/chip-build-vscode:0.6.48" + - name: "connectedhomeip/chip-build-vscode:0.6.51" env: - PW_ENVIRONMENT_ROOT=/pwenv args: @@ -21,7 +21,7 @@ steps: path: /pwenv timeout: 900s - - name: "connectedhomeip/chip-build-vscode:0.6.48" + - name: "connectedhomeip/chip-build-vscode:0.6.51" env: - PW_ENVIRONMENT_ROOT=/pwenv args: @@ -76,7 +76,7 @@ steps: --target k32w-shell build --create-archives /workspace/artifacts/ - - name: "connectedhomeip/chip-build-vscode:0.6.48" + - name: "connectedhomeip/chip-build-vscode:0.6.51" env: - PW_ENVIRONMENT_ROOT=/pwenv args: diff --git a/integrations/cloudbuild/chef.yaml b/integrations/cloudbuild/chef.yaml index a2b209ebf1fc94..576b1e128aae96 100644 --- a/integrations/cloudbuild/chef.yaml +++ b/integrations/cloudbuild/chef.yaml @@ -1,5 +1,5 @@ steps: - - name: "connectedhomeip/chip-build-vscode:0.6.48" + - name: "connectedhomeip/chip-build-vscode:0.6.51" env: - PW_ENVIRONMENT_ROOT=/pwenv args: @@ -12,7 +12,7 @@ steps: path: /pwenv timeout: 2700s - - name: "connectedhomeip/chip-build-vscode:0.6.48" + - name: "connectedhomeip/chip-build-vscode:0.6.51" env: - PW_ENVIRONMENT_ROOT=/pwenv args: @@ -26,7 +26,7 @@ steps: - name: pwenv path: /pwenv - - name: "connectedhomeip/chip-build-vscode:0.6.48" + - name: "connectedhomeip/chip-build-vscode:0.6.51" env: - PW_ENVIRONMENT_ROOT=/pwenv args: diff --git a/integrations/cloudbuild/smoke-test.yaml b/integrations/cloudbuild/smoke-test.yaml index 25232f3d742ab1..77c6c02ca7695d 100644 --- a/integrations/cloudbuild/smoke-test.yaml +++ b/integrations/cloudbuild/smoke-test.yaml @@ -1,5 +1,5 @@ steps: - - name: "connectedhomeip/chip-build-vscode:0.6.48" + - name: "connectedhomeip/chip-build-vscode:0.6.51" entrypoint: "bash" args: - "-c" @@ -7,7 +7,7 @@ steps: git config --global --add safe.directory "*" git submodule update --init --recursive id: Submodules - - name: "connectedhomeip/chip-build-vscode:0.6.48" + - name: "connectedhomeip/chip-build-vscode:0.6.51" env: - PW_ENVIRONMENT_ROOT=/pwenv args: @@ -22,7 +22,7 @@ steps: path: /pwenv timeout: 900s - - name: "connectedhomeip/chip-build-vscode:0.6.48" + - name: "connectedhomeip/chip-build-vscode:0.6.51" id: ESP32 env: - PW_ENVIRONMENT_ROOT=/pwenv @@ -41,7 +41,7 @@ steps: volumes: - name: pwenv path: /pwenv - - name: "connectedhomeip/chip-build-vscode:0.6.48" + - name: "connectedhomeip/chip-build-vscode:0.6.51" id: NRFConnect env: - PW_ENVIRONMENT_ROOT=/pwenv @@ -62,7 +62,7 @@ steps: - name: pwenv path: /pwenv - - name: "connectedhomeip/chip-build-vscode:0.6.48" + - name: "connectedhomeip/chip-build-vscode:0.6.51" id: EFR32 env: - PW_ENVIRONMENT_ROOT=/pwenv @@ -84,7 +84,7 @@ steps: - name: pwenv path: /pwenv - - name: "connectedhomeip/chip-build-vscode:0.6.48" + - name: "connectedhomeip/chip-build-vscode:0.6.51" id: Linux env: - PW_ENVIRONMENT_ROOT=/pwenv @@ -144,7 +144,7 @@ steps: - name: pwenv path: /pwenv - - name: "connectedhomeip/chip-build-vscode:0.6.48" + - name: "connectedhomeip/chip-build-vscode:0.6.51" id: Android env: - PW_ENVIRONMENT_ROOT=/pwenv diff --git a/src/app/server/java/BUILD.gn b/src/app/server/java/BUILD.gn index fa3a49f8be2737..a99d98ebb842fd 100644 --- a/src/app/server/java/BUILD.gn +++ b/src/app/server/java/BUILD.gn @@ -70,9 +70,9 @@ android_library("java") { javac_flags = [ "-Xlint:deprecation" ] # TODO: add classpath support (we likely need to add something like - # ..../platforms/android-21/android.jar to access BLE items) + # ..../platforms/android-26/android.jar to access BLE items) } java_prebuilt("android") { - jar_path = "${android_sdk_root}/platforms/android-21/android.jar" + jar_path = "${android_sdk_root}/platforms/android-26/android.jar" } diff --git a/src/controller/java/BUILD.gn b/src/controller/java/BUILD.gn index ce113422854bcb..60427564a26525 100644 --- a/src/controller/java/BUILD.gn +++ b/src/controller/java/BUILD.gn @@ -286,7 +286,7 @@ android_library("java") { ] # TODO: add classpath support (we likely need to add something like - # ..../platforms/android-21/android.jar to access BLE items) + # ..../platforms/android-26/android.jar to access BLE items) } if (chip_link_tests) { @@ -318,7 +318,7 @@ if (chip_link_tests) { javac_flags = [ "-Xlint:deprecation" ] # TODO: add classpath support (we likely need to add something like - # ..../platforms/android-21/android.jar to access BLE items) + # ..../platforms/android-26/android.jar to access BLE items) } android_library("tests") { @@ -353,12 +353,12 @@ if (chip_link_tests) { javac_flags = [ "-Xlint:deprecation" ] # TODO: add classpath support (we likely need to add something like - # ..../platforms/android-21/android.jar to access BLE items) + # ..../platforms/android-26/android.jar to access BLE items) } } if (!build_java_matter_controller) { java_prebuilt("android") { - jar_path = "${android_sdk_root}/platforms/android-21/android.jar" + jar_path = "${android_sdk_root}/platforms/android-26/android.jar" } } diff --git a/src/inet/InetInterface.cpp b/src/inet/InetInterface.cpp index 88c2176f9bb32c..7c09c9f12edd61 100644 --- a/src/inet/InetInterface.cpp +++ b/src/inet/InetInterface.cpp @@ -507,143 +507,6 @@ void CloseIOCTLSocket() } } -#if __ANDROID__ && __ANDROID_API__ < 24 - -static struct if_nameindex * backport_if_nameindex(void); -static void backport_if_freenameindex(struct if_nameindex *); - -static void backport_if_freenameindex(struct if_nameindex * inArray) -{ - if (inArray == NULL) - { - return; - } - - for (size_t i = 0; inArray[i].if_index != 0; i++) - { - if (inArray[i].if_name != NULL) - { - Platform::MemoryFree(inArray[i].if_name); - } - } - - Platform::MemoryFree(inArray); -} - -static struct if_nameindex * backport_if_nameindex(void) -{ - int err; - unsigned index; - size_t intfIter = 0; - size_t maxIntfNum = 0; - size_t numIntf = 0; - size_t numAddrs = 0; - struct if_nameindex * retval = NULL; - struct if_nameindex * tmpval = NULL; - struct ifaddrs * addrList = NULL; - struct ifaddrs * addrIter = NULL; - const char * lastIntfName = ""; - - err = getifaddrs(&addrList); - VerifyOrExit(err >= 0, ); - - // coalesce on consecutive interface names - for (addrIter = addrList; addrIter != NULL; addrIter = addrIter->ifa_next) - { - numAddrs++; - if (strcmp(addrIter->ifa_name, lastIntfName) == 0) - { - continue; - } - numIntf++; - lastIntfName = addrIter->ifa_name; - } - - tmpval = (struct if_nameindex *) Platform::MemoryAlloc((numIntf + 1) * sizeof(struct if_nameindex)); - VerifyOrExit(tmpval != NULL, ); - memset(tmpval, 0, (numIntf + 1) * sizeof(struct if_nameindex)); - - lastIntfName = ""; - for (addrIter = addrList; addrIter != NULL; addrIter = addrIter->ifa_next) - { - if (strcmp(addrIter->ifa_name, lastIntfName) == 0) - { - continue; - } - - index = if_nametoindex(addrIter->ifa_name); - if (index != 0) - { - tmpval[intfIter].if_index = index; - tmpval[intfIter].if_name = strdup(addrIter->ifa_name); - intfIter++; - } - lastIntfName = addrIter->ifa_name; - } - - // coalesce on interface index - maxIntfNum = 0; - for (size_t i = 0; tmpval[i].if_index != 0; i++) - { - if (maxIntfNum < tmpval[i].if_index) - { - maxIntfNum = tmpval[i].if_index; - } - } - - retval = (struct if_nameindex *) Platform::MemoryAlloc((maxIntfNum + 1) * sizeof(struct if_nameindex)); - VerifyOrExit(retval != NULL, ); - memset(retval, 0, (maxIntfNum + 1) * sizeof(struct if_nameindex)); - - for (size_t i = 0; tmpval[i].if_index != 0; i++) - { - struct if_nameindex * intf = &tmpval[i]; - if (retval[intf->if_index - 1].if_index == 0) - { - retval[intf->if_index - 1] = *intf; - } - else - { - free(intf->if_name); - intf->if_index = 0; - intf->if_name = 0; - } - } - - intfIter = 0; - - // coalesce potential gaps between indeces - for (size_t i = 0; i < maxIntfNum; i++) - { - if (retval[i].if_index != 0) - { - retval[intfIter] = retval[i]; - intfIter++; - } - } - - for (size_t i = intfIter; i < maxIntfNum; i++) - { - retval[i].if_index = 0; - retval[i].if_name = NULL; - } - -exit: - if (tmpval != NULL) - { - Platform::MemoryFree(tmpval); - } - - if (addrList != NULL) - { - freeifaddrs(addrList); - } - - return retval; -} - -#endif // __ANDROID__ && __ANDROID_API__ < 24 - InterfaceIterator::InterfaceIterator() { mIntfArray = nullptr; @@ -656,11 +519,7 @@ InterfaceIterator::~InterfaceIterator() { if (mIntfArray != nullptr) { -#if __ANDROID__ && __ANDROID_API__ < 24 - backport_if_freenameindex(mIntfArray); -#else if_freenameindex(mIntfArray); -#endif mIntfArray = nullptr; } } @@ -674,11 +533,7 @@ bool InterfaceIterator::Next() { if (mIntfArray == nullptr) { -#if __ANDROID__ && __ANDROID_API__ < 24 - mIntfArray = backport_if_nameindex(); -#else mIntfArray = if_nameindex(); -#endif } else if (mIntfArray[mCurIntf].if_index != 0) { diff --git a/src/messaging/tests/java/BUILD.gn b/src/messaging/tests/java/BUILD.gn index 59030145309dec..25c9b950200efd 100644 --- a/src/messaging/tests/java/BUILD.gn +++ b/src/messaging/tests/java/BUILD.gn @@ -70,11 +70,11 @@ android_library("java") { javac_flags = [ "-Xlint:deprecation" ] # TODO: add classpath support (we likely need to add something like - # ..../platforms/android-21/android.jar to access BLE items) + # ..../platforms/android-26/android.jar to access BLE items) } if (!build_java_matter_controller) { java_prebuilt("android") { - jar_path = "${android_sdk_root}/platforms/android-21/android.jar" + jar_path = "${android_sdk_root}/platforms/android-26/android.jar" } } diff --git a/src/platform/android/BUILD.gn b/src/platform/android/BUILD.gn index 3611db0267e841..8c49d86050aa87 100644 --- a/src/platform/android/BUILD.gn +++ b/src/platform/android/BUILD.gn @@ -105,5 +105,5 @@ android_library("java") { } java_prebuilt("android_sdk") { - jar_path = "${android_sdk_root}/platforms/android-21/android.jar" + jar_path = "${android_sdk_root}/platforms/android-26/android.jar" } diff --git a/src/setup_payload/java/BUILD.gn b/src/setup_payload/java/BUILD.gn index fcf690b74ec236..a1c2cb21cfea90 100644 --- a/src/setup_payload/java/BUILD.gn +++ b/src/setup_payload/java/BUILD.gn @@ -60,5 +60,5 @@ android_library("java") { ] # TODO: add classpath support (we likely need to add something like - # ..../platforms/android-21/android.jar to access BLE items) + # ..../platforms/android-26/android.jar to access BLE items) }