Skip to content

Commit 93d5fff

Browse files
authored
Add vendor support to Android blueprints (#7614)
1 parent 4b38b44 commit 93d5fff

File tree

4 files changed

+33
-15
lines changed

4 files changed

+33
-15
lines changed

Android.bp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ cc_object {
8383
"src/external/IntelRDFPMathLib20U2/LIBRARY/src/bid_from_int.c",
8484
"src/external/IntelRDFPMathLib20U2/LIBRARY/src/bid_round.c",
8585
],
86+
vendor: true
8687
}
8788

8889
cc_object {
@@ -110,6 +111,7 @@ cc_object {
110111
"-Wno-unused-local-typedefs",
111112
"-Wno-unused-parameter",
112113
],
114+
vendor: true
113115
}
114116

115117
genrule {
@@ -135,11 +137,11 @@ cc_defaults {
135137
},
136138
shared_libs: [
137139
"liblog",
138-
"libandroid",
139140
"libz",
140141
"libcrypto",
141142
"libssl",
142143
],
144+
vendor: true
143145
}
144146

145147
cc_defaults {
@@ -154,6 +156,7 @@ cc_defaults {
154156
"-DREALM_ENABLE_SYNC=1",
155157
"-DREALM_ENABLE_GEOSPATIAL=1",
156158
"-DREALM_HAVE_EPOLL=1",
159+
"-DREALM_AOSP_VENDOR=1",
157160
"-Wno-non-virtual-dtor",
158161
"-Wno-missing-field-initializers",
159162
],
@@ -193,4 +196,5 @@ cc_library_static {
193196
"src/realm/object-store/sync/impl/emscripten/**/*",
194197
],
195198
export_shared_lib_headers: ["libcrypto"],
199+
vendor: true
196200
}

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
### Enhancements
44
* <New feature description> (PR [#????](https://github.com/realm/realm-core/pull/????))
5-
* None.
5+
* Add vendor support to the Android Blueprint (PR [#7614](https://github.com/realm/realm-core/pull/7614)).
66

77
### Fixed
88
* A non-streaming progress notifier would not immediately call its callback after registration. Instead you would have to wait for a download message to be received to get your first update - if you were already caught up when you registered the notifier you could end up waiting a long time for the server to deliver a download that would call/expire your notifier ([#7627](https://github.com/realm/realm-core/issues/7627), since v14.6.0).

src/realm/object-store/util/scheduler.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,16 @@
2828
#include <realm/object-store/util/apple/scheduler.hpp>
2929
#endif
3030

31-
#if REALM_ANDROID
31+
// When building Realm within the VNDK in AOSP, __ANDROID__ is defined.
32+
// However, access to libandroid is restricted by VNDK policies.
33+
// As a result, we cannot utilize the built-in ALooper functionality.
34+
// Instead, we require users to provide their own scheduler implementation.
35+
36+
#if REALM_ANDROID && !defined(REALM_AOSP_VENDOR)
37+
#define HAS_ANDROID_ALOOPER
38+
#endif
39+
40+
#if HAS_ANDROID_ALOOPER
3241
#include <realm/object-store/util/android/scheduler.hpp>
3342
#endif
3443

@@ -125,7 +134,7 @@ std::shared_ptr<Scheduler> Scheduler::make_platform_default()
125134
#else
126135
#if REALM_PLATFORM_APPLE
127136
return make_runloop(nullptr);
128-
#elif REALM_ANDROID
137+
#elif HAS_ANDROID_ALOOPER
129138
return make_alooper();
130139
#elif defined(__EMSCRIPTEN__)
131140
return std::make_shared<EmscriptenScheduler>();
@@ -167,12 +176,12 @@ std::shared_ptr<Scheduler> Scheduler::make_dispatch(void* queue)
167176
}
168177
#endif // REALM_PLATFORM_APPLE
169178

170-
#if REALM_ANDROID
179+
#if HAS_ANDROID_ALOOPER
171180
std::shared_ptr<Scheduler> Scheduler::make_alooper()
172181
{
173182
return std::make_shared<ALooperScheduler>();
174183
}
175-
#endif // REALM_ANDROID
184+
#endif // HAS_ANDROID_ALOOPER
176185

177186
#if REALM_HAVE_UV
178187
std::shared_ptr<Scheduler> Scheduler::make_uv()
Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
#!/bin/bash
22

3-
realm_version=$(sed -rn 's/^VERSION: (.*)/\1/p' < "$1")
4-
version_and_extra=( ${$realm_version//-/ } )
5-
version_only=${version_and_extra[0]}
6-
extra=${version_and_extra[1]}
3+
version=$(awk '/^VERSION:[[:space:]]*/ {print $2}' $1)
74

8-
semver=( ${version_only//./ } )
9-
major=${semver[0]}
10-
minor=${semver[1]}
11-
patch=${semver[2]}
5+
major=$(echo $version | cut -d '.' -f 1)
6+
minor=$(echo $version | cut -d '.' -f 2)
7+
patch=$(echo $version | cut -d '.' -f 3)
128

13-
sed "s/@CONFIG_VERSION_MAJOR@/$major/g; s/@CONFIG_VERSION_MINOR@/$minor/g; s/@CONFIG_VERSION_PATCH@/$patch/g; s/@CONFIG_VERSION_TWEAK@/$extra/g; s/@CONFIG_VERSION@/$VERSION/g" $2
9+
patch_and_suffix=$(echo $version | cut -d '.' -f 3)
10+
11+
patch=${patch_and_suffix%%-*}
12+
extra=${patch_and_suffix#*-}
13+
14+
if [[ "$extra" == "$patch_and_suffix" ]]; then
15+
extra=""
16+
fi
17+
18+
sed "s/@CONFIG_VERSION_MAJOR@/$major/g; s/@CONFIG_VERSION_MINOR@/$minor/g; s/@CONFIG_VERSION_PATCH@/$patch/g; s/@CONFIG_VERSION_TWEAK@/$extra/g; s/@CONFIG_VERSION@/$version/g" $2

0 commit comments

Comments
 (0)