Skip to content

Commit 5058a43

Browse files
committed
linters
1 parent b7b7cec commit 5058a43

File tree

8 files changed

+61
-61
lines changed

8 files changed

+61
-61
lines changed

android/daemon/src/main/java/org/mozilla/firefox/vpn/daemon/Log.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55
package org.mozilla.firefox.vpn.daemon
66

77
import android.content.Context
8+
import android.util.Log as nativeLog
89
import java.io.File
910
import java.time.LocalDateTime
10-
import android.util.Log as nativeLog
11-
import org.mozilla.firefox.vpn.daemon.BuildConfig
1211

1312
/*
1413
* Drop in replacement for android.util.Log

android/daemon/src/main/java/org/mozilla/firefox/vpn/daemon/VPNService.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import org.mozilla.firefox.vpn.daemon.GleanMetrics.Session
2828
import org.mozilla.guardian.tunnel.WireGuardGo
2929
import java.io.File
3030
import java.util.*
31-
import org.mozilla.firefox.vpn.daemon.BuildConfig
3231

3332
class VPNService : android.net.VpnService() {
3433
private val tag = "VPNService"

nebula/ui/components/qmldir

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
module components
2-
linktarget componentsplugin
3-
optional plugin qml_components_componentsplugin
4-
classname componentsPlugin
5-
typeinfo components.qmltypes
6-
prefer :/nebula/components/
71
MZAlert 0.0 MZAlert.qml
82
MZAnimatedRings 0.0 MZAnimatedRings.qml
93
MZAvatar 0.0 MZAvatar.qml

src/commands/commandui.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ int CommandUI::run(QStringList& tokens) {
250250
TemporaryDir::cleanupAll();
251251

252252
vpn->setStartMinimized(minimizedOption.m_set ||
253-
(qgetenv("MVPN_MINIMIZED") == "1"));
253+
(qgetenv("MVPN_MINIMIZED") == "1"));
254254

255255
#ifndef Q_OS_WIN
256256
// Signal handling for a proper shutdown.
@@ -322,15 +322,16 @@ int CommandUI::run(QStringList& tokens) {
322322
QObject::connect(vpn->controller(), &Controller::readyToQuit, vpn,
323323
&App::quit, Qt::QueuedConnection);
324324

325-
#ifdef MZ_ANDROID
326-
// On Android we need to make sure when we load a QML application that the context
327-
// is set. Qt ___should___ do this for us, but it seems that in some cases it does not.
328-
// So we chant dark JNI magic to make sure the VPNActivity is set as context provider.
325+
#ifdef MZ_ANDROID
326+
// On Android we need to make sure when we load a QML application that the
327+
// context is set. Qt ___should___ do this for us, but it seems that in some
328+
// cases it does not. So we chant dark JNI magic to make sure the
329+
// VPNActivity is set as context provider.
329330
logger.debug() << "Forcing activity publish";
330331
AndroidCommons::forcePublishActivity();
331332
// In case we have a pending exception, clear it before loading main.qml
332333
AndroidCommons::clearPendingJavaException("before main.qml load");
333-
#endif
334+
#endif
334335
const QUrl url(QStringLiteral("qrc:/qt/qml/Mozilla/VPN/main.qml"));
335336
logger.debug() << "Loading main QML file:" << url.toString();
336337
engine->load(url);
@@ -364,11 +365,12 @@ int CommandUI::run(QStringList& tokens) {
364365
&MacOSMenuBar::controllerStateChanged);
365366

366367
#endif
367-
NotificationHandler* notificationHandler = NotificationHandler::create(qApp);
368-
QObject::connect(vpn->controller(), &Controller::stateChanged,notificationHandler,
368+
NotificationHandler* notificationHandler =
369+
NotificationHandler::create(qApp);
370+
QObject::connect(vpn->controller(), &Controller::stateChanged,
371+
notificationHandler,
369372
&NotificationHandler::showNotification);
370373

371-
372374
QObject::connect(
373375
SettingsHolder::instance(), &SettingsHolder::languageCodeChanged, []() {
374376
logger.debug() << "Retranslating";

src/mozillavpn.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,14 @@
9494

9595
#include <QApplication>
9696
#include <QBuffer>
97-
#include <QQmlContext>
9897
#include <QDir>
9998
#include <QFileInfo>
10099
#include <QGuiApplication>
101100
#include <QIcon>
102101
#include <QJsonDocument>
103102
#include <QLocale>
104103
#include <QQmlApplicationEngine>
104+
#include <QQmlContext>
105105
#include <QScreen>
106106
#include <QTimer>
107107
#include <QUrl>
@@ -307,17 +307,17 @@ void MozillaVPN::initialize() {
307307
#endif
308308

309309
m_private->m_captivePortalDetection.initialize();
310-
logger.debug() << "Captive Portal Detection initialized";
310+
logger.debug() << "Captive Portal Detection initialized";
311311
m_private->m_networkWatcher.initialize();
312-
logger.debug() << "Network Watcher initialized";
312+
logger.debug() << "Network Watcher initialized";
313313

314314
DNSHelper::maybeMigrateDNSProviderFlags();
315-
logger.debug() << "DNS Helper initialized";
315+
logger.debug() << "DNS Helper initialized";
316316

317317
SettingsWatcher::instance();
318-
logger.debug() << "Settings Watcher initialized";
318+
logger.debug() << "Settings Watcher initialized";
319319

320-
logger.debug()<< "Checking token";
320+
logger.debug() << "Checking token";
321321
if (!settingsHolder->hasToken()) {
322322
return;
323323
}
@@ -2311,11 +2311,12 @@ int MozillaVPN::runCommandLineApp(std::function<int()>&& a_callback) {
23112311
}
23122312

23132313
/**
2314-
* This function instantiates a QMLApplication, MozillaVPN singleton and calles
2315-
* the provided callback.
2316-
* On Android, the callback is called when the Context is available, the Qt Eventloop is running in this case.
2317-
* On other platforms, the callback is called before starting the Qt Eventloop.
2318-
*/
2314+
* This function instantiates a QMLApplication, MozillaVPN singleton and calles
2315+
* the provided callback.
2316+
* On Android, the callback is called when the Context is available, the Qt
2317+
* Eventloop is running in this case. On other platforms, the callback is called
2318+
* before starting the Qt Eventloop.
2319+
*/
23192320
int MozillaVPN::runGuiApp(std::function<int()>&& a_callback) {
23202321
std::function<int()> callback = std::move(a_callback);
23212322

@@ -2333,7 +2334,6 @@ int MozillaVPN::runGuiApp(std::function<int()>&& a_callback) {
23332334
QQmlContext* ctx = engine->rootContext();
23342335
ctx->setContextProperty("QT_QUICK_BACKEND", qgetenv("QT_QUICK_BACKEND"));
23352336

2336-
23372337
if (SettingsHolder::instance()->stagingServer()) {
23382338
Constants::setStaging();
23392339
LogHandler::instance()->setStderr(true);
@@ -2352,11 +2352,11 @@ int MozillaVPN::runGuiApp(std::function<int()>&& a_callback) {
23522352
QIcon icon(Constants::LOGO_URL);
23532353
app.setWindowIcon(icon);
23542354

2355-
#ifdef MZ_ANDROID
2356-
AndroidCommons::runWhenUiViewConstructible(callback);
2357-
#else
2358-
callback();
2359-
#endif
2355+
#ifdef MZ_ANDROID
2356+
AndroidCommons::runWhenUiViewConstructible(callback);
2357+
#else
2358+
callback();
2359+
#endif
23602360

23612361
return app.exec();
23622362
}

src/platforms/android/androidcommons.cpp

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,9 @@ void AndroidCommons::forcePublishActivity() {
5656
// 2) Re-publish to Qt (if available in your Qt build)
5757
// Safe no-op if it's already the same:
5858
QJniObject::callStaticMethod<void>(
59-
"org/qtproject/qt/android/QtNative",
60-
"setActivity",
61-
"(Landroid/app/Activity;)V",
62-
activity.object<jobject>());
63-
return true;
59+
"org/qtproject/qt/android/QtNative", "setActivity",
60+
"(Landroid/app/Activity;)V", activity.object<jobject>());
61+
return true;
6462
});
6563
fut.waitForFinished();
6664
}
@@ -151,11 +149,9 @@ void AndroidCommons::launchPlayStore() {
151149
appActivity.object());
152150
}
153151

154-
155-
156152
bool AndroidCommons::clearPendingJavaException(const char* where) {
157153
QJniEnvironment env;
158-
if (!env->ExceptionCheck()){
154+
if (!env->ExceptionCheck()) {
159155
logger.info() << "No pending exception at" << where;
160156
return false;
161157
}
@@ -165,9 +161,9 @@ bool AndroidCommons::clearPendingJavaException(const char* where) {
165161
return true;
166162
};
167163

168-
169164
// static
170-
void AndroidCommons::runWhenUiViewConstructible(std::function<void()> fn, int retryMs) {
165+
void AndroidCommons::runWhenUiViewConstructible(std::function<void()> fn,
166+
int retryMs) {
171167
using QAA = QNativeInterface::QAndroidApplication;
172168
auto attempt = [fn = std::move(fn), retryMs]() mutable {
173169
// Do the probe on the Android UI thread
@@ -180,20 +176,30 @@ void AndroidCommons::runWhenUiViewConstructible(std::function<void()> fn, int re
180176

181177
// 2) Actually try to construct a View with that Context
182178
QJniEnvironment env;
183-
QJniObject dummyView("android/view/View", "(Landroid/content/Context;)V", ctx.object());
184-
if (env->ExceptionCheck()) { env->ExceptionDescribe(); env->ExceptionClear(); return false; }
179+
QJniObject dummyView("android/view/View", "(Landroid/content/Context;)V",
180+
ctx.object());
181+
if (env->ExceptionCheck()) {
182+
env->ExceptionDescribe();
183+
env->ExceptionClear();
184+
return false;
185+
}
185186

186187
if (clearPendingJavaException("gate-exit(UI)")) return false;
187188

188189
// Success — run the work on the Qt thread
189-
QMetaObject::invokeMethod(qApp, [fn = std::move(fn)]() mutable { fn(); }, Qt::QueuedConnection);
190+
QMetaObject::invokeMethod(
191+
qApp, [fn = std::move(fn)]() mutable { fn(); }, Qt::QueuedConnection);
190192
return true;
191193
}).then([retryMs, fn = std::move(fn)](QFuture<QVariant> f) mutable {
192-
const bool ok = f.isValid() && f.result().isValid() && f.result().toBool();
193-
if (!ok) QTimer::singleShot(retryMs, qApp, [fn = std::move(fn), retryMs]() mutable {
194-
AndroidCommons::runWhenUiViewConstructible(std::move(fn), retryMs);
195-
});
194+
const bool ok =
195+
f.isValid() && f.result().isValid() && f.result().toBool();
196+
if (!ok)
197+
QTimer::singleShot(retryMs, qApp,
198+
[fn = std::move(fn), retryMs]() mutable {
199+
AndroidCommons::runWhenUiViewConstructible(
200+
std::move(fn), retryMs);
201+
});
196202
});
197203
};
198204
QTimer::singleShot(0, qApp, attempt);
199-
}
205+
}

src/platforms/android/androidcommons.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ class AndroidCommons final : public QObject {
1212
Q_OBJECT
1313
Q_DISABLE_COPY_MOVE(AndroidCommons)
1414

15-
public:
16-
static bool clearPendingJavaException(const char* where);
17-
static void runWhenUiViewConstructible(std::function<void()> fn, int retryMs = 50);
15+
public:
16+
static bool clearPendingJavaException(const char* where);
17+
static void runWhenUiViewConstructible(std::function<void()> fn,
18+
int retryMs = 50);
1819

1920
static void forcePublishActivity();
2021
static QJniObject getActivity();

src/platforms/android/androidvpnactivity.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,9 @@ void AndroidVPNActivity::onIntentInternal(JNIEnv* env, jobject thiz) {
223223
emit s_instance->onOpenedWithUrl(url);
224224
}
225225

226-
227-
bool AndroidVPNActivity::isReady(){
226+
bool AndroidVPNActivity::isReady() {
228227
QJniEnvironment env;
229-
const bool res = QJniObject::callStaticMethod<bool>(
230-
CLASSNAME, "isReady", "()Z");
228+
const bool res =
229+
QJniObject::callStaticMethod<bool>(CLASSNAME, "isReady", "()Z");
231230
return res;
232-
};
231+
};

0 commit comments

Comments
 (0)