Skip to content

Commit

Permalink
Update Android SDK to 26 (#25856)
Browse files Browse the repository at this point in the history
* 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 <andy314@gmail.com>
  • Loading branch information
2 people authored and pull[bot] committed Aug 28, 2023
1 parent 7018227 commit 1409448
Show file tree
Hide file tree
Showing 15 changed files with 31 additions and 176 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/full-android.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/smoketest-android.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion build/config/android/config.gni
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ declare_args() {
android_ndk_root = ""

# Version of the Android SDK.
android_sdk_version = 21
android_sdk_version = 26
}
4 changes: 2 additions & 2 deletions examples/tv-app/android/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down
4 changes: 2 additions & 2 deletions examples/tv-casting-app/android/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down
2 changes: 1 addition & 1 deletion gn_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions integrations/cloudbuild/build-all.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions integrations/cloudbuild/chef.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand Down
14 changes: 7 additions & 7 deletions integrations/cloudbuild/smoke-test.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
steps:
- name: "connectedhomeip/chip-build-vscode:0.6.48"
- name: "connectedhomeip/chip-build-vscode:0.6.51"
entrypoint: "bash"
args:
- "-c"
- |
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:
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/app/server/java/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
8 changes: 4 additions & 4 deletions src/controller/java/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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") {
Expand Down Expand Up @@ -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"
}
}
145 changes: 0 additions & 145 deletions src/inet/InetInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
}
Expand All @@ -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)
{
Expand Down
Loading

0 comments on commit 1409448

Please sign in to comment.