[GH] Remove the use of String.format(...) from WorkManager.
* Reduces CPU usage & avoids ICU.
Test: Unit tests pass.
This is an imported pull request from https://github.com/androidx/androidx/pull/253.
Resolves #253
Github-Pr-Head-Sha: 32456d9ad0bb4c282eed47652563e1ef3ccd6e51
GitOrigin-RevId: 3b98db8876f98f78c2cc0b3b65d28c53e2c1fd0e
Change-Id: Ia69995ea202ec9e78cad315b3522af6b8cbe1be4
diff --git a/work/integration-tests/testapp/src/main/java/androidx/work/integration/testapp/RetryActivity.java b/work/integration-tests/testapp/src/main/java/androidx/work/integration/testapp/RetryActivity.java
index bff7669..8e9b849 100644
--- a/work/integration-tests/testapp/src/main/java/androidx/work/integration/testapp/RetryActivity.java
+++ b/work/integration-tests/testapp/src/main/java/androidx/work/integration/testapp/RetryActivity.java
@@ -128,22 +128,19 @@
double errorRate = getInputData().getDouble(ERROR_RATE, 0.5);
try {
- Log.i(TAG,
- String.format("[%s] %s started (run attempt = %d)",
- name,
- getId(),
- getRunAttemptCount()));
+ Log.i(TAG, "[" + name + "] " + getId() +
+ " started (run attempt = " + getRunAttemptCount() + ")");
for (int i = 0; i < timeTaken; i++) {
Thread.sleep(1000L);
- Log.v(TAG, String.format("[%s] %s completed stage = %d", name, getId(), i));
+ Log.v(TAG, "[" + name + "] " + getId() + " completed stage = " + i);
}
if (Math.random() < errorRate) {
throw new RuntimeException("random failure");
}
- Log.i(TAG, String.format("[%s] %s successful", name, getId()));
+ Log.i(TAG, "[" + name + "] " + getId() + " successful");
return Result.success();
} catch (Exception e) {
- Log.e(TAG, String.format("[%s] %s failed: %s", name, getId(), e.getMessage()));
+ Log.e(TAG, "[" + name + "] " + getId() + " failed: " + e.getMessage());
return Result.retry();
}
}
diff --git a/work/integration-tests/testapp/src/main/java/androidx/work/integration/testapp/RetryWorker.java b/work/integration-tests/testapp/src/main/java/androidx/work/integration/testapp/RetryWorker.java
index 3cf48e4..c9be7b4 100644
--- a/work/integration-tests/testapp/src/main/java/androidx/work/integration/testapp/RetryWorker.java
+++ b/work/integration-tests/testapp/src/main/java/androidx/work/integration/testapp/RetryWorker.java
@@ -54,7 +54,7 @@
@NonNull
@Override
public Result doWork() {
- Log.e(TAG, String.format("Requesting retry (%s)", getRunAttemptCount()));
+ Log.e(TAG, "Requesting retry (" + getRunAttemptCount() + ")");
return Result.retry();
}
}
diff --git a/work/integration-tests/testapp/src/main/java/androidx/work/integration/testapp/ToastWorker.java b/work/integration-tests/testapp/src/main/java/androidx/work/integration/testapp/ToastWorker.java
index bf2d789..fb02bd2 100644
--- a/work/integration-tests/testapp/src/main/java/androidx/work/integration/testapp/ToastWorker.java
+++ b/work/integration-tests/testapp/src/main/java/androidx/work/integration/testapp/ToastWorker.java
@@ -59,7 +59,7 @@
message = "completed!";
}
final Date now = new Date(System.currentTimeMillis());
- Log.i(TAG, String.format("Run time [%s]: %s", message, now));
+ Log.i(TAG, "Run time [" + message + "]: " + now);
final String displayMessage = message;
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
diff --git a/work/work-gcm/src/main/java/androidx/work/impl/background/gcm/GcmScheduler.java b/work/work-gcm/src/main/java/androidx/work/impl/background/gcm/GcmScheduler.java
index 9031b57..9f29c18 100644
--- a/work/work-gcm/src/main/java/androidx/work/impl/background/gcm/GcmScheduler.java
+++ b/work/work-gcm/src/main/java/androidx/work/impl/background/gcm/GcmScheduler.java
@@ -54,14 +54,14 @@
public void schedule(@NonNull WorkSpec... workSpecs) {
for (WorkSpec workSpec : workSpecs) {
Task task = mTaskConverter.convert(workSpec);
- Logger.get().debug(TAG, String.format("Scheduling %s with %s", workSpec, task));
+ Logger.get().debug(TAG, "Scheduling " + workSpec + "with " + task);
mNetworkManager.schedule(task);
}
}
@Override
public void cancel(@NonNull String workSpecId) {
- Logger.get().debug(TAG, String.format("Cancelling %s", workSpecId));
+ Logger.get().debug(TAG, "Cancelling " + workSpecId);
mNetworkManager.cancelTask(workSpecId, WorkManagerGcmService.class);
}
diff --git a/work/work-gcm/src/main/java/androidx/work/impl/background/gcm/WorkManagerGcmDispatcher.java b/work/work-gcm/src/main/java/androidx/work/impl/background/gcm/WorkManagerGcmDispatcher.java
index f759de4..6f30c6a 100644
--- a/work/work-gcm/src/main/java/androidx/work/impl/background/gcm/WorkManagerGcmDispatcher.java
+++ b/work/work-gcm/src/main/java/androidx/work/impl/background/gcm/WorkManagerGcmDispatcher.java
@@ -89,7 +89,7 @@
// per tag, which in our case is a workSpecId. Therefore its safe to block here with
// a latch because there is 1 thread per workSpecId.
- Logger.get().debug(TAG, String.format("Handling task %s", taskParams));
+ Logger.get().debug(TAG, "Handling task " + taskParams);
String workSpecId = taskParams.getTag();
if (workSpecId == null || workSpecId.isEmpty()) {
@@ -103,7 +103,7 @@
new WorkSpecTimeLimitExceededListener(mWorkManagerImpl);
Processor processor = mWorkManagerImpl.getProcessor();
processor.addExecutionListener(listener);
- String wakeLockTag = String.format("WorkGcm-onRunTask (%s)", workSpecId);
+ String wakeLockTag = "WorkGcm-onRunTask (" + workSpecId + ")";
PowerManager.WakeLock wakeLock = WakeLocks.newWakeLock(mContext, wakeLockTag);
mWorkManagerImpl.startWork(workSpecId);
mWorkTimer.startTimer(workSpecId, AWAIT_TIME_IN_MILLISECONDS, timeLimitExceededListener);
@@ -112,7 +112,7 @@
wakeLock.acquire();
listener.getLatch().await(AWAIT_TIME_IN_MINUTES, TimeUnit.MINUTES);
} catch (InterruptedException exception) {
- Logger.get().debug(TAG, String.format("Rescheduling WorkSpec %s", workSpecId));
+ Logger.get().debug(TAG, "Rescheduling WorkSpec" + workSpecId);
return reschedule(workSpecId);
} finally {
processor.removeExecutionListener(listener);
@@ -121,7 +121,7 @@
}
if (listener.needsReschedule()) {
- Logger.get().debug(TAG, String.format("Rescheduling WorkSpec %s", workSpecId));
+ Logger.get().debug(TAG, "Rescheduling WorkSpec" + workSpecId);
return reschedule(workSpecId);
}
@@ -130,18 +130,16 @@
WorkInfo.State state = workSpec != null ? workSpec.state : null;
if (state == null) {
- Logger.get().debug(TAG, String.format("WorkSpec %s does not exist", workSpecId));
+ Logger.get().debug(TAG, "WorkSpec %s does not exist" + workSpecId);
return GcmNetworkManager.RESULT_FAILURE;
} else {
switch (state) {
case SUCCEEDED:
case CANCELLED:
- Logger.get().debug(TAG,
- String.format("Returning RESULT_SUCCESS for WorkSpec %s", workSpecId));
+ Logger.get().debug(TAG, "Returning RESULT_SUCCESS for WorkSpec " + workSpecId);
return GcmNetworkManager.RESULT_SUCCESS;
case FAILED:
- Logger.get().debug(TAG,
- String.format("Returning RESULT_FAILURE for WorkSpec %s", workSpecId));
+ Logger.get().debug(TAG, "Returning RESULT_FAILURE for WorkSpec " + workSpecId);
return GcmNetworkManager.RESULT_FAILURE;
default:
Logger.get().debug(TAG, "Rescheduling eligible work.");
@@ -175,8 +173,7 @@
}
});
- Logger.get().debug(TAG,
- String.format("Returning RESULT_SUCCESS for WorkSpec %s", workSpecId));
+ Logger.get().debug(TAG, "Returning RESULT_SUCCESS for WorkSpec " + workSpecId);
return GcmNetworkManager.RESULT_SUCCESS;
}
@@ -191,7 +188,7 @@
@Override
public void onTimeLimitExceeded(@NonNull String workSpecId) {
- Logger.get().debug(TAG, String.format("WorkSpec time limit exceeded %s", workSpecId));
+ Logger.get().debug(TAG, "WorkSpec time limit exceeded " + workSpecId);
mWorkManager.stopWork(workSpecId);
}
}
@@ -220,8 +217,7 @@
public void onExecuted(@NonNull String workSpecId, boolean needsReschedule) {
if (!mWorkSpecId.equals(workSpecId)) {
Logger.get().warning(TAG,
- String.format("Notified for %s, but was looking for %s", workSpecId,
- mWorkSpecId));
+ "Notified for " + workSpecId + ", but was looking for " + mWorkSpecId);
} else {
mNeedsReschedule = needsReschedule;
mLatch.countDown();
diff --git a/work/work-multiprocess/src/main/java/androidx/work/multiprocess/ListenableWorkerImpl.java b/work/work-multiprocess/src/main/java/androidx/work/multiprocess/ListenableWorkerImpl.java
index c4c1cca..39f3fa8 100644
--- a/work/work-multiprocess/src/main/java/androidx/work/multiprocess/ListenableWorkerImpl.java
+++ b/work/work-multiprocess/src/main/java/androidx/work/multiprocess/ListenableWorkerImpl.java
@@ -93,7 +93,7 @@
final String workerClassName = parcelableRemoteWorkRequest.getWorkerClassName();
Logger.get().debug(TAG,
- String.format("Executing work request (%s, %s)", id, workerClassName));
+ "Executing work request (" + id + ", " + workerClassName + ")");
final ListenableFuture<ListenableWorker.Result> futureResult =
executeWorkRequest(id, workerClassName, workerParameters);
@@ -109,7 +109,7 @@
} catch (ExecutionException | InterruptedException exception) {
reportFailure(callback, exception);
} catch (CancellationException cancellationException) {
- Logger.get().debug(TAG, String.format("Worker (%s) was cancelled", id));
+ Logger.get().debug(TAG, "Worker (" + id + ") was cancelled");
reportFailure(callback, cancellationException);
} finally {
synchronized (sLock) {
@@ -131,7 +131,7 @@
ParcelableWorkerParameters parcelableWorkerParameters =
ParcelConverters.unmarshall(request, ParcelableWorkerParameters.CREATOR);
final String id = parcelableWorkerParameters.getId().toString();
- Logger.get().debug(TAG, String.format("Interrupting work with id (%s)", id));
+ Logger.get().debug(TAG, "Interrupting work with id (" + id + ")");
final ListenableFuture<ListenableWorker.Result> future;
synchronized (sLock) {
@@ -162,9 +162,7 @@
@NonNull WorkerParameters workerParameters) {
final SettableFuture<ListenableWorker.Result> future = SettableFuture.create();
-
- Logger.get().debug(TAG,
- String.format("Tracking execution of %s (%s)", id, workerClassName));
+ Logger.get().debug(TAG, "Tracking execution of " + id + " (" + workerClassName + ")");
synchronized (sLock) {
mFutureMap.put(id, future);
@@ -174,19 +172,15 @@
.createWorkerWithDefaultFallback(mContext, workerClassName, workerParameters);
if (worker == null) {
- String message = String.format(
- "Unable to create an instance of %s", workerClassName);
+ String message = "Unable to create an instance of " + workerClassName;
Logger.get().error(TAG, message);
future.setException(new IllegalStateException(message));
return future;
}
if (!(worker instanceof RemoteListenableWorker)) {
- String message = String.format(
- "%s does not extend %s",
- workerClassName,
- RemoteListenableWorker.class.getName()
- );
+ String message =
+ workerClassName + " does not extend " + RemoteListenableWorker.class.getName();
Logger.get().error(TAG, message);
future.setException(new IllegalStateException(message));
return future;
diff --git a/work/work-multiprocess/src/main/java/androidx/work/multiprocess/ListenableWorkerImplClient.java b/work/work-multiprocess/src/main/java/androidx/work/multiprocess/ListenableWorkerImplClient.java
index 6dbd628..1b33980 100644
--- a/work/work-multiprocess/src/main/java/androidx/work/multiprocess/ListenableWorkerImplClient.java
+++ b/work/work-multiprocess/src/main/java/androidx/work/multiprocess/ListenableWorkerImplClient.java
@@ -77,8 +77,7 @@
synchronized (mLock) {
if (mConnection == null) {
Logger.get().debug(TAG,
- String.format("Binding to %s, %s", component.getPackageName(),
- component.getClassName()));
+ "Binding to " + component.getPackageName() + ", " + component.getClassName());
mConnection = new Connection();
try {
@@ -210,7 +209,7 @@
public void onNullBinding(@NonNull ComponentName name) {
Logger.get().error(TAG, "Unable to bind to service");
mFuture.setException(
- new RuntimeException(String.format("Cannot bind to service %s", name)));
+ new RuntimeException("Cannot bind to service " + name));
}
}
diff --git a/work/work-multiprocess/src/main/java/androidx/work/multiprocess/RemoteWorkManagerClient.java b/work/work-multiprocess/src/main/java/androidx/work/multiprocess/RemoteWorkManagerClient.java
index ff89d80..8e59405 100644
--- a/work/work-multiprocess/src/main/java/androidx/work/multiprocess/RemoteWorkManagerClient.java
+++ b/work/work-multiprocess/src/main/java/androidx/work/multiprocess/RemoteWorkManagerClient.java
@@ -493,7 +493,7 @@
public void onNullBinding(@NonNull ComponentName name) {
Logger.get().error(TAG, "Unable to bind to service");
mFuture.setException(
- new RuntimeException(String.format("Cannot bind to service %s", name)));
+ new RuntimeException("Cannot bind to service " + name));
}
}
diff --git a/work/work-multiprocess/src/main/java/androidx/work/multiprocess/parcelable/ParcelableData.java b/work/work-multiprocess/src/main/java/androidx/work/multiprocess/parcelable/ParcelableData.java
index 46566ba..c22f99f 100644
--- a/work/work-multiprocess/src/main/java/androidx/work/multiprocess/parcelable/ParcelableData.java
+++ b/work/work-multiprocess/src/main/java/androidx/work/multiprocess/parcelable/ParcelableData.java
@@ -182,7 +182,7 @@
parcel.writeStringArray(stringArray);
} else {
// Exhaustive check
- String message = String.format("Unsupported value type %s", valueType.getName());
+ String message = "Unsupported value type " + valueType.getName();
throw new IllegalArgumentException(message);
}
}
@@ -240,7 +240,7 @@
value = parcel.createStringArray();
break;
default:
- String message = String.format("Unsupported type %s", type);
+ String message = "Unsupported type " + type;
throw new IllegalStateException(message);
}
String key = parcel.readString();
diff --git a/work/work-multiprocess/src/main/java/androidx/work/multiprocess/parcelable/ParcelableResult.java b/work/work-multiprocess/src/main/java/androidx/work/multiprocess/parcelable/ParcelableResult.java
index d24b96e..d4e0e3e 100644
--- a/work/work-multiprocess/src/main/java/androidx/work/multiprocess/parcelable/ParcelableResult.java
+++ b/work/work-multiprocess/src/main/java/androidx/work/multiprocess/parcelable/ParcelableResult.java
@@ -91,7 +91,7 @@
return 3;
} else {
// Exhaustive check
- throw new IllegalStateException(String.format("Unknown Result %s", result));
+ throw new IllegalStateException("Unknown Result " + result);
}
}
@@ -106,7 +106,7 @@
result = ListenableWorker.Result.failure(data);
} else {
// Exhaustive check
- throw new IllegalStateException(String.format("Unknown result type %s", resultType));
+ throw new IllegalStateException("Unknown result type " + resultType);
}
return result;
}
diff --git a/work/work-runtime/src/main/java/androidx/work/Data.java b/work/work-runtime/src/main/java/androidx/work/Data.java
index 578e83e..3eb2d7e 100644
--- a/work/work-runtime/src/main/java/androidx/work/Data.java
+++ b/work/work-runtime/src/main/java/androidx/work/Data.java
@@ -937,7 +937,7 @@
mValues.put(key, convertPrimitiveDoubleArray((double[]) value));
} else {
throw new IllegalArgumentException(
- String.format("Key %s has invalid type %s", key, valueType));
+ "Key " + key + "has invalid type " + valueType);
}
}
return this;
diff --git a/work/work-runtime/src/main/java/androidx/work/DelegatingWorkerFactory.java b/work/work-runtime/src/main/java/androidx/work/DelegatingWorkerFactory.java
index 83e1d10..1dad53b 100644
--- a/work/work-runtime/src/main/java/androidx/work/DelegatingWorkerFactory.java
+++ b/work/work-runtime/src/main/java/androidx/work/DelegatingWorkerFactory.java
@@ -75,8 +75,7 @@
}
} catch (Throwable throwable) {
String message =
- String.format("Unable to instantiate a ListenableWorker (%s)",
- workerClassName);
+ "Unable to instantiate a ListenableWorker (" + workerClassName + ")";
Logger.get().error(TAG, message, throwable);
throw throwable;
}
diff --git a/work/work-runtime/src/main/java/androidx/work/Operation.java b/work/work-runtime/src/main/java/androidx/work/Operation.java
index bf9c999..e3d8dde 100644
--- a/work/work-runtime/src/main/java/androidx/work/Operation.java
+++ b/work/work-runtime/src/main/java/androidx/work/Operation.java
@@ -142,7 +142,7 @@
@Override
@NonNull
public String toString() {
- return String.format("FAILURE (%s)", mThrowable.getMessage());
+ return "FAILURE (" + mThrowable.getMessage() + ")";
}
}
}
diff --git a/work/work-runtime/src/main/java/androidx/work/WorkerFactory.java b/work/work-runtime/src/main/java/androidx/work/WorkerFactory.java
index ef9e223..180cd47 100644
--- a/work/work-runtime/src/main/java/androidx/work/WorkerFactory.java
+++ b/work/work-runtime/src/main/java/androidx/work/WorkerFactory.java
@@ -104,12 +104,10 @@
if (worker != null && worker.isUsed()) {
String factoryName = this.getClass().getName();
- String message = String.format("WorkerFactory (%s) returned an instance of a "
- + "ListenableWorker (%s) which has already been invoked. "
- + "createWorker() must always return a new instance of a "
- + "ListenableWorker.",
- factoryName, workerClassName);
-
+ String message = "WorkerFactory (" + factoryName + ") returned an instance of a "
+ + "ListenableWorker (" + workerClassName + ") which has already been invoked. "
+ + "createWorker() must always return a new instance of a "
+ + "ListenableWorker.";
throw new IllegalStateException(message);
}
diff --git a/work/work-runtime/src/main/java/androidx/work/impl/Processor.java b/work/work-runtime/src/main/java/androidx/work/impl/Processor.java
index 10cf65e..d9c8262 100644
--- a/work/work-runtime/src/main/java/androidx/work/impl/Processor.java
+++ b/work/work-runtime/src/main/java/androidx/work/impl/Processor.java
@@ -115,9 +115,7 @@
// Work may get triggered multiple times if they have passing constraints
// and new work with those constraints are added.
if (isEnqueued(id)) {
- Logger.get().debug(
- TAG,
- String.format("Work %s is already enqueued for processing", id));
+ Logger.get().debug(TAG, "Work " + id + " is already enqueued for processing");
return false;
}
@@ -139,7 +137,7 @@
mEnqueuedWorkMap.put(id, workWrapper);
}
mWorkTaskExecutor.getBackgroundExecutor().execute(workWrapper);
- Logger.get().debug(TAG, String.format("%s: processing %s", getClass().getSimpleName(), id));
+ Logger.get().debug(TAG, getClass().getSimpleName() + ": processing " + id);
return true;
}
@@ -147,8 +145,7 @@
public void startForeground(@NonNull String workSpecId,
@NonNull ForegroundInfo foregroundInfo) {
synchronized (mLock) {
- Logger.get().info(TAG, String.format("Moving WorkSpec (%s) to the foreground",
- workSpecId));
+ Logger.get().info(TAG, "Moving WorkSpec (" + workSpecId + ") to the foreground");
WorkerWrapper wrapper = mEnqueuedWorkMap.remove(workSpecId);
if (wrapper != null) {
if (mForegroundLock == null) {
@@ -171,7 +168,7 @@
*/
public boolean stopForegroundWork(@NonNull String id) {
synchronized (mLock) {
- Logger.get().debug(TAG, String.format("Processor stopping foreground work %s", id));
+ Logger.get().debug(TAG, "Processor stopping foreground work " + id);
WorkerWrapper wrapper = mForegroundWorkMap.remove(id);
return interrupt(id, wrapper);
}
@@ -185,7 +182,7 @@
*/
public boolean stopWork(@NonNull String id) {
synchronized (mLock) {
- Logger.get().debug(TAG, String.format("Processor stopping background work %s", id));
+ Logger.get().debug(TAG, "Processor stopping background work " + id);
WorkerWrapper wrapper = mEnqueuedWorkMap.remove(id);
return interrupt(id, wrapper);
}
@@ -199,7 +196,7 @@
*/
public boolean stopAndCancelWork(@NonNull String id) {
synchronized (mLock) {
- Logger.get().debug(TAG, String.format("Processor cancelling %s", id));
+ Logger.get().debug(TAG, "Processor cancelling " + id);
mCancelledIds.add(id);
WorkerWrapper wrapper;
// Check if running in the context of a foreground service
@@ -297,9 +294,9 @@
synchronized (mLock) {
mEnqueuedWorkMap.remove(workSpecId);
- Logger.get().debug(TAG, String.format("%s %s executed; reschedule = %s",
- getClass().getSimpleName(), workSpecId, needsReschedule));
-
+ Logger.get().debug(TAG,
+ getClass().getSimpleName() + " " + workSpecId +
+ " executed; reschedule = " + needsReschedule);
for (ExecutionListener executionListener : mOuterListeners) {
executionListener.onExecuted(workSpecId, needsReschedule);
}
@@ -338,10 +335,10 @@
private static boolean interrupt(@NonNull String id, @Nullable WorkerWrapper wrapper) {
if (wrapper != null) {
wrapper.interrupt();
- Logger.get().debug(TAG, String.format("WorkerWrapper interrupted for %s", id));
+ Logger.get().debug(TAG, "WorkerWrapper interrupted for " + id);
return true;
} else {
- Logger.get().debug(TAG, String.format("WorkerWrapper could not be found for %s", id));
+ Logger.get().debug(TAG, "WorkerWrapper could not be found for " + id);
return false;
}
}
diff --git a/work/work-runtime/src/main/java/androidx/work/impl/Schedulers.java b/work/work-runtime/src/main/java/androidx/work/impl/Schedulers.java
index b43c623..9569703 100644
--- a/work/work-runtime/src/main/java/androidx/work/impl/Schedulers.java
+++ b/work/work-runtime/src/main/java/androidx/work/impl/Schedulers.java
@@ -150,7 +150,7 @@
Class<?> klass = Class.forName(GCM_SCHEDULER);
Scheduler scheduler =
(Scheduler) klass.getConstructor(Context.class).newInstance(context);
- Logger.get().debug(TAG, String.format("Created %s", GCM_SCHEDULER));
+ Logger.get().debug(TAG, "Created " + GCM_SCHEDULER);
return scheduler;
} catch (Throwable throwable) {
Logger.get().debug(TAG, "Unable to create GCM Scheduler", throwable);
diff --git a/work/work-runtime/src/main/java/androidx/work/impl/WorkContinuationImpl.java b/work/work-runtime/src/main/java/androidx/work/impl/WorkContinuationImpl.java
index 83762b4..525d7d0 100644
--- a/work/work-runtime/src/main/java/androidx/work/impl/WorkContinuationImpl.java
+++ b/work/work-runtime/src/main/java/androidx/work/impl/WorkContinuationImpl.java
@@ -188,7 +188,7 @@
mOperation = runnable.getOperation();
} else {
Logger.get().warning(TAG,
- String.format("Already enqueued work ids (%s)", TextUtils.join(", ", mIds)));
+ "Already enqueued work ids (" + TextUtils.join(", ", mIds) + ")");
}
return mOperation;
}
diff --git a/work/work-runtime/src/main/java/androidx/work/impl/WorkDatabasePathHelper.java b/work/work-runtime/src/main/java/androidx/work/impl/WorkDatabasePathHelper.java
index 0b4bf2b..6acbfaeb 100644
--- a/work/work-runtime/src/main/java/androidx/work/impl/WorkDatabasePathHelper.java
+++ b/work/work-runtime/src/main/java/androidx/work/impl/WorkDatabasePathHelper.java
@@ -68,15 +68,15 @@
File destination = paths.get(source);
if (source.exists() && destination != null) {
if (destination.exists()) {
- String message = String.format("Over-writing contents of %s", destination);
+ String message = "Over-writing contents of " + destination;
Logger.get().warning(TAG, message);
}
boolean renamed = source.renameTo(destination);
String message;
if (renamed) {
- message = String.format("Migrated %s to %s", source, destination);
+ message = "Migrated " + source + "to " + destination;
} else {
- message = String.format("Renaming %s to %s failed", source, destination);
+ message = "Renaming " + source + " to " + destination + " failed";
}
Logger.get().debug(TAG, message);
}
diff --git a/work/work-runtime/src/main/java/androidx/work/impl/WorkerWrapper.java b/work/work-runtime/src/main/java/androidx/work/impl/WorkerWrapper.java
index 12b8eee..eee1b9c 100644
--- a/work/work-runtime/src/main/java/androidx/work/impl/WorkerWrapper.java
+++ b/work/work-runtime/src/main/java/androidx/work/impl/WorkerWrapper.java
@@ -148,7 +148,7 @@
if (mWorkSpec == null) {
Logger.get().error(
TAG,
- String.format("Didn't find WorkSpec for id %s", mWorkSpecId));
+ "Didn't find WorkSpec for id " + mWorkSpecId);
resolve(false);
mWorkDatabase.setTransactionSuccessful();
return;
@@ -160,8 +160,8 @@
resolveIncorrectStatus();
mWorkDatabase.setTransactionSuccessful();
Logger.get().debug(TAG,
- String.format("%s is not in ENQUEUED state. Nothing more to do.",
- mWorkSpec.workerClassName));
+ mWorkSpec.workerClassName
+ + " is not in ENQUEUED state. Nothing more to do");
return;
}
@@ -216,8 +216,7 @@
InputMerger inputMerger =
inputMergerFactory.createInputMergerWithDefaultFallback(inputMergerClassName);
if (inputMerger == null) {
- Logger.get().error(TAG, String.format("Could not create Input Merger %s",
- mWorkSpec.inputMergerClassName));
+ Logger.get().error(TAG, "Could not create Input Merger " + mWorkSpec.inputMergerClassName);
setFailedAndResolve();
return;
}
@@ -250,16 +249,14 @@
if (mWorker == null) {
Logger.get().error(TAG,
- String.format("Could not create Worker %s", mWorkSpec.workerClassName));
+ "Could not create Worker " + mWorkSpec.workerClassName);
setFailedAndResolve();
return;
}
if (mWorker.isUsed()) {
- Logger.get().error(TAG,
- String.format("Received an already-used Worker %s; WorkerFactory should return "
- + "new instances",
- mWorkSpec.workerClassName));
+ Logger.get().error(TAG, "Received an already-used Worker " + mWorkSpec.workerClassName
+ + "; Worker Factory should return new instances");
setFailedAndResolve();
return;
}
@@ -290,7 +287,7 @@
try {
runExpedited.get();
Logger.get().debug(TAG,
- String.format("Starting work for %s", mWorkSpec.workerClassName));
+ "Starting work for " + mWorkSpec.workerClassName);
// Call mWorker.startWork() on the main thread.
mInnerFuture = mWorker.startWork();
future.setFuture(mInnerFuture);
@@ -310,23 +307,20 @@
// If the ListenableWorker returns a null result treat it as a failure.
ListenableWorker.Result result = future.get();
if (result == null) {
- Logger.get().error(TAG, String.format(
- "%s returned a null result. Treating it as a failure.",
- mWorkSpec.workerClassName));
+ Logger.get().error(TAG, mWorkSpec.workerClassName
+ + " returned a null result. Treating it as a failure.");
} else {
- Logger.get().debug(TAG, String.format("%s returned a %s result.",
- mWorkSpec.workerClassName, result));
+ Logger.get().debug(TAG,
+ mWorkSpec.workerClassName + " returned a " + result + ".");
mResult = result;
}
} catch (CancellationException exception) {
// Cancellations need to be treated with care here because innerFuture
// cancellations will bubble up, and we need to gracefully handle that.
- Logger.get().info(TAG, String.format("%s was cancelled", workDescription),
- exception);
+ Logger.get().info(TAG, workDescription + " was cancelled", exception);
} catch (InterruptedException | ExecutionException exception) {
Logger.get().error(TAG,
- String.format("%s failed because it threw an exception/error",
- workDescription), exception);
+ workDescription + " failed because it threw an exception/error");
} finally {
onWorkFinished();
}
@@ -396,8 +390,7 @@
if (mWorker != null && !isDone) {
mWorker.stop();
} else {
- String message =
- String.format("WorkSpec %s is already done. Not interrupting.", mWorkSpec);
+ String message = "WorkSpec " + mWorkSpec + " is already done. Not interrupting.";
Logger.get().debug(TAG, message);
}
}
@@ -405,12 +398,12 @@
private void resolveIncorrectStatus() {
WorkInfo.State status = mWorkSpecDao.getState(mWorkSpecId);
if (status == RUNNING) {
- Logger.get().debug(TAG, String.format("Status for %s is RUNNING;"
- + "not doing any work and rescheduling for later execution", mWorkSpecId));
+ Logger.get().debug(TAG, "Status for " + mWorkSpecId
+ + " is RUNNING; not doing any work and rescheduling for later execution");
resolve(true);
} else {
Logger.get().debug(TAG,
- String.format("Status for %s is %s; not doing any work", mWorkSpecId, status));
+ "Status for " + mWorkSpecId + " is " + status + " ; not doing any work");
resolve(false);
}
}
@@ -422,7 +415,7 @@
// Worker exceeding a 10 min execution window.
// One scheduler completing a Worker, and telling other Schedulers to cleanup.
if (mInterrupted) {
- Logger.get().debug(TAG, String.format("Work interrupted for %s", mWorkDescription));
+ Logger.get().debug(TAG, "Work interrupted for " + mWorkDescription);
WorkInfo.State currentState = mWorkSpecDao.getState(mWorkSpecId);
if (currentState == null) {
// This can happen because of a beginUniqueWork(..., REPLACE, ...). Notify the
@@ -470,7 +463,7 @@
if (result instanceof ListenableWorker.Result.Success) {
Logger.get().info(
TAG,
- String.format("Worker result SUCCESS for %s", mWorkDescription));
+ "Worker result SUCCESS for " + mWorkDescription);
if (mWorkSpec.isPeriodic()) {
resetPeriodicAndResolve();
} else {
@@ -480,12 +473,12 @@
} else if (result instanceof ListenableWorker.Result.Retry) {
Logger.get().info(
TAG,
- String.format("Worker result RETRY for %s", mWorkDescription));
+ "Worker result RETRY for " + mWorkDescription);
rescheduleAndResolve();
} else {
Logger.get().info(
TAG,
- String.format("Worker result FAILURE for %s", mWorkDescription));
+ "Worker result FAILURE for " + mWorkDescription);
if (mWorkSpec.isPeriodic()) {
resetPeriodicAndResolve();
} else {
@@ -588,7 +581,7 @@
if (mWorkSpecDao.getState(dependentWorkId) == BLOCKED
&& mDependencyDao.hasCompletedAllPrerequisites(dependentWorkId)) {
Logger.get().info(TAG,
- String.format("Setting status to enqueued for %s", dependentWorkId));
+ "Setting status to enqueued for " + dependentWorkId);
mWorkSpecDao.setState(ENQUEUED, dependentWorkId);
mWorkSpecDao.setPeriodStartTime(dependentWorkId, currentTimeMillis);
}
diff --git a/work/work-runtime/src/main/java/androidx/work/impl/background/greedy/DelayedWorkTracker.java b/work/work-runtime/src/main/java/androidx/work/impl/background/greedy/DelayedWorkTracker.java
index ccc0c64..8d46d0a 100644
--- a/work/work-runtime/src/main/java/androidx/work/impl/background/greedy/DelayedWorkTracker.java
+++ b/work/work-runtime/src/main/java/androidx/work/impl/background/greedy/DelayedWorkTracker.java
@@ -71,7 +71,7 @@
Runnable runnable = new Runnable() {
@Override
public void run() {
- Logger.get().debug(TAG, String.format("Scheduling work %s", workSpec.id));
+ Logger.get().debug(TAG, "Scheduling work " + workSpec.id);
mGreedyScheduler.schedule(workSpec);
}
};
diff --git a/work/work-runtime/src/main/java/androidx/work/impl/background/systemalarm/Alarms.java b/work/work-runtime/src/main/java/androidx/work/impl/background/systemalarm/Alarms.java
index e98a2b8..d9555fd 100644
--- a/work/work-runtime/src/main/java/androidx/work/impl/background/systemalarm/Alarms.java
+++ b/work/work-runtime/src/main/java/androidx/work/impl/background/systemalarm/Alarms.java
@@ -90,7 +90,7 @@
if (systemIdInfo != null) {
cancelExactAlarm(context, workSpecId, systemIdInfo.systemId);
Logger.get().debug(TAG,
- String.format("Removing SystemIdInfo for workSpecId (%s)", workSpecId));
+ "Removing SystemIdInfo for workSpecId (" + workSpecId + ")");
systemIdInfoDao.removeSystemIdInfo(workSpecId);
}
}
@@ -108,10 +108,7 @@
}
PendingIntent pendingIntent = PendingIntent.getService(context, alarmId, delayMet, flags);
if (pendingIntent != null && alarmManager != null) {
- Logger.get().debug(TAG, String.format(
- "Cancelling existing alarm with (workSpecId, systemId) (%s, %s)",
- workSpecId,
- alarmId));
+ Logger.get().debug(TAG, "Cancelling existing alarm with (workSpecId, systemId) (" + workSpecId + ", " + alarmId + ")");
alarmManager.cancel(pendingIntent);
}
}
diff --git a/work/work-runtime/src/main/java/androidx/work/impl/background/systemalarm/CommandHandler.java b/work/work-runtime/src/main/java/androidx/work/impl/background/systemalarm/CommandHandler.java
index 736b79d..a3bcefa 100644
--- a/work/work-runtime/src/main/java/androidx/work/impl/background/systemalarm/CommandHandler.java
+++ b/work/work-runtime/src/main/java/androidx/work/impl/background/systemalarm/CommandHandler.java
@@ -161,9 +161,7 @@
Bundle extras = intent.getExtras();
if (!hasKeys(extras, KEY_WORKSPEC_ID)) {
Logger.get().error(TAG,
- String.format("Invalid request for %s, requires %s.",
- action,
- KEY_WORKSPEC_ID));
+ "Invalid request for " + action + " , requires " + KEY_WORKSPEC_ID + " .");
} else {
if (ACTION_SCHEDULE_WORK.equals(action)) {
handleScheduleWorkIntent(intent, startId, dispatcher);
@@ -174,7 +172,7 @@
} else if (ACTION_EXECUTION_COMPLETED.equals(action)) {
handleExecutionCompleted(intent, startId);
} else {
- Logger.get().warning(TAG, String.format("Ignoring intent %s", intent));
+ Logger.get().warning(TAG, "Ignoring intent " + intent);
}
}
}
@@ -187,7 +185,7 @@
Bundle extras = intent.getExtras();
String workSpecId = extras.getString(KEY_WORKSPEC_ID);
- Logger.get().debug(TAG, String.format("Handling schedule work for %s", workSpecId));
+ Logger.get().debug(TAG, "Handling schedule work for " + workSpecId);
WorkManagerImpl workManager = dispatcher.getWorkManager();
WorkDatabase workDatabase = workManager.getWorkDatabase();
@@ -224,13 +222,12 @@
if (!workSpec.hasConstraints()) {
Logger.get().debug(TAG,
- String.format("Setting up Alarms for %s at %s", workSpecId, triggerAt));
+ "Setting up Alarms for " + workSpecId + "at " + triggerAt);
Alarms.setAlarm(mContext, dispatcher.getWorkManager(), workSpecId, triggerAt);
} else {
// Schedule an alarm irrespective of whether all constraints matched.
Logger.get().debug(TAG,
- String.format("Opportunistically setting an alarm for %s at %s", workSpecId,
- triggerAt));
+ "Opportunistically setting an alarm for " + workSpecId + "at " + triggerAt);
Alarms.setAlarm(
mContext,
dispatcher.getWorkManager(),
@@ -261,7 +258,7 @@
Bundle extras = intent.getExtras();
synchronized (mLock) {
String workSpecId = extras.getString(KEY_WORKSPEC_ID);
- Logger.get().debug(TAG, String.format("Handing delay met for %s", workSpecId));
+ Logger.get().debug(TAG, "Handing delay met for " + workSpecId);
// Check to see if we are already handling an ACTION_DELAY_MET for the WorkSpec.
// If we are, then there is nothing for us to do.
@@ -271,9 +268,8 @@
mPendingDelayMet.put(workSpecId, delayMetCommandHandler);
delayMetCommandHandler.handleProcessWork();
} else {
- Logger.get().debug(TAG,
- String.format("WorkSpec %s is already being handled for ACTION_DELAY_MET",
- workSpecId));
+ Logger.get().debug(TAG, "WorkSpec " + workSpecId
+ + " is is already being handled for ACTION_DELAY_MET");
}
}
}
@@ -284,7 +280,7 @@
Bundle extras = intent.getExtras();
String workSpecId = extras.getString(KEY_WORKSPEC_ID);
- Logger.get().debug(TAG, String.format("Handing stopWork work for %s", workSpecId));
+ Logger.get().debug(TAG, "Handing stopWork work for " + workSpecId);
dispatcher.getWorkManager().stopWork(workSpecId);
Alarms.cancelAlarm(mContext, dispatcher.getWorkManager(), workSpecId);
@@ -297,7 +293,7 @@
@NonNull Intent intent, int startId,
@NonNull SystemAlarmDispatcher dispatcher) {
- Logger.get().debug(TAG, String.format("Handling constraints changed %s", intent));
+ Logger.get().debug(TAG, "Handling constraints changed " + intent);
// Constraints changed command handler is synchronous. No cleanup
// is necessary.
ConstraintsCommandHandler changedCommandHandler =
@@ -310,7 +306,7 @@
int startId,
@NonNull SystemAlarmDispatcher dispatcher) {
- Logger.get().debug(TAG, String.format("Handling reschedule %s, %s", intent, startId));
+ Logger.get().debug(TAG, "Handling reschedule " + intent + ", " + startId);
dispatcher.getWorkManager().rescheduleEligibleWork();
}
@@ -323,7 +319,7 @@
boolean needsReschedule = extras.getBoolean(KEY_NEEDS_RESCHEDULE);
Logger.get().debug(
TAG,
- String.format("Handling onExecutionCompleted %s, %s", intent, startId));
+ "Handling onExecutionCompleted " + intent + ", " + startId);
// Delegate onExecuted() to the command handler.
onExecuted(workSpecId, needsReschedule);
}
diff --git a/work/work-runtime/src/main/java/androidx/work/impl/background/systemalarm/ConstraintProxy.java b/work/work-runtime/src/main/java/androidx/work/impl/background/systemalarm/ConstraintProxy.java
index 69ec75e..31de7d7 100644
--- a/work/work-runtime/src/main/java/androidx/work/impl/background/systemalarm/ConstraintProxy.java
+++ b/work/work-runtime/src/main/java/androidx/work/impl/background/systemalarm/ConstraintProxy.java
@@ -32,7 +32,7 @@
@Override
public void onReceive(Context context, Intent intent) {
- Logger.get().debug(TAG, String.format("onReceive : %s", intent));
+ Logger.get().debug(TAG, "onReceive : " + intent);
Intent constraintChangedIntent = CommandHandler.createConstraintsChangedIntent(context);
context.startService(constraintChangedIntent);
}
diff --git a/work/work-runtime/src/main/java/androidx/work/impl/background/systemalarm/ConstraintProxyUpdateReceiver.java b/work/work-runtime/src/main/java/androidx/work/impl/background/systemalarm/ConstraintProxyUpdateReceiver.java
index 5b563aa..179b414 100644
--- a/work/work-runtime/src/main/java/androidx/work/impl/background/systemalarm/ConstraintProxyUpdateReceiver.java
+++ b/work/work-runtime/src/main/java/androidx/work/impl/background/systemalarm/ConstraintProxyUpdateReceiver.java
@@ -82,7 +82,7 @@
public void onReceive(@NonNull final Context context, @Nullable final Intent intent) {
String action = intent != null ? intent.getAction() : null;
if (!ACTION.equals(action)) {
- Logger.get().debug(TAG, String.format("Ignoring unknown action %s", action));
+ Logger.get().debug(TAG, "Ignoring unknown action " + action);
} else {
final PendingResult pendingResult = goAsync();
WorkManagerImpl workManager = WorkManagerImpl.getInstance(context);
@@ -103,17 +103,13 @@
boolean networkStateProxyEnabled = intent.getBooleanExtra(
KEY_NETWORK_STATE_PROXY_ENABLED, false);
- Logger.get().debug(
- TAG,
- String.format("Updating proxies: BatteryNotLowProxy enabled (%s), "
- + "BatteryChargingProxy enabled (%s), "
- + "StorageNotLowProxy (%s), "
- + "NetworkStateProxy enabled (%s)",
- batteryNotLowProxyEnabled,
- batteryChargingProxyEnabled,
- storageNotLowProxyEnabled,
- networkStateProxyEnabled));
+ String message = "Updating proxies: ("
+ + "BatteryNotLowProxy (" + batteryNotLowProxyEnabled + "), "
+ + "BatteryChargingProxy (" + batteryChargingProxyEnabled + "), "
+ + "StorageNotLowProxy (" + storageNotLowProxyEnabled + "), "
+ + "NetworkStateProxy (" + networkStateProxyEnabled + "), ";
+ Logger.get().debug(TAG, message);
PackageManagerHelper.setComponentEnabled(context, BatteryNotLowProxy.class,
batteryNotLowProxyEnabled);
PackageManagerHelper.setComponentEnabled(context,
diff --git a/work/work-runtime/src/main/java/androidx/work/impl/background/systemalarm/ConstraintsCommandHandler.java b/work/work-runtime/src/main/java/androidx/work/impl/background/systemalarm/ConstraintsCommandHandler.java
index 8b843e2..a78ea08 100644
--- a/work/work-runtime/src/main/java/androidx/work/impl/background/systemalarm/ConstraintsCommandHandler.java
+++ b/work/work-runtime/src/main/java/androidx/work/impl/background/systemalarm/ConstraintsCommandHandler.java
@@ -86,8 +86,7 @@
for (WorkSpec workSpec : eligibleWorkSpecs) {
String workSpecId = workSpec.id;
Intent intent = CommandHandler.createDelayMetIntent(mContext, workSpecId);
- Logger.get().debug(TAG, String.format(
- "Creating a delay_met command for workSpec with id (%s)", workSpecId));
+ Logger.get().debug(TAG, "Creating a delay_met command for workSpec with id (" + workSpecId + ")");
mDispatcher.postOnMainThread(
new SystemAlarmDispatcher.AddRunnable(mDispatcher, intent, mStartId));
}
diff --git a/work/work-runtime/src/main/java/androidx/work/impl/background/systemalarm/DelayMetCommandHandler.java b/work/work-runtime/src/main/java/androidx/work/impl/background/systemalarm/DelayMetCommandHandler.java
index 9435259..ed912dc 100644
--- a/work/work-runtime/src/main/java/androidx/work/impl/background/systemalarm/DelayMetCommandHandler.java
+++ b/work/work-runtime/src/main/java/androidx/work/impl/background/systemalarm/DelayMetCommandHandler.java
@@ -123,7 +123,7 @@
if (mCurrentState == STATE_INITIAL) {
mCurrentState = STATE_START_REQUESTED;
- Logger.get().debug(TAG, String.format("onAllConstraintsMet for %s", mWorkSpecId));
+ Logger.get().debug(TAG, "onAllConstraintsMet for " + mWorkSpecId);
// Constraints met, schedule execution
// Not using WorkManagerImpl#startWork() here because we need to know if the
// processor actually enqueued the work here.
@@ -140,14 +140,14 @@
cleanUp();
}
} else {
- Logger.get().debug(TAG, String.format("Already started work for %s", mWorkSpecId));
+ Logger.get().debug(TAG, "Already started work for " + mWorkSpecId);
}
}
}
@Override
public void onExecuted(@NonNull String workSpecId, boolean needsReschedule) {
- Logger.get().debug(TAG, String.format("onExecuted %s, %s", workSpecId, needsReschedule));
+ Logger.get().debug(TAG, "onExecuted " + workSpecId + ", " + needsReschedule);
cleanUp();
if (needsReschedule) {
@@ -172,7 +172,7 @@
public void onTimeLimitExceeded(@NonNull String workSpecId) {
Logger.get().debug(
TAG,
- String.format("Exceeded time limits on execution for %s", workSpecId));
+ "Exceeded time limits on execution for " + workSpecId);
stopWork();
}
@@ -183,11 +183,9 @@
@WorkerThread
void handleProcessWork() {
- mWakeLock = WakeLocks.newWakeLock(
- mContext,
- String.format("%s (%s)", mWorkSpecId, mStartId));
+ mWakeLock = WakeLocks.newWakeLock(mContext, mWorkSpecId + " (" + mStartId + ")");
Logger.get().debug(TAG,
- String.format("Acquiring wakelock %s for WorkSpec %s", mWakeLock, mWorkSpecId));
+ "Acquiring wakelock " + mWakeLock + "for WorkSpec " + mWorkSpecId);
mWakeLock.acquire();
WorkSpec workSpec = mDispatcher.getWorkManager()
@@ -208,7 +206,7 @@
mHasConstraints = workSpec.hasConstraints();
if (!mHasConstraints) {
- Logger.get().debug(TAG, String.format("No constraints for %s", mWorkSpecId));
+ Logger.get().debug(TAG, "No constraints for " + mWorkSpecId);
onAllConstraintsMet(Collections.singletonList(mWorkSpecId));
} else {
// Allow tracker to report constraint changes
@@ -228,7 +226,7 @@
mCurrentState = STATE_STOP_REQUESTED;
Logger.get().debug(
TAG,
- String.format("Stopping work for WorkSpec %s", mWorkSpecId));
+ "Stopping work for WorkSpec " + mWorkSpecId);
Intent stopWork = CommandHandler.createStopWorkIntent(mContext, mWorkSpecId);
mDispatcher.postOnMainThread(
new SystemAlarmDispatcher.AddRunnable(mDispatcher, stopWork, mStartId));
@@ -237,20 +235,18 @@
// reschedule should not happen. For e.g. DELAY_MET when constraints are not met,
// should not result in a reschedule.
if (mDispatcher.getProcessor().isEnqueued(mWorkSpecId)) {
- Logger.get().debug(TAG,
- String.format("WorkSpec %s needs to be rescheduled", mWorkSpecId));
+ Logger.get().debug(TAG, "WorkSpec " + mWorkSpecId + " needs to be rescheduled");
Intent reschedule = CommandHandler.createScheduleWorkIntent(mContext,
mWorkSpecId);
mDispatcher.postOnMainThread(
new SystemAlarmDispatcher.AddRunnable(mDispatcher, reschedule,
mStartId));
} else {
- Logger.get().debug(TAG, String.format(
- "Processor does not have WorkSpec %s. No need to reschedule ",
- mWorkSpecId));
+ Logger.get().debug(TAG, "Processor does not have WorkSpec " + mWorkSpecId
+ + ". No need to reschedule");
}
} else {
- Logger.get().debug(TAG, String.format("Already stopped work for %s", mWorkSpecId));
+ Logger.get().debug(TAG, "Already stopped work for " + mWorkSpecId);
}
}
}
@@ -270,8 +266,7 @@
// release wake locks
if (mWakeLock != null && mWakeLock.isHeld()) {
- Logger.get().debug(TAG, String.format(
- "Releasing wakelock %s for WorkSpec %s", mWakeLock, mWorkSpecId));
+ Logger.get().debug(TAG, "Releasing wakelock " + mWakeLock + "for WorkSpec " + mWorkSpecId);
mWakeLock.release();
}
}
diff --git a/work/work-runtime/src/main/java/androidx/work/impl/background/systemalarm/RescheduleReceiver.java b/work/work-runtime/src/main/java/androidx/work/impl/background/systemalarm/RescheduleReceiver.java
index 8f84b5b..d91ef62 100644
--- a/work/work-runtime/src/main/java/androidx/work/impl/background/systemalarm/RescheduleReceiver.java
+++ b/work/work-runtime/src/main/java/androidx/work/impl/background/systemalarm/RescheduleReceiver.java
@@ -33,7 +33,7 @@
@Override
public void onReceive(Context context, Intent intent) {
- Logger.get().debug(TAG, String.format("Received intent %s", intent));
+ Logger.get().debug(TAG, "Received intent " + intent);
if (Build.VERSION.SDK_INT >= WorkManagerImpl.MIN_JOB_SCHEDULER_API_LEVEL) {
try {
WorkManagerImpl workManager = WorkManagerImpl.getInstance(context);
diff --git a/work/work-runtime/src/main/java/androidx/work/impl/background/systemalarm/SystemAlarmDispatcher.java b/work/work-runtime/src/main/java/androidx/work/impl/background/systemalarm/SystemAlarmDispatcher.java
index 8c1b5e5..13c65df 100644
--- a/work/work-runtime/src/main/java/androidx/work/impl/background/systemalarm/SystemAlarmDispatcher.java
+++ b/work/work-runtime/src/main/java/androidx/work/impl/background/systemalarm/SystemAlarmDispatcher.java
@@ -133,7 +133,7 @@
*/
@MainThread
public boolean add(@NonNull final Intent intent, final int startId) {
- Logger.get().debug(TAG, String.format("Adding command %s (%s)", intent, startId));
+ Logger.get().debug(TAG, "Adding command " + intent + " (" + startId + ")");
assertMainThread();
String action = intent.getAction();
if (TextUtils.isEmpty(action)) {
@@ -217,7 +217,7 @@
// ReentrantLock, and lock the queue while command processor processes
// an intent. Synchronized to prevent ConcurrentModificationExceptions.
if (mCurrentIntent != null) {
- Logger.get().debug(TAG, String.format("Removing command %s", mCurrentIntent));
+ Logger.get().debug(TAG, "Removing command " + mCurrentIntent);
if (!mIntents.remove(0).equals(mCurrentIntent)) {
throw new IllegalStateException("Dequeue-d command is not the first.");
}
@@ -262,17 +262,13 @@
final int startId = mCurrentIntent.getIntExtra(KEY_START_ID,
DEFAULT_START_ID);
Logger.get().debug(TAG,
- String.format("Processing command %s, %s", mCurrentIntent,
- startId));
+ "Processing command " + mCurrentIntent + ", " + startId);
final PowerManager.WakeLock wakeLock = WakeLocks.newWakeLock(
mContext,
- String.format("%s (%s)", action, startId));
+ action + " (" + startId + ")");
try {
- Logger.get().debug(TAG, String.format(
- "Acquiring operation wake lock (%s) %s",
- action,
- wakeLock));
-
+ Logger.get().debug(TAG,
+ "Acquiring operation wake lock (" + action + ") " + wakeLock);
wakeLock.acquire();
mCommandHandler.onHandleIntent(mCurrentIntent, startId,
SystemAlarmDispatcher.this);
@@ -284,10 +280,7 @@
} finally {
Logger.get().debug(
TAG,
- String.format(
- "Releasing operation wake lock (%s) %s",
- action,
- wakeLock));
+ "Releasing operation wake lock (" + action + ") " + wakeLock);
wakeLock.release();
// Check if we have processed all commands
postOnMainThread(
diff --git a/work/work-runtime/src/main/java/androidx/work/impl/background/systemalarm/SystemAlarmScheduler.java b/work/work-runtime/src/main/java/androidx/work/impl/background/systemalarm/SystemAlarmScheduler.java
index 633121b..15a272a 100644
--- a/work/work-runtime/src/main/java/androidx/work/impl/background/systemalarm/SystemAlarmScheduler.java
+++ b/work/work-runtime/src/main/java/androidx/work/impl/background/systemalarm/SystemAlarmScheduler.java
@@ -64,7 +64,7 @@
* times to drift to guarantee that the interval duration always elapses between alarms.
*/
private void scheduleWorkSpec(@NonNull WorkSpec workSpec) {
- Logger.get().debug(TAG, String.format("Scheduling work with workSpecId %s", workSpec.id));
+ Logger.get().debug(TAG, "Scheduling work with workSpecId " + workSpec.id);
Intent scheduleIntent = CommandHandler.createScheduleWorkIntent(mContext, workSpec.id);
mContext.startService(scheduleIntent);
}
diff --git a/work/work-runtime/src/main/java/androidx/work/impl/background/systemjob/SystemJobInfoConverter.java b/work/work-runtime/src/main/java/androidx/work/impl/background/systemjob/SystemJobInfoConverter.java
index 02df55e..1dd016c 100644
--- a/work/work-runtime/src/main/java/androidx/work/impl/background/systemjob/SystemJobInfoConverter.java
+++ b/work/work-runtime/src/main/java/androidx/work/impl/background/systemjob/SystemJobInfoConverter.java
@@ -187,8 +187,7 @@
}
break;
}
- Logger.get().debug(TAG, String.format(
- "API version too low. Cannot convert network type value %s", networkType));
+ Logger.get().debug(TAG, "API version too low. Cannot convert network type value " + networkType);
return JobInfo.NETWORK_TYPE_ANY;
}
}
diff --git a/work/work-runtime/src/main/java/androidx/work/impl/background/systemjob/SystemJobScheduler.java b/work/work-runtime/src/main/java/androidx/work/impl/background/systemjob/SystemJobScheduler.java
index dcbb0d5e..754be5f 100644
--- a/work/work-runtime/src/main/java/androidx/work/impl/background/systemjob/SystemJobScheduler.java
+++ b/work/work-runtime/src/main/java/androidx/work/impl/background/systemjob/SystemJobScheduler.java
@@ -182,12 +182,12 @@
JobInfo jobInfo = mSystemJobInfoConverter.convert(workSpec, jobId);
Logger.get().debug(
TAG,
- String.format("Scheduling work ID %s Job ID %s", workSpec.id, jobId));
+ "Scheduling work ID " + workSpec.id + "Job ID " + jobId);
try {
int result = mJobScheduler.schedule(jobInfo);
if (result == JobScheduler.RESULT_FAILURE) {
Logger.get()
- .warning(TAG, String.format("Unable to schedule work ID %s", workSpec.id));
+ .warning(TAG, "Unable to schedule work ID " + workSpec.id);
if (workSpec.expedited
&& workSpec.outOfQuotaPolicy == RUN_AS_NON_EXPEDITED_WORK_REQUEST) {
// Falling back to a non-expedited job.
@@ -218,7 +218,7 @@
throw new IllegalStateException(message, e);
} catch (Throwable throwable) {
// OEM implementation bugs in JobScheduler cause the app to crash. Avoid crashing.
- Logger.get().error(TAG, String.format("Unable to schedule %s", workSpec), throwable);
+ Logger.get().error(TAG, "Unable to schedule " + workSpec, throwable);
}
}
diff --git a/work/work-runtime/src/main/java/androidx/work/impl/background/systemjob/SystemJobService.java b/work/work-runtime/src/main/java/androidx/work/impl/background/systemjob/SystemJobService.java
index bbc87a0..d561dbf 100644
--- a/work/work-runtime/src/main/java/androidx/work/impl/background/systemjob/SystemJobService.java
+++ b/work/work-runtime/src/main/java/androidx/work/impl/background/systemjob/SystemJobService.java
@@ -106,8 +106,7 @@
if (mJobParameters.containsKey(workSpecId)) {
// This condition may happen due to our workaround for an undesired behavior in API
// 23. See the documentation in {@link SystemJobScheduler#schedule}.
- Logger.get().debug(TAG, String.format(
- "Job is already being executed by SystemJobService: %s", workSpecId));
+ Logger.get().debug(TAG, "Job is already being executed by SystemJobService: " + workSpecId);
return false;
}
@@ -115,7 +114,7 @@
// returns true. This is because JobScheduler ensures that for PeriodicWork, constraints
// are actually met irrespective.
- Logger.get().debug(TAG, String.format("onStartJob for %s", workSpecId));
+ Logger.get().debug(TAG, "onStartJob for " + workSpecId);
mJobParameters.put(workSpecId, params);
}
@@ -159,7 +158,7 @@
return false;
}
- Logger.get().debug(TAG, String.format("onStopJob for %s", workSpecId));
+ Logger.get().debug(TAG, "onStopJob for " + workSpecId);
synchronized (mJobParameters) {
mJobParameters.remove(workSpecId);
@@ -170,7 +169,7 @@
@Override
public void onExecuted(@NonNull String workSpecId, boolean needsReschedule) {
- Logger.get().debug(TAG, String.format("%s executed on JobScheduler", workSpecId));
+ Logger.get().debug(TAG, workSpecId + " executed on JobScheduler");
JobParameters parameters;
synchronized (mJobParameters) {
parameters = mJobParameters.remove(workSpecId);
diff --git a/work/work-runtime/src/main/java/androidx/work/impl/constraints/NetworkState.java b/work/work-runtime/src/main/java/androidx/work/impl/constraints/NetworkState.java
index c7aa8e9..5f8b9e5 100644
--- a/work/work-runtime/src/main/java/androidx/work/impl/constraints/NetworkState.java
+++ b/work/work-runtime/src/main/java/androidx/work/impl/constraints/NetworkState.java
@@ -100,7 +100,9 @@
@NonNull
@Override
public String toString() {
- return String.format("[ Connected=%b Validated=%b Metered=%b NotRoaming=%b ]",
- mIsConnected, mIsValidated, mIsMetered, mIsNotRoaming);
+ return "Connected : " + mIsConnected
+ + " Validated : " + mIsValidated
+ + " Metered : " + mIsMetered
+ + " NotRoaming : " + mIsNotRoaming;
}
}
diff --git a/work/work-runtime/src/main/java/androidx/work/impl/constraints/WorkConstraintsTracker.java b/work/work-runtime/src/main/java/androidx/work/impl/constraints/WorkConstraintsTracker.java
index 2377a51..ec29a46 100644
--- a/work/work-runtime/src/main/java/androidx/work/impl/constraints/WorkConstraintsTracker.java
+++ b/work/work-runtime/src/main/java/androidx/work/impl/constraints/WorkConstraintsTracker.java
@@ -134,8 +134,7 @@
synchronized (mLock) {
for (ConstraintController<?> constraintController : mConstraintControllers) {
if (constraintController.isWorkSpecConstrained(workSpecId)) {
- Logger.get().debug(TAG, String.format("Work %s constrained by %s", workSpecId,
- constraintController.getClass().getSimpleName()));
+ Logger.get().debug(TAG, "Work " + workSpecId + "constrained by " + constraintController.getClass().getSimpleName());
return false;
}
}
@@ -149,7 +148,7 @@
List<String> unconstrainedWorkSpecIds = new ArrayList<>();
for (String workSpecId : workSpecIds) {
if (areAllConstraintsMet(workSpecId)) {
- Logger.get().debug(TAG, String.format("Constraints met for %s", workSpecId));
+ Logger.get().debug(TAG, "Constraints met for " + workSpecId);
unconstrainedWorkSpecIds.add(workSpecId);
}
}
diff --git a/work/work-runtime/src/main/java/androidx/work/impl/constraints/trackers/BatteryChargingTracker.java b/work/work-runtime/src/main/java/androidx/work/impl/constraints/trackers/BatteryChargingTracker.java
index 1e26fc1..da8625f 100644
--- a/work/work-runtime/src/main/java/androidx/work/impl/constraints/trackers/BatteryChargingTracker.java
+++ b/work/work-runtime/src/main/java/androidx/work/impl/constraints/trackers/BatteryChargingTracker.java
@@ -77,7 +77,7 @@
return;
}
- Logger.get().debug(TAG, String.format("Received %s", action));
+ Logger.get().debug(TAG, "Received " + action);
switch (action) {
case BatteryManager.ACTION_CHARGING:
setState(true);
diff --git a/work/work-runtime/src/main/java/androidx/work/impl/constraints/trackers/BatteryNotLowTracker.java b/work/work-runtime/src/main/java/androidx/work/impl/constraints/trackers/BatteryNotLowTracker.java
index ba5db71..6f4d4dd 100644
--- a/work/work-runtime/src/main/java/androidx/work/impl/constraints/trackers/BatteryNotLowTracker.java
+++ b/work/work-runtime/src/main/java/androidx/work/impl/constraints/trackers/BatteryNotLowTracker.java
@@ -88,7 +88,7 @@
return;
}
- Logger.get().debug(TAG, String.format("Received %s", intent.getAction()));
+ Logger.get().debug(TAG, "Received " + intent.getAction());
switch (intent.getAction()) {
case Intent.ACTION_BATTERY_OKAY:
diff --git a/work/work-runtime/src/main/java/androidx/work/impl/constraints/trackers/BroadcastReceiverConstraintTracker.java b/work/work-runtime/src/main/java/androidx/work/impl/constraints/trackers/BroadcastReceiverConstraintTracker.java
index 2ae5dfa..ecfe937 100644
--- a/work/work-runtime/src/main/java/androidx/work/impl/constraints/trackers/BroadcastReceiverConstraintTracker.java
+++ b/work/work-runtime/src/main/java/androidx/work/impl/constraints/trackers/BroadcastReceiverConstraintTracker.java
@@ -67,9 +67,7 @@
@Override
public void startTracking() {
- Logger.get().debug(
- TAG,
- String.format("%s: registering receiver", getClass().getSimpleName()));
+ Logger.get().debug(TAG, getClass().getSimpleName() + ": registering receiver");
mAppContext.registerReceiver(mBroadcastReceiver, getIntentFilter());
}
@@ -77,7 +75,7 @@
public void stopTracking() {
Logger.get().debug(
TAG,
- String.format("%s: unregistering receiver", getClass().getSimpleName()));
+ getClass().getSimpleName() + ": unregistering receiver");
mAppContext.unregisterReceiver(mBroadcastReceiver);
}
}
diff --git a/work/work-runtime/src/main/java/androidx/work/impl/constraints/trackers/ConstraintTracker.java b/work/work-runtime/src/main/java/androidx/work/impl/constraints/trackers/ConstraintTracker.java
index 6d164d2..7d64637 100644
--- a/work/work-runtime/src/main/java/androidx/work/impl/constraints/trackers/ConstraintTracker.java
+++ b/work/work-runtime/src/main/java/androidx/work/impl/constraints/trackers/ConstraintTracker.java
@@ -65,9 +65,8 @@
if (mListeners.add(listener)) {
if (mListeners.size() == 1) {
mCurrentState = getInitialState();
- Logger.get().debug(TAG, String.format("%s: initial state = %s",
- getClass().getSimpleName(),
- mCurrentState));
+ Logger.get().debug(TAG,
+ getClass().getSimpleName() + ": initial state = " + mCurrentState);
startTracking();
}
listener.onConstraintChanged(mCurrentState);
diff --git a/work/work-runtime/src/main/java/androidx/work/impl/constraints/trackers/NetworkStateTracker.java b/work/work-runtime/src/main/java/androidx/work/impl/constraints/trackers/NetworkStateTracker.java
index 19e2777..467404f 100644
--- a/work/work-runtime/src/main/java/androidx/work/impl/constraints/trackers/NetworkStateTracker.java
+++ b/work/work-runtime/src/main/java/androidx/work/impl/constraints/trackers/NetworkStateTracker.java
@@ -170,7 +170,7 @@
// The Network parameter is unreliable when a VPN app is running - use active network.
Logger.get().debug(
TAG,
- String.format("Network capabilities changed: %s", capabilities));
+ "Network capabilities changed: " + capabilities);
setState(getActiveNetworkState());
}
diff --git a/work/work-runtime/src/main/java/androidx/work/impl/constraints/trackers/StorageNotLowTracker.java b/work/work-runtime/src/main/java/androidx/work/impl/constraints/trackers/StorageNotLowTracker.java
index cf97361..f913585 100644
--- a/work/work-runtime/src/main/java/androidx/work/impl/constraints/trackers/StorageNotLowTracker.java
+++ b/work/work-runtime/src/main/java/androidx/work/impl/constraints/trackers/StorageNotLowTracker.java
@@ -83,7 +83,7 @@
return; // Should never happen since the IntentFilter was configured.
}
- Logger.get().debug(TAG, String.format("Received %s", intent.getAction()));
+ Logger.get().debug(TAG, "Received " + intent.getAction());
switch (intent.getAction()) {
case Intent.ACTION_DEVICE_STORAGE_OK:
diff --git a/work/work-runtime/src/main/java/androidx/work/impl/foreground/SystemForegroundDispatcher.java b/work/work-runtime/src/main/java/androidx/work/impl/foreground/SystemForegroundDispatcher.java
index f763f24..673f3e2 100644
--- a/work/work-runtime/src/main/java/androidx/work/impl/foreground/SystemForegroundDispatcher.java
+++ b/work/work-runtime/src/main/java/androidx/work/impl/foreground/SystemForegroundDispatcher.java
@@ -189,12 +189,9 @@
// thread, so there is a chance that handleStop() fires before onExecuted() is called
// on the main thread.
Logger.get().debug(TAG,
- String.format("Removing Notification (id: %s, workSpecId: %s ,"
- + "notificationType: %s)",
- removedInfo.getNotificationId(),
- workSpecId,
- removedInfo.getForegroundServiceType())
- );
+ "Removing Notification (id: " + removedInfo.getNotificationId() +
+ ", workSpecId: " + workSpecId +
+ ", notificationType: " + removedInfo.getForegroundServiceType());
callback.cancelNotification(removedInfo.getNotificationId());
}
}
@@ -239,7 +236,7 @@
@MainThread
private void handleStartForeground(@NonNull Intent intent) {
- Logger.get().info(TAG, String.format("Started foreground service %s", intent));
+ Logger.get().info(TAG, "Started foreground service " + intent);
final String workSpecId = intent.getStringExtra(KEY_WORKSPEC_ID);
final WorkDatabase database = mWorkManagerImpl.getWorkDatabase();
mTaskExecutor.executeOnBackgroundThread(new Runnable() {
@@ -265,9 +262,11 @@
int notificationType = intent.getIntExtra(KEY_FOREGROUND_SERVICE_TYPE, 0);
String workSpecId = intent.getStringExtra(KEY_WORKSPEC_ID);
Notification notification = intent.getParcelableExtra(KEY_NOTIFICATION);
+
Logger.get().debug(TAG,
- String.format("Notifying with (id: %s, workSpecId: %s, notificationType: %s)",
- notificationId, workSpecId, notificationType));
+ "Notifying with (id:" + notificationId
+ + ", workSpecId: " + workSpecId
+ + ", notificationType :" + notificationType + ")");
if (notification != null && mCallback != null) {
// Keep track of this ForegroundInfo
@@ -315,7 +314,7 @@
@MainThread
private void handleCancelWork(@NonNull Intent intent) {
- Logger.get().info(TAG, String.format("Stopping foreground work for %s", intent));
+ Logger.get().info(TAG, "Stopping foreground work for " + intent);
String workSpecId = intent.getStringExtra(KEY_WORKSPEC_ID);
if (workSpecId != null && !TextUtils.isEmpty(workSpecId)) {
mWorkManagerImpl.cancelWorkById(UUID.fromString(workSpecId));
@@ -332,7 +331,7 @@
if (!workSpecIds.isEmpty()) {
for (String workSpecId : workSpecIds) {
Logger.get().debug(TAG,
- String.format("Constraints unmet for WorkSpec %s", workSpecId));
+ "Constraints unmet for WorkSpec " + workSpecId);
mWorkManagerImpl.stopForegroundWork(workSpecId);
}
}
@@ -376,7 +375,7 @@
Intent intent = new Intent(context, SystemForegroundService.class);
intent.setAction(ACTION_CANCEL_WORK);
// Set data to make it unique for filterEquals()
- intent.setData(Uri.parse(String.format("workspec://%s", workSpecId)));
+ intent.setData(Uri.parse("workspec://" + workSpecId));
intent.putExtra(KEY_WORKSPEC_ID, workSpecId);
return intent;
}
diff --git a/work/work-runtime/src/main/java/androidx/work/impl/model/WorkSpec.java b/work/work-runtime/src/main/java/androidx/work/impl/model/WorkSpec.java
index 245f432..36700e1 100644
--- a/work/work-runtime/src/main/java/androidx/work/impl/model/WorkSpec.java
+++ b/work/work-runtime/src/main/java/androidx/work/impl/model/WorkSpec.java
@@ -200,9 +200,7 @@
*/
public void setPeriodic(long intervalDuration) {
if (intervalDuration < MIN_PERIODIC_INTERVAL_MILLIS) {
- Logger.get().warning(TAG, String.format(
- "Interval duration lesser than minimum allowed value; Changed to %s",
- MIN_PERIODIC_INTERVAL_MILLIS));
+ Logger.get().warning(TAG, "Interval duration lesser than minimum allowed value; Changed to " + MIN_PERIODIC_INTERVAL_MILLIS);
intervalDuration = MIN_PERIODIC_INTERVAL_MILLIS;
}
setPeriodic(intervalDuration, intervalDuration);
@@ -216,21 +214,17 @@
*/
public void setPeriodic(long intervalDuration, long flexDuration) {
if (intervalDuration < MIN_PERIODIC_INTERVAL_MILLIS) {
- Logger.get().warning(TAG, String.format(
- "Interval duration lesser than minimum allowed value; Changed to %s",
- MIN_PERIODIC_INTERVAL_MILLIS));
+ Logger.get().warning(TAG, "Interval duration lesser than minimum allowed value; Changed to " + MIN_PERIODIC_INTERVAL_MILLIS);
intervalDuration = MIN_PERIODIC_INTERVAL_MILLIS;
}
if (flexDuration < MIN_PERIODIC_FLEX_MILLIS) {
Logger.get().warning(TAG,
- String.format("Flex duration lesser than minimum allowed value; Changed to %s",
- MIN_PERIODIC_FLEX_MILLIS));
+ "Flex duration lesser than minimum allowed value; Changed to " + MIN_PERIODIC_FLEX_MILLIS);
flexDuration = MIN_PERIODIC_FLEX_MILLIS;
}
if (flexDuration > intervalDuration) {
Logger.get().warning(TAG,
- String.format("Flex duration greater than interval duration; Changed to %s",
- intervalDuration));
+ "Flex duration greater than interval duration; Changed to " + intervalDuration);
flexDuration = intervalDuration;
}
this.intervalDuration = intervalDuration;
diff --git a/work/work-runtime/src/main/java/androidx/work/impl/utils/EnqueueRunnable.java b/work/work-runtime/src/main/java/androidx/work/impl/utils/EnqueueRunnable.java
index 29580d4..d878596 100644
--- a/work/work-runtime/src/main/java/androidx/work/impl/utils/EnqueueRunnable.java
+++ b/work/work-runtime/src/main/java/androidx/work/impl/utils/EnqueueRunnable.java
@@ -84,7 +84,7 @@
try {
if (mWorkContinuation.hasCycles()) {
throw new IllegalStateException(
- String.format("WorkContinuation has cycles (%s)", mWorkContinuation));
+ "WorkContinuation has cycles (" + mWorkContinuation + ")");
}
boolean needsScheduling = addToDatabase();
if (needsScheduling) {
@@ -148,8 +148,9 @@
if (!parent.isEnqueued()) {
needsScheduling |= processContinuation(parent);
} else {
- Logger.get().warning(TAG, String.format("Already enqueued work ids (%s).",
- TextUtils.join(", ", parent.getIds())));
+ Logger.get().warning(TAG,
+ "Already enqueued work ids (" +
+ TextUtils.join(", ", parent.getIds()) + ")");
}
}
}
@@ -200,8 +201,7 @@
for (String id : prerequisiteIds) {
WorkSpec prerequisiteWorkSpec = workDatabase.workSpecDao().getWorkSpec(id);
if (prerequisiteWorkSpec == null) {
- Logger.get().error(TAG,
- String.format("Prerequisite %s doesn't exist; not enqueuing", id));
+ Logger.get().error(TAG, "Prerequisite " + id + " doesn't exist; not enqueuing");
return false;
}
diff --git a/work/work-runtime/src/main/java/androidx/work/impl/utils/ForceStopRunnable.java b/work/work-runtime/src/main/java/androidx/work/impl/utils/ForceStopRunnable.java
index fb6517f..4643fbf 100644
--- a/work/work-runtime/src/main/java/androidx/work/impl/utils/ForceStopRunnable.java
+++ b/work/work-runtime/src/main/java/androidx/work/impl/utils/ForceStopRunnable.java
@@ -141,7 +141,7 @@
} else {
long duration = mRetryCount * BACKOFF_DURATION_MS;
Logger.get()
- .debug(TAG, String.format("Retrying after %s", duration),
+ .debug(TAG, "Retrying after " + duration,
exception);
sleep(mRetryCount * BACKOFF_DURATION_MS);
}
@@ -304,7 +304,7 @@
return true;
}
boolean isDefaultProcess = ProcessUtils.isDefaultProcess(mContext, configuration);
- Logger.get().debug(TAG, String.format("Is default app process = %s", isDefaultProcess));
+ Logger.get().debug(TAG, "Is default app process = " + isDefaultProcess);
return isDefaultProcess;
}
diff --git a/work/work-runtime/src/main/java/androidx/work/impl/utils/PackageManagerHelper.java b/work/work-runtime/src/main/java/androidx/work/impl/utils/PackageManagerHelper.java
index 8a9aaad..9c1d752 100644
--- a/work/work-runtime/src/main/java/androidx/work/impl/utils/PackageManagerHelper.java
+++ b/work/work-runtime/src/main/java/androidx/work/impl/utils/PackageManagerHelper.java
@@ -52,11 +52,11 @@
: PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
PackageManager.DONT_KILL_APP);
- Logger.get().debug(TAG,
- String.format("%s %s", klazz.getName(), (enabled ? "enabled" : "disabled")));
+ Logger.get().debug(TAG, klazz.getName() + " " + (enabled ? "enabled" : "disabled"));
} catch (Exception exception) {
- Logger.get().debug(TAG, String.format("%s could not be %s", klazz.getName(),
- (enabled ? "enabled" : "disabled")), exception);
+ Logger.get().debug(TAG,
+ klazz.getName() + "could not be " + (enabled ? "enabled" : "disabled"),
+ exception);
}
}
diff --git a/work/work-runtime/src/main/java/androidx/work/impl/utils/StopWorkRunnable.java b/work/work-runtime/src/main/java/androidx/work/impl/utils/StopWorkRunnable.java
index 9907a51..3d91efb 100644
--- a/work/work-runtime/src/main/java/androidx/work/impl/utils/StopWorkRunnable.java
+++ b/work/work-runtime/src/main/java/androidx/work/impl/utils/StopWorkRunnable.java
@@ -75,10 +75,7 @@
Logger.get().debug(
TAG,
- String.format(
- "StopWorkRunnable for %s; Processor.stopWork = %s",
- mWorkSpecId,
- isStopped));
+ "StopWorkRunnable for " + mWorkSpecId + "; Processor.stopWork = " + isStopped);
workDatabase.setTransactionSuccessful();
} finally {
diff --git a/work/work-runtime/src/main/java/androidx/work/impl/utils/WakeLocks.java b/work/work-runtime/src/main/java/androidx/work/impl/utils/WakeLocks.java
index f82869d..652cef9 100644
--- a/work/work-runtime/src/main/java/androidx/work/impl/utils/WakeLocks.java
+++ b/work/work-runtime/src/main/java/androidx/work/impl/utils/WakeLocks.java
@@ -87,7 +87,7 @@
for (PowerManager.WakeLock wakeLock : wakeLocksCopy.keySet()) {
if (wakeLock != null && wakeLock.isHeld()) {
- String message = String.format("WakeLock held for %s", wakeLocksCopy.get(wakeLock));
+ String message = "WakeLock held for " + wakeLocksCopy.get(wakeLock);
Logger.get().warning(TAG, message);
}
}
diff --git a/work/work-runtime/src/main/java/androidx/work/impl/utils/WorkForegroundRunnable.java b/work/work-runtime/src/main/java/androidx/work/impl/utils/WorkForegroundRunnable.java
index dad9d9d..d8cd1a5 100644
--- a/work/work-runtime/src/main/java/androidx/work/impl/utils/WorkForegroundRunnable.java
+++ b/work/work-runtime/src/main/java/androidx/work/impl/utils/WorkForegroundRunnable.java
@@ -92,13 +92,13 @@
try {
ForegroundInfo foregroundInfo = foregroundFuture.get();
if (foregroundInfo == null) {
- String message =
- String.format("Worker was marked important (%s) but did not "
- + "provide ForegroundInfo", mWorkSpec.workerClassName);
+ String message = "Worker was marked important (" +
+ mWorkSpec.workerClassName +
+ ") but did not provide ForegroundInfo";
throw new IllegalStateException(message);
}
- Logger.get().debug(TAG, String.format("Updating notification for %s",
- mWorkSpec.workerClassName));
+ Logger.get().debug(TAG,
+ "Updating notification for " + mWorkSpec.workerClassName);
// Mark as running in the foreground
mWorker.setRunInForeground(true);
mFuture.setFuture(
diff --git a/work/work-runtime/src/main/java/androidx/work/impl/utils/WorkProgressUpdater.java b/work/work-runtime/src/main/java/androidx/work/impl/utils/WorkProgressUpdater.java
index e15d7edbd..090af58 100644
--- a/work/work-runtime/src/main/java/androidx/work/impl/utils/WorkProgressUpdater.java
+++ b/work/work-runtime/src/main/java/androidx/work/impl/utils/WorkProgressUpdater.java
@@ -73,7 +73,7 @@
@Override
public void run() {
String workSpecId = id.toString();
- Logger.get().debug(TAG, String.format("Updating progress for %s (%s)", id, data));
+ Logger.get().debug(TAG, "Updating progress for " + id + " (" + data + ")");
mWorkDatabase.beginTransaction();
try {
WorkSpecDao workSpecDao = mWorkDatabase.workSpecDao();
@@ -86,10 +86,9 @@
mWorkDatabase.workProgressDao().insert(progress);
} else {
Logger.get().warning(TAG,
- String.format(
- "Ignoring setProgressAsync(...). WorkSpec (%s) is not"
- + " in a RUNNING state.",
- workSpecId));
+ "Ignoring setProgressAsync(...). WorkSpec (" +
+ workSpecId +
+ ") is not in a RUNNING state.");
}
} else {
String message =
diff --git a/work/work-runtime/src/main/java/androidx/work/impl/utils/WorkTimer.java b/work/work-runtime/src/main/java/androidx/work/impl/utils/WorkTimer.java
index b6922cf..822c36e 100644
--- a/work/work-runtime/src/main/java/androidx/work/impl/utils/WorkTimer.java
+++ b/work/work-runtime/src/main/java/androidx/work/impl/utils/WorkTimer.java
@@ -83,7 +83,7 @@
@NonNull TimeLimitExceededListener listener) {
synchronized (mLock) {
- Logger.get().debug(TAG, String.format("Starting timer for %s", workSpecId));
+ Logger.get().debug(TAG, "Starting timer for " + workSpecId);
// clear existing timer's first
stopTimer(workSpecId);
WorkTimerRunnable runnable = new WorkTimerRunnable(this, workSpecId);
@@ -102,7 +102,7 @@
synchronized (mLock) {
WorkTimerRunnable removed = mTimerMap.remove(workSpecId);
if (removed != null) {
- Logger.get().debug(TAG, String.format("Stopping timer for %s", workSpecId));
+ Logger.get().debug(TAG, "Stopping timer for " + workSpecId);
mListeners.remove(workSpecId);
}
}
diff --git a/work/work-runtime/src/main/java/androidx/work/impl/workers/ConstraintTrackingWorker.java b/work/work-runtime/src/main/java/androidx/work/impl/workers/ConstraintTrackingWorker.java
index ddb43b7..7e28494 100644
--- a/work/work-runtime/src/main/java/androidx/work/impl/workers/ConstraintTrackingWorker.java
+++ b/work/work-runtime/src/main/java/androidx/work/impl/workers/ConstraintTrackingWorker.java
@@ -123,7 +123,7 @@
workConstraintsTracker.replace(Collections.singletonList(workSpec));
if (workConstraintsTracker.areAllConstraintsMet(getId().toString())) {
- Logger.get().debug(TAG, String.format("Constraints met for delegate %s", className));
+ Logger.get().debug(TAG, "Constraints met for delegate " + className);
// Wrapping the call to mDelegate#doWork() in a try catch, because
// changes in constraints can cause the worker to throw RuntimeExceptions, and
@@ -230,7 +230,7 @@
@Override
public void onAllConstraintsNotMet(@NonNull List<String> workSpecIds) {
// If at any point, constraints are not met mark it so we can retry the work.
- Logger.get().debug(TAG, String.format("Constraints changed for %s", workSpecIds));
+ Logger.get().debug(TAG, "Constraints changed for " + workSpecIds);
synchronized (mLock) {
mAreConstraintsUnmet = true;
}
diff --git a/work/work-testing/src/main/java/androidx/work/testing/TestForegroundUpdater.java b/work/work-testing/src/main/java/androidx/work/testing/TestForegroundUpdater.java
index b33e8f8..42b9b8c 100644
--- a/work/work-testing/src/main/java/androidx/work/testing/TestForegroundUpdater.java
+++ b/work/work-testing/src/main/java/androidx/work/testing/TestForegroundUpdater.java
@@ -46,7 +46,7 @@
@NonNull UUID id,
@NonNull ForegroundInfo foregroundInfo) {
- Logger.get().info(TAG, String.format("setForegroundAsync for %s", id));
+ Logger.get().info(TAG, "setForegroundAsync for " + id);
SettableFuture<Void> future = SettableFuture.create();
future.set(null);
return future;
diff --git a/work/work-testing/src/main/java/androidx/work/testing/TestListenableWorkerBuilder.java b/work/work-testing/src/main/java/androidx/work/testing/TestListenableWorkerBuilder.java
index 071d18e..73a49dc 100644
--- a/work/work-testing/src/main/java/androidx/work/testing/TestListenableWorkerBuilder.java
+++ b/work/work-testing/src/main/java/androidx/work/testing/TestListenableWorkerBuilder.java
@@ -358,8 +358,7 @@
if (worker == null) {
throw new IllegalStateException(
- String.format("Could not create an instance of ListenableWorker %s",
- getWorkerName()));
+ "Could not create an instance of ListenableWorker " + getWorkerName());
}
// This won't do much for the case of the from(Context, WorkRequest) as we lose the
@@ -367,8 +366,7 @@
// also carry over to Kotlin extensions.
if (!getWorkerClass().isAssignableFrom(worker.getClass())) {
throw new IllegalStateException(
- String.format("Unexpected worker type %s (expected %s)", worker.getClass(),
- getWorkerClass()));
+ "Unexpected worker type " + worker.getClass() + " (expected " + getWorkerClass() + " )");
}
return (W) worker;
}
diff --git a/work/work-testing/src/main/java/androidx/work/testing/TestProgressUpdater.java b/work/work-testing/src/main/java/androidx/work/testing/TestProgressUpdater.java
index 6c4e199..8cc61cd 100644
--- a/work/work-testing/src/main/java/androidx/work/testing/TestProgressUpdater.java
+++ b/work/work-testing/src/main/java/androidx/work/testing/TestProgressUpdater.java
@@ -44,7 +44,7 @@
@NonNull Context context,
@NonNull UUID id,
@NonNull Data data) {
- Logger.get().info(TAG, String.format("Updating progress for %s (%s)", id, data));
+ Logger.get().info(TAG, "Updating progress for " + id + " (" + data + ")");
SettableFuture<Void> future = SettableFuture.create();
future.set(null);
return future;
diff --git a/work/work-testing/src/main/java/androidx/work/testing/TestWorkerBuilder.java b/work/work-testing/src/main/java/androidx/work/testing/TestWorkerBuilder.java
index dd41d211..cdb50af 100644
--- a/work/work-testing/src/main/java/androidx/work/testing/TestWorkerBuilder.java
+++ b/work/work-testing/src/main/java/androidx/work/testing/TestWorkerBuilder.java
@@ -66,8 +66,7 @@
Class<Worker> workerClass = getWorkerClass(name);
if (workerClass == null) {
throw new IllegalArgumentException(
- String.format("Invalid worker class name or class does not extend Worker (%s)",
- name));
+ "Invalid worker class name or class does not extend Worker (" + name + ")");
}
List<String> tags = new ArrayList<>(workRequest.getTags().size());