Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ android {
// Instead of failing the build due to missing translations, just inform us to avoid
// mistakes during manual import
informational 'MissingTranslation'
disable 'GradlePluginVersion'
}

dependenciesInfo {
Expand Down Expand Up @@ -267,6 +268,7 @@ dependencies {
exclude group: 'org.hamcrest', module: 'hamcrest-core'
}

implementation libs.errorprone.annotations
errorprone libs.errorprone
annotationProcessor libs.errorprone
testAnnotationProcessor libs.errorprone
Expand Down
19 changes: 10 additions & 9 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ room = "2.8.0-alpha01"
# https://android.googlesource.com/platform/external/dagger2
hilt = "2.55"
# https://mvnrepository.com/artifact/io.github.takahirom.roborazzi/roborazzi
roborazzi = "1.50.0"
roborazzi = "1.54.0"
# https://mvnrepository.com/artifact/androidx.test.espresso/espresso-core
# https://mvnrepository.com/artifact/androidx.test.espresso/espresso-contrib
espresso = "3.7.0"
Expand All @@ -22,13 +22,13 @@ espresso = "3.7.0"
# ========================================
# https://mvnrepository.com/artifact/com.android.application/com.android.application.gradle.plugin
# https://mvnrepository.com/artifact/com.android.library/com.android.library.gradle.plugin
agp = "8.10.1"
agp = "8.11.2"
# https://plugins.gradle.org/plugin/org.jetbrains.kotlin.android
kotlin = "2.1.10"
# https://mvnrepository.com/artifact/net.ltgt.errorprone/net.ltgt.errorprone.gradle.plugin
errorprone = "4.2.0"
# https://mvnrepository.com/artifact/com.google.errorprone/error_prone_core
errorprone = "2.45.0"
# https://mvnrepository.com/artifact/org.jetbrains.kotlinx/kover-gradle-plugin
kover = "0.9.1"
kover = "0.9.4"

[libraries]
# https://mvnrepository.com/artifact/androidx.activity/activity
Expand Down Expand Up @@ -56,8 +56,8 @@ coordinatorlayout = { module = "androidx.coordinatorlayout:coordinatorlayout", v
# https://mvnrepository.com/artifact/androidx.core/core
# https://android.googlesource.com/platform/prebuilts/sdk/+/refs/heads/main/current/androidx/m2repository/androidx/core/core/
core = { module = "androidx.core:core", version = "1.17.0" } # TODO: AOSP sources use 1.19.0-alpha01; upgrade when available in Maven Central }
# https://mvnrepository.com/artifact/com.google.errorprone/error_prone_core
errorprone = { module = "com.google.errorprone:error_prone_core", version = "2.42.0" }
errorprone = { module = "com.google.errorprone:error_prone_core", version.ref = "errorprone" }
errorprone-annotations = { module = "com.google.errorprone:error_prone_annotations", version.ref = "errorprone" }
# https://mvnrepository.com/artifact/androidx.test.espresso/espresso-core
espresso = { module = "androidx.test.espresso:espresso-core", version.ref = "espresso" }
espresso-contrib = { module = "androidx.test.espresso:espresso-contrib", version.ref = "espresso" }
Expand All @@ -75,7 +75,7 @@ livedata = { module = "androidx.lifecycle:lifecycle-livedata", version = "2.10.0
# https://android.googlesource.com/platform/prebuilts/sdk/+/refs/heads/main/current/extras/material-design-x/com/google/android/material/material/
material = { module = "com.google.android.material:material", version = "1.14.0-alpha02" }
# https://mvnrepository.com/artifact/org.mockito/mockito-core
mockito = { module = "org.mockito:mockito-core", version = "5.20.0" }
mockito = { module = "org.mockito:mockito-core", version = "5.21.0" }
# https://mvnrepository.com/artifact/androidx.preference/preference
# https://android.googlesource.com/platform/prebuilts/sdk/+/refs/heads/main/current/androidx/m2repository/androidx/preference/preference/
preference = { module = "androidx.preference:preference", version = "1.2.1" } # TODO AOSP sources use 1.3.0-alpha01; upgrade when available in Maven Central }
Expand Down Expand Up @@ -107,6 +107,7 @@ viewmodel = { module = "androidx.lifecycle:lifecycle-viewmodel", version = "2.10
android-application = { id = "com.android.application", version.ref = "agp" }
android-library = { id = "com.android.library", version.ref = "agp" }
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
errorprone = { id = "net.ltgt.errorprone", version.ref = "errorprone" }
# https://mvnrepository.com/artifact/net.ltgt.errorprone/net.ltgt.errorprone.gradle.plugin
errorprone = { id = "net.ltgt.errorprone", version = "4.2.0" }
kover = { id = "org.jetbrains.kotlinx.kover", version.ref = "kover" }
roborazzi = { id = "io.github.takahirom.roborazzi", version.ref = "roborazzi" }
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
14 changes: 13 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,20 @@ pluginManagement {
}
}

buildscript {
ext {
agpVersion = new File(rootProject.projectDir.absoluteFile, "gradle/libs.versions.toml")
.readLines()
.stream()
.filter((line) -> line.startsWith("agp ="))
.map((line) -> line.split('"')[1])
.findFirst()
.get()
}
}

plugins {
id 'com.android.settings' version '8.10.1'
id 'com.android.settings' version "${agpVersion}"
}

dependencyResolutionManagement {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void onReceive(final Context context, final Intent intent) {

mLogger = mLoggerFactory.create(getClass().getSimpleName());

mLogger.d("onReceive() : intent=" + intent);
mLogger.d("onReceive() : intent=%s", intent);

final LocalDateTime now = LocalDateTime.now(ZoneId.systemDefault());
final String action = intent.getAction() != null ? intent.getAction() : "";
Expand Down
24 changes: 17 additions & 7 deletions src/com/github/iusmac/sevensim/Logger.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

import androidx.annotation.VisibleForTesting;

import com.google.errorprone.annotations.FormatMethod;
import com.google.errorprone.annotations.FormatString;

import dagger.assisted.Assisted;
import dagger.assisted.AssistedFactory;
import dagger.assisted.AssistedInject;
Expand Down Expand Up @@ -51,31 +54,36 @@ public Logger(final Runtime javaRuntime, final @Named("Debug") boolean debug,
public boolean isErrorLoggable() { return Log.isLoggable(mTag, Log.ERROR); }
public boolean isWtfLoggable() { return Log.isLoggable(mTag, Log.ASSERT); }

public void v(String message, Object... args) {
@FormatMethod
public void v(@FormatString String message, Object... args) {
if (mIsDebuggable || isVerboseLoggable()) {
Log.v(mTag, format(message, args));
}
}

public void d(String message, Object... args) {
@FormatMethod
public void d(@FormatString String message, Object... args) {
if (mIsDebuggable || isDebugLoggable()) {
Log.d(mTag, format(message, args));
}
}

public void i(String message, Object... args) {
@FormatMethod
public void i(@FormatString String message, Object... args) {
if (mIsDebuggable || isInfoLoggable()) {
Log.i(mTag, format(message, args));
}
}

public void w(String message, Object... args) {
@FormatMethod
public void w(@FormatString String message, Object... args) {
if (mIsDebuggable || isWarnLoggable()) {
Log.w(mTag, format(message, args));
}
}

public void e(String message, Object... args) {
@FormatMethod
public void e(@FormatString String message, Object... args) {
if (mIsDebuggable || isErrorLoggable()) {
Log.e(mTag, format(message, args));
}
Expand All @@ -87,7 +95,8 @@ public void e(String message, Throwable e) {
}
}

public void wtf(String message, Object... args) {
@FormatMethod
public void wtf(@FormatString String message, Object... args) {
if (mIsDebuggable || isWtfLoggable()) {
Log.wtf(mTag, format(message, args));
}
Expand All @@ -108,7 +117,8 @@ public interface Factory {
Logger create(String tag);
}

private static String format(String message, Object... args) {
@FormatMethod
private static String format(@FormatString String message, Object... args) {
return args == null || args.length == 0 ? message : String.format(Locale.US, message, args);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void onReceive(final Context context, final Intent intent) {

mLogger = mLoggerFactory.create(getClass().getSimpleName());

mLogger.d("onReceive() : intent=" + intent);
mLogger.d("onReceive() : intent=%s", intent);

final LocalDateTime now = LocalDateTime.now(ZoneId.systemDefault());
final String action = intent.getAction() != null ? intent.getAction() : "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ public void setUiccApplicationsEnabled(final int subId, final boolean enabled) {
final String logPrefix = String.format(Locale.getDefault(), "setUiccApplicationsEnabled(" +
"subId=%d,enabled=%s)", subId, enabled);

mLogger.d(logPrefix);
mLogger.d("%s", logPrefix);

final Subscription sub = mSubscriptions.getSubscriptionForSubId(subId).orElse(null);

if (sub == null) {
mLogger.e(logPrefix + " Aborting due to missing subscription.");
mLogger.e("%s Aborting due to missing subscription.", logPrefix);
mSubscriptions.notifyAllListeners();
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public abstract class Subscriptions implements Iterable<Subscription> {
private final BroadcastReceiver mCarrierConfigChangedReceiver = new BroadcastReceiver() {
@Override
public void onReceive(final Context context, final Intent intent) {
mLogger.v("onReceive() : intent=" + intent);
mLogger.v("onReceive() : intent=%s", intent);

switch (Objects.toString(intent.getAction(), "")) {
case TelephonyManager.ACTION_SIM_CARD_STATE_CHANGED,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public void setSimState(final int slotIndex, final boolean enabled,
// From testing, it turned out that SIM power state change request ignores Airplane mode,
// so we can allow disabling but not enabling request
if (enabled && TelephonyUtils.isAirplaneModeOn(mContext)) {
mLogger.w(logPrefix + "Aborting due to Airplane mode.");
mLogger.w("%sAborting due to Airplane mode.", logPrefix);

Utils.makeToast(mContext, mContext.getString(R.string.airplane_mode_enabled));

Expand All @@ -122,19 +122,19 @@ public void setSimState(final int slotIndex, final boolean enabled,
}

synchronized (this) {
mLogger.d(logPrefix + "In sync block.");
mLogger.d("%sIn sync block.", logPrefix);

final Subscription sub =
mSubscriptions.getSubscriptionForSimSlotIndex(slotIndex).orElse(null);

if (sub == null) {
mLogger.e(logPrefix + "Aborting due to missing subscription.");
mLogger.e("%sAborting due to missing subscription.", logPrefix);
mSubscriptions.notifyAllListeners();
return;
}

if (enabled == sub.isSimEnabled()) {
mLogger.w(logPrefix + "Already in state.");
mLogger.w("%sAlready in state.", logPrefix);
mSubscriptions.notifyAllListeners();
return;
}
Expand Down Expand Up @@ -199,7 +199,7 @@ public void setSimState(final int slotIndex, final boolean enabled,
try {
mRequestMetadata.wait(deadlineMillis - nowMillis);
} catch (InterruptedException e) {
mLogger.w(logPrefix + "Acquire wait interrupted.");
mLogger.w("%sAcquire wait interrupted.", logPrefix);
// At this point we'll just propagate a custom internal "interrupted
// abruptly" code that will assume the request succeeded
mRequestMetadata.putInt(KEY_REQUEST_RESPONSE_CODE,
Expand Down Expand Up @@ -294,7 +294,7 @@ private void handleOnSetSimPowerStateForSlotFinished(final int resCode) {
TelephonyManager.SET_SIM_POWER_STATE_NOT_SUPPORTED -> // 4
requestFailed = true;

default -> mLogger.e(logPrefix + ". Unexpected resCode.");
default -> mLogger.e("%s. Unexpected resCode.", logPrefix);
}
} else {
switch (resCode) {
Expand Down Expand Up @@ -356,7 +356,7 @@ private void handleOnSetSimPowerStateForSlotFinished(final int resCode) {
// to explicitly notify listeners, so they can stay tuned to actual state
shouldNotifyAllListeners |= requestFailed;

mLogger.d(logPrefix + ", requestFailed=%s,shouldNotifyAllListeners=%s", requestFailed,
mLogger.d("%s,requestFailed=%s,shouldNotifyAllListeners=%s", logPrefix, requestFailed,
shouldNotifyAllListeners);

if (shouldNotifyAllListeners) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ final class IntentReceiver extends BroadcastReceiver {
public void onReceive(final Context context, final Intent intent) {
final String action = intent.getAction();

mLogger.d("onReceive() : intent=" + intent);
mLogger.d("onReceive() : intent=%s", intent);

switch (action) {
case Intent.ACTION_LOCALE_CHANGED -> {
Expand Down
2 changes: 1 addition & 1 deletion src/com/github/iusmac/sevensim/ui/sim/SimListActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ final class IntentReceiver extends BroadcastReceiver {
public void onReceive(final Context context, final Intent intent) {
final String action = intent.getAction();

mLogger.d("onReceive() : intent=" + intent);
mLogger.d("onReceive() : intent=%s", intent);

switch (action) {
case Intent.ACTION_TIMEZONE_CHANGED, Intent.ACTION_TIME_CHANGED -> {
Expand Down