From d50e0f5fb9d60992d65a818a8af1cc20e878e312 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Sun, 8 Jul 2018 23:59:25 +0200 Subject: [PATCH] Use instanceOf instead of getClass Signed-off-by: Jason A. Donenfeld --- .../main/java/com/wireguard/android/BootShutdownReceiver.java | 2 +- .../main/java/com/wireguard/android/activity/BaseActivity.java | 2 +- .../java/com/wireguard/android/activity/SettingsActivity.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/wireguard/android/BootShutdownReceiver.java b/app/src/main/java/com/wireguard/android/BootShutdownReceiver.java index 1a8c96a0..3b9f852d 100644 --- a/app/src/main/java/com/wireguard/android/BootShutdownReceiver.java +++ b/app/src/main/java/com/wireguard/android/BootShutdownReceiver.java @@ -21,7 +21,7 @@ public class BootShutdownReceiver extends BroadcastReceiver { @Override public void onReceive(final Context context, final Intent intent) { Application.onHaveBackend(backend -> { - if (backend.getClass() != WgQuickBackend.class) + if (!(backend instanceof WgQuickBackend)) return; final String action = intent.getAction(); if (action == null) diff --git a/app/src/main/java/com/wireguard/android/activity/BaseActivity.java b/app/src/main/java/com/wireguard/android/activity/BaseActivity.java index b7aee1e3..e5aaadf2 100644 --- a/app/src/main/java/com/wireguard/android/activity/BaseActivity.java +++ b/app/src/main/java/com/wireguard/android/activity/BaseActivity.java @@ -54,7 +54,7 @@ public abstract class BaseActivity extends ThemeChangeAwareActivity { super.onCreate(savedInstanceState); Application.onHaveBackend(backend -> { - if (backend.getClass() == GoBackend.class) { + if (backend instanceof GoBackend) { final Intent intent = GoBackend.VpnService.prepare(this); if (intent != null) startActivityForResult(intent, 0); diff --git a/app/src/main/java/com/wireguard/android/activity/SettingsActivity.java b/app/src/main/java/com/wireguard/android/activity/SettingsActivity.java index a8d58e6e..ed2da4dc 100644 --- a/app/src/main/java/com/wireguard/android/activity/SettingsActivity.java +++ b/app/src/main/java/com/wireguard/android/activity/SettingsActivity.java @@ -102,7 +102,7 @@ public class SettingsActivity extends ThemeChangeAwareActivity { final PreferenceScreen screen = getPreferenceScreen(); Application.onHaveBackend(backend -> { for (final Preference pref : wgQuickOnlyPrefs) { - if (backend.getClass() == WgQuickBackend.class) + if (backend instanceof WgQuickBackend) pref.setVisible(true); else screen.removePreference(pref);