From cb50c0f569fdc4f027632dc074ef44639f2ca138 Mon Sep 17 00:00:00 2001 From: "jose.pereda" Date: Fri, 9 Aug 2024 18:22:09 +0200 Subject: [PATCH] Prevent Util.activity reference from being nullified. --- modules/util/src/main/native/android/dalvik/Util.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/util/src/main/native/android/dalvik/Util.java b/modules/util/src/main/native/android/dalvik/Util.java index 8ad5e783..7da5a03e 100644 --- a/modules/util/src/main/native/android/dalvik/Util.java +++ b/modules/util/src/main/native/android/dalvik/Util.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Gluon + * Copyright (c) 2020, 2024, Gluon * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -47,9 +47,9 @@ public class Util { private static boolean debug = false; public Util(Activity activity) { - Util.activity = activity; Log.v(TAG, "Util "); if (activity != null) { + Util.activity = activity; new Handler(Util.activity.getMainLooper()).postDelayed(new Runnable() { @Override @@ -97,6 +97,9 @@ private static void syncClipboardFromOS() { @Override public void run() { if (Util.activity == null) { + if (debug) { + Log.v(TAG, "Util::syncClipboardFromOS failed, no activity"); + } return; } new Handler(Util.activity.getMainLooper()).postDelayed(new Runnable() { @@ -123,6 +126,9 @@ public void run() { private static void syncClipboardToOS() { if (Util.activity == null) { + if (debug) { + Log.v(TAG, "Util::syncClipboardToOS failed, no activity"); + } return; } final String text = nativeSyncClipboardToOS();