From 80260a7953aab2afd3ab30032b973447c0a5a670 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Pereda?= Date: Sun, 11 Aug 2024 19:05:46 +0200 Subject: [PATCH] Prevent Util.activity reference from being nullified. (#404) --- 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();