Skip to content

Commit f7977bc

Browse files
mwswartwoutandy31415
andauthoredMar 30, 2023
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 <andy314@gmail.com>
1 parent ca5deb3 commit f7977bc

File tree

15 files changed

+31
-176
lines changed

15 files changed

+31
-176
lines changed
 

‎.github/workflows/full-android.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
if: github.actor != 'restyled-io[bot]'
3838

3939
container:
40-
image: connectedhomeip/chip-build-android:0.6.47
40+
image: connectedhomeip/chip-build-android:0.6.51
4141
volumes:
4242
- "/tmp/log_output:/tmp/test_logs"
4343

‎.github/workflows/smoketest-android.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
if: github.actor != 'restyled-io[bot]'
3939

4040
container:
41-
image: connectedhomeip/chip-build-android:0.6.47
41+
image: connectedhomeip/chip-build-android:0.6.51
4242
volumes:
4343
- "/tmp/log_output:/tmp/test_logs"
4444

‎build/config/android/config.gni

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ declare_args() {
2020
android_ndk_root = ""
2121

2222
# Version of the Android SDK.
23-
android_sdk_version = 21
23+
android_sdk_version = 26
2424
}

‎examples/tv-app/android/BUILD.gn

+2-2
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,11 @@ android_library("java") {
151151
javac_flags = [ "-Xlint:deprecation" ]
152152

153153
# TODO: add classpath support (we likely need to add something like
154-
# ..../platforms/android-21/android.jar to access BLE items)
154+
# ..../platforms/android-26/android.jar to access BLE items)
155155
}
156156

157157
java_prebuilt("android") {
158-
jar_path = "${android_sdk_root}/platforms/android-21/android.jar"
158+
jar_path = "${android_sdk_root}/platforms/android-26/android.jar"
159159
}
160160

161161
group("default") {

‎examples/tv-casting-app/android/BUILD.gn

+2-2
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,11 @@ android_library("java") {
8686
javac_flags = [ "-Xlint:deprecation" ]
8787

8888
# TODO: add classpath support (we likely need to add something like
89-
# ..../platforms/android-21/android.jar to access BLE items)
89+
# ..../platforms/android-26/android.jar to access BLE items)
9090
}
9191

9292
java_prebuilt("android") {
93-
jar_path = "${android_sdk_root}/platforms/android-21/android.jar"
93+
jar_path = "${android_sdk_root}/platforms/android-26/android.jar"
9494
}
9595

9696
group("default") {

‎gn_build.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ else
126126
echo
127127
echo "Hint: Set \$ANDROID_HOME and \$ANDROID_NDK_HOME to enable building for Android"
128128
echo " The required android sdk platform version is 21. It can be obtained from"
129-
echo " https://dl.google.com/android/repository/android-21_r02.zip"
129+
echo " https://dl.google.com/android/repository/platform-26_r02.zip"
130130
fi
131131

132132
echo

‎integrations/cloudbuild/build-all.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ steps:
66
- "--init"
77
- "--recursive"
88
id: Submodules
9-
- name: "connectedhomeip/chip-build-vscode:0.6.48"
9+
- name: "connectedhomeip/chip-build-vscode:0.6.51"
1010
env:
1111
- PW_ENVIRONMENT_ROOT=/pwenv
1212
args:
@@ -21,7 +21,7 @@ steps:
2121
path: /pwenv
2222
timeout: 900s
2323

24-
- name: "connectedhomeip/chip-build-vscode:0.6.48"
24+
- name: "connectedhomeip/chip-build-vscode:0.6.51"
2525
env:
2626
- PW_ENVIRONMENT_ROOT=/pwenv
2727
args:
@@ -76,7 +76,7 @@ steps:
7676
--target k32w-shell
7777
build
7878
--create-archives /workspace/artifacts/
79-
- name: "connectedhomeip/chip-build-vscode:0.6.48"
79+
- name: "connectedhomeip/chip-build-vscode:0.6.51"
8080
env:
8181
- PW_ENVIRONMENT_ROOT=/pwenv
8282
args:

‎integrations/cloudbuild/chef.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
steps:
2-
- name: "connectedhomeip/chip-build-vscode:0.6.48"
2+
- name: "connectedhomeip/chip-build-vscode:0.6.51"
33
env:
44
- PW_ENVIRONMENT_ROOT=/pwenv
55
args:
@@ -12,7 +12,7 @@ steps:
1212
path: /pwenv
1313
timeout: 2700s
1414

15-
- name: "connectedhomeip/chip-build-vscode:0.6.48"
15+
- name: "connectedhomeip/chip-build-vscode:0.6.51"
1616
env:
1717
- PW_ENVIRONMENT_ROOT=/pwenv
1818
args:
@@ -26,7 +26,7 @@ steps:
2626
- name: pwenv
2727
path: /pwenv
2828

29-
- name: "connectedhomeip/chip-build-vscode:0.6.48"
29+
- name: "connectedhomeip/chip-build-vscode:0.6.51"
3030
env:
3131
- PW_ENVIRONMENT_ROOT=/pwenv
3232
args:

‎integrations/cloudbuild/smoke-test.yaml

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
steps:
2-
- name: "connectedhomeip/chip-build-vscode:0.6.48"
2+
- name: "connectedhomeip/chip-build-vscode:0.6.51"
33
entrypoint: "bash"
44
args:
55
- "-c"
66
- |
77
git config --global --add safe.directory "*"
88
git submodule update --init --recursive
99
id: Submodules
10-
- name: "connectedhomeip/chip-build-vscode:0.6.48"
10+
- name: "connectedhomeip/chip-build-vscode:0.6.51"
1111
env:
1212
- PW_ENVIRONMENT_ROOT=/pwenv
1313
args:
@@ -22,7 +22,7 @@ steps:
2222
path: /pwenv
2323
timeout: 900s
2424

25-
- name: "connectedhomeip/chip-build-vscode:0.6.48"
25+
- name: "connectedhomeip/chip-build-vscode:0.6.51"
2626
id: ESP32
2727
env:
2828
- PW_ENVIRONMENT_ROOT=/pwenv
@@ -41,7 +41,7 @@ steps:
4141
volumes:
4242
- name: pwenv
4343
path: /pwenv
44-
- name: "connectedhomeip/chip-build-vscode:0.6.48"
44+
- name: "connectedhomeip/chip-build-vscode:0.6.51"
4545
id: NRFConnect
4646
env:
4747
- PW_ENVIRONMENT_ROOT=/pwenv
@@ -62,7 +62,7 @@ steps:
6262
- name: pwenv
6363
path: /pwenv
6464

65-
- name: "connectedhomeip/chip-build-vscode:0.6.48"
65+
- name: "connectedhomeip/chip-build-vscode:0.6.51"
6666
id: EFR32
6767
env:
6868
- PW_ENVIRONMENT_ROOT=/pwenv
@@ -84,7 +84,7 @@ steps:
8484
- name: pwenv
8585
path: /pwenv
8686

87-
- name: "connectedhomeip/chip-build-vscode:0.6.48"
87+
- name: "connectedhomeip/chip-build-vscode:0.6.51"
8888
id: Linux
8989
env:
9090
- PW_ENVIRONMENT_ROOT=/pwenv
@@ -144,7 +144,7 @@ steps:
144144
- name: pwenv
145145
path: /pwenv
146146

147-
- name: "connectedhomeip/chip-build-vscode:0.6.48"
147+
- name: "connectedhomeip/chip-build-vscode:0.6.51"
148148
id: Android
149149
env:
150150
- PW_ENVIRONMENT_ROOT=/pwenv

‎src/app/server/java/BUILD.gn

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ android_library("java") {
7070
javac_flags = [ "-Xlint:deprecation" ]
7171

7272
# TODO: add classpath support (we likely need to add something like
73-
# ..../platforms/android-21/android.jar to access BLE items)
73+
# ..../platforms/android-26/android.jar to access BLE items)
7474
}
7575

7676
java_prebuilt("android") {
77-
jar_path = "${android_sdk_root}/platforms/android-21/android.jar"
77+
jar_path = "${android_sdk_root}/platforms/android-26/android.jar"
7878
}

‎src/controller/java/BUILD.gn

+4-4
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ android_library("java") {
286286
]
287287

288288
# TODO: add classpath support (we likely need to add something like
289-
# ..../platforms/android-21/android.jar to access BLE items)
289+
# ..../platforms/android-26/android.jar to access BLE items)
290290
}
291291

292292
if (chip_link_tests) {
@@ -318,7 +318,7 @@ if (chip_link_tests) {
318318
javac_flags = [ "-Xlint:deprecation" ]
319319

320320
# TODO: add classpath support (we likely need to add something like
321-
# ..../platforms/android-21/android.jar to access BLE items)
321+
# ..../platforms/android-26/android.jar to access BLE items)
322322
}
323323

324324
android_library("tests") {
@@ -353,12 +353,12 @@ if (chip_link_tests) {
353353
javac_flags = [ "-Xlint:deprecation" ]
354354

355355
# TODO: add classpath support (we likely need to add something like
356-
# ..../platforms/android-21/android.jar to access BLE items)
356+
# ..../platforms/android-26/android.jar to access BLE items)
357357
}
358358
}
359359

360360
if (!build_java_matter_controller) {
361361
java_prebuilt("android") {
362-
jar_path = "${android_sdk_root}/platforms/android-21/android.jar"
362+
jar_path = "${android_sdk_root}/platforms/android-26/android.jar"
363363
}
364364
}

‎src/inet/InetInterface.cpp

-145
Original file line numberDiff line numberDiff line change
@@ -507,143 +507,6 @@ void CloseIOCTLSocket()
507507
}
508508
}
509509

510-
#if __ANDROID__ && __ANDROID_API__ < 24
511-
512-
static struct if_nameindex * backport_if_nameindex(void);
513-
static void backport_if_freenameindex(struct if_nameindex *);
514-
515-
static void backport_if_freenameindex(struct if_nameindex * inArray)
516-
{
517-
if (inArray == NULL)
518-
{
519-
return;
520-
}
521-
522-
for (size_t i = 0; inArray[i].if_index != 0; i++)
523-
{
524-
if (inArray[i].if_name != NULL)
525-
{
526-
Platform::MemoryFree(inArray[i].if_name);
527-
}
528-
}
529-
530-
Platform::MemoryFree(inArray);
531-
}
532-
533-
static struct if_nameindex * backport_if_nameindex(void)
534-
{
535-
int err;
536-
unsigned index;
537-
size_t intfIter = 0;
538-
size_t maxIntfNum = 0;
539-
size_t numIntf = 0;
540-
size_t numAddrs = 0;
541-
struct if_nameindex * retval = NULL;
542-
struct if_nameindex * tmpval = NULL;
543-
struct ifaddrs * addrList = NULL;
544-
struct ifaddrs * addrIter = NULL;
545-
const char * lastIntfName = "";
546-
547-
err = getifaddrs(&addrList);
548-
VerifyOrExit(err >= 0, );
549-
550-
// coalesce on consecutive interface names
551-
for (addrIter = addrList; addrIter != NULL; addrIter = addrIter->ifa_next)
552-
{
553-
numAddrs++;
554-
if (strcmp(addrIter->ifa_name, lastIntfName) == 0)
555-
{
556-
continue;
557-
}
558-
numIntf++;
559-
lastIntfName = addrIter->ifa_name;
560-
}
561-
562-
tmpval = (struct if_nameindex *) Platform::MemoryAlloc((numIntf + 1) * sizeof(struct if_nameindex));
563-
VerifyOrExit(tmpval != NULL, );
564-
memset(tmpval, 0, (numIntf + 1) * sizeof(struct if_nameindex));
565-
566-
lastIntfName = "";
567-
for (addrIter = addrList; addrIter != NULL; addrIter = addrIter->ifa_next)
568-
{
569-
if (strcmp(addrIter->ifa_name, lastIntfName) == 0)
570-
{
571-
continue;
572-
}
573-
574-
index = if_nametoindex(addrIter->ifa_name);
575-
if (index != 0)
576-
{
577-
tmpval[intfIter].if_index = index;
578-
tmpval[intfIter].if_name = strdup(addrIter->ifa_name);
579-
intfIter++;
580-
}
581-
lastIntfName = addrIter->ifa_name;
582-
}
583-
584-
// coalesce on interface index
585-
maxIntfNum = 0;
586-
for (size_t i = 0; tmpval[i].if_index != 0; i++)
587-
{
588-
if (maxIntfNum < tmpval[i].if_index)
589-
{
590-
maxIntfNum = tmpval[i].if_index;
591-
}
592-
}
593-
594-
retval = (struct if_nameindex *) Platform::MemoryAlloc((maxIntfNum + 1) * sizeof(struct if_nameindex));
595-
VerifyOrExit(retval != NULL, );
596-
memset(retval, 0, (maxIntfNum + 1) * sizeof(struct if_nameindex));
597-
598-
for (size_t i = 0; tmpval[i].if_index != 0; i++)
599-
{
600-
struct if_nameindex * intf = &tmpval[i];
601-
if (retval[intf->if_index - 1].if_index == 0)
602-
{
603-
retval[intf->if_index - 1] = *intf;
604-
}
605-
else
606-
{
607-
free(intf->if_name);
608-
intf->if_index = 0;
609-
intf->if_name = 0;
610-
}
611-
}
612-
613-
intfIter = 0;
614-
615-
// coalesce potential gaps between indeces
616-
for (size_t i = 0; i < maxIntfNum; i++)
617-
{
618-
if (retval[i].if_index != 0)
619-
{
620-
retval[intfIter] = retval[i];
621-
intfIter++;
622-
}
623-
}
624-
625-
for (size_t i = intfIter; i < maxIntfNum; i++)
626-
{
627-
retval[i].if_index = 0;
628-
retval[i].if_name = NULL;
629-
}
630-
631-
exit:
632-
if (tmpval != NULL)
633-
{
634-
Platform::MemoryFree(tmpval);
635-
}
636-
637-
if (addrList != NULL)
638-
{
639-
freeifaddrs(addrList);
640-
}
641-
642-
return retval;
643-
}
644-
645-
#endif // __ANDROID__ && __ANDROID_API__ < 24
646-
647510
InterfaceIterator::InterfaceIterator()
648511
{
649512
mIntfArray = nullptr;
@@ -656,11 +519,7 @@ InterfaceIterator::~InterfaceIterator()
656519
{
657520
if (mIntfArray != nullptr)
658521
{
659-
#if __ANDROID__ && __ANDROID_API__ < 24
660-
backport_if_freenameindex(mIntfArray);
661-
#else
662522
if_freenameindex(mIntfArray);
663-
#endif
664523
mIntfArray = nullptr;
665524
}
666525
}
@@ -674,11 +533,7 @@ bool InterfaceIterator::Next()
674533
{
675534
if (mIntfArray == nullptr)
676535
{
677-
#if __ANDROID__ && __ANDROID_API__ < 24
678-
mIntfArray = backport_if_nameindex();
679-
#else
680536
mIntfArray = if_nameindex();
681-
#endif
682537
}
683538
else if (mIntfArray[mCurIntf].if_index != 0)
684539
{

0 commit comments

Comments
 (0)
Please sign in to comment.