Fix executable choosing for my phone, and fix broadcasting to each interface.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4232 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
Cory McWilliams 2023-03-18 01:26:34 +00:00
parent fbb657a85c
commit 63615747a7
3 changed files with 10 additions and 6 deletions

View File

@ -441,11 +441,11 @@ out/TildeFriends-debug.unsigned.apk: BUILD_TYPE := debug
out/TildeFriends-release.unsigned.apk: BUILD_TYPE := release
out/%.unsigned.apk:
@mkdir -p $(dir $@) out/apk$(BUILD_TYPE)/lib/arm64-v8a/ out/apk$(BUILD_TYPE)/lib/x86_64/
@mkdir -p $(dir $@) out/apk$(BUILD_TYPE)/lib/aarch64/ out/apk$(BUILD_TYPE)/lib/x86_64/
@echo [aapt] $@
@cp out/android$(BUILD_TYPE)/tildefriends out/apk$(BUILD_TYPE)/lib/arm64-v8a/
@cp out/android$(BUILD_TYPE)/tildefriends out/apk$(BUILD_TYPE)/lib/aarch64/
@cp out/android$(BUILD_TYPE)-x86_64/tildefriends out/apk$(BUILD_TYPE)/lib/x86_64/
@/usr/lib/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip out/apk$(BUILD_TYPE)/lib/arm64-v8a/tildefriends
@/usr/lib/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip out/apk$(BUILD_TYPE)/lib/aarch64/tildefriends
@/usr/lib/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip out/apk$(BUILD_TYPE)/lib/x86_64/tildefriends
@cp out/res.apk $@
@cp out/apk/classes.dex out/apk$(BUILD_TYPE)/

View File

@ -47,8 +47,10 @@ public class MainActivity extends Activity {
ZipInputStream zip = new ZipInputStream(new BufferedInputStream(new FileInputStream(getPackageResourcePath().toString())));
ZipEntry entry = null;
String lookup = String.format("lib/%s/tildefriends", arch);
Log.w("tildefriends", "Looking for " + lookup);
while ((entry = zip.getNextEntry()) != null) {
if (entry.getName().equals(lookup)) {
Log.w("tildefriends", "Extracting " + entry.getName());
FileOutputStream out = new FileOutputStream(getFilesDir().toString().concat("/tildefriends"));
byte[] buffer = new byte[32768];
int count;

View File

@ -2554,7 +2554,7 @@ static void _tf_ssb_on_connection(uv_stream_t* stream, int status)
uv_read_start((uv_stream_t*)&connection->tcp, _tf_ssb_connection_on_tcp_alloc, _tf_ssb_connection_on_tcp_recv);
}
static void _tf_ssb_send_broadcast(tf_ssb_t* ssb, struct sockaddr_in* address)
static void _tf_ssb_send_broadcast(tf_ssb_t* ssb, struct sockaddr_in* address, struct sockaddr_in* netmask)
{
struct sockaddr server_addr;
int len = (int)sizeof(server_addr);
@ -2581,7 +2581,9 @@ static void _tf_ssb_send_broadcast(tf_ssb_t* ssb, struct sockaddr_in* address)
struct sockaddr_in broadcast_addr = { 0 };
broadcast_addr.sin_family = AF_INET;
broadcast_addr.sin_port = htons(8008);
broadcast_addr.sin_addr.s_addr = INADDR_BROADCAST;
broadcast_addr.sin_addr.s_addr =
(address->sin_addr.s_addr & netmask->sin_addr.s_addr) |
(INADDR_BROADCAST & ~netmask->sin_addr.s_addr);
int r = uv_udp_try_send(&ssb->broadcast_sender, &buf, 1, (struct sockaddr*)&broadcast_addr);
if (r < 0)
{
@ -2601,7 +2603,7 @@ static void _tf_ssb_broadcast_timer(uv_timer_t* timer)
if (!info[i].is_internal &&
info[i].address.address4.sin_family == AF_INET)
{
_tf_ssb_send_broadcast(ssb, &info[i].address.address4);
_tf_ssb_send_broadcast(ssb, &info[i].address.address4, &info[i].netmask.netmask4);
}
}
uv_free_interface_addresses(info, count);