Skip to content

Commit e53480b

Browse files
committed
Clean up logging.
1 parent 6323c25 commit e53480b

19 files changed

+122
-154
lines changed

firebase-appdistribution/src/main/java/com/google/firebase/appdistribution/impl/AabUpdater.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
/** Class that handles updateApp functionality for AABs in {@link FirebaseAppDistribution}. */
3636
class AabUpdater {
37-
private static final String TAG = "AabUpdater:";
37+
private static final String TAG = "AabUpdater";
3838

3939
private final FirebaseAppDistributionLifecycleNotifier lifecycleNotifier;
4040
private final HttpsUrlConnectionFactory httpsUrlConnectionFactory;
@@ -152,7 +152,7 @@ private void openRedirectUrlInPlay(String redirectUrl, Activity hostActivity) {
152152
Intent updateIntent = new Intent(Intent.ACTION_VIEW);
153153
updateIntent.setData(Uri.parse(redirectUrl));
154154
updateIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
155-
LogWrapper.getInstance().v(TAG + "Redirecting to play");
155+
LogWrapper.v(TAG, "Redirecting to play");
156156

157157
// Launch the intent before the synchronized block to avoid failing to update in the rare
158158
// scenario where the activity moves to the background while we're awaiting the lock.

firebase-appdistribution/src/main/java/com/google/firebase/appdistribution/impl/ApkInstaller.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727

2828
/** Class that handles installing APKs in {@link FirebaseAppDistribution}. */
2929
class ApkInstaller {
30-
private static final String TAG = "ApkInstaller:";
30+
private static final String TAG = "ApkInstaller";
31+
3132
private final FirebaseAppDistributionLifecycleNotifier lifeCycleNotifier;
3233

3334
@GuardedBy("installTaskLock")
@@ -79,7 +80,7 @@ private void startInstallActivity(String path, Activity currentActivity) {
7980
Intent intent = new Intent(currentActivity, InstallActivity.class);
8081
intent.putExtra("INSTALL_PATH", path);
8182
currentActivity.startActivity(intent);
82-
LogWrapper.getInstance().v(TAG + "Prompting tester with install activity ");
83+
LogWrapper.v(TAG, "Prompting tester with install activity");
8384
}
8485

8586
void trySetInstallTaskError() {

firebase-appdistribution/src/main/java/com/google/firebase/appdistribution/impl/ApkUpdater.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,8 @@
4242

4343
/** Class that handles updateApp functionality for APKs in {@link FirebaseAppDistribution}. */
4444
class ApkUpdater {
45-
45+
private static final String TAG = "ApkUpdater";
4646
private static final int UPDATE_INTERVAL_MS = 250;
47-
private static final String TAG = "ApkUpdater:";
4847
private static final String REQUEST_METHOD_GET = "GET";
4948
private static final String DEFAULT_APK_FILE_NAME = "downloaded_release.apk";
5049

@@ -185,7 +184,7 @@ private void makeApkDownloadRequest(
185184
postUpdateProgress(
186185
responseLength, 0, UpdateStatus.PENDING, showNotification, R.string.downloading_app_update);
187186
String fileName = getApkFileName();
188-
LogWrapper.getInstance().v(TAG + "Attempting to download APK to disk");
187+
LogWrapper.v(TAG, "Attempting to download APK to disk");
189188

190189
long bytesDownloaded = downloadToDisk(connection, responseLength, fileName, showNotification);
191190

@@ -271,10 +270,10 @@ private String getApkFileName() {
271270
context.getApplicationInfo().loadLabel(context.getPackageManager()).toString();
272271
return applicationName + ".apk";
273272
} catch (Exception e) {
274-
LogWrapper.getInstance()
273+
LogWrapper
275274
.w(
276-
TAG
277-
+ "Unable to retrieve app name. Using generic file name for APK: "
275+
TAG,
276+
"Unable to retrieve app name. Using generic file name for APK: "
278277
+ DEFAULT_APK_FILE_NAME);
279278
return DEFAULT_APK_FILE_NAME;
280279
}

firebase-appdistribution/src/main/java/com/google/firebase/appdistribution/impl/AppIconSource.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import androidx.core.content.ContextCompat;
2424

2525
class AppIconSource {
26-
private static final String TAG = "AppIconSource: ";
26+
private static final String TAG = "AppIconSource";
2727

2828
private static final int DEFAULT_ICON = android.R.drawable.sym_def_app_icon;
2929

@@ -50,8 +50,8 @@ int getNonAdaptiveIconOrDefault(Context context) {
5050
}
5151

5252
if (isAdaptiveIcon(icon)) {
53-
LogWrapper.getInstance()
54-
.e(TAG + "Adaptive icons cannot be used in notifications. Ignoring icon id: " + iconId);
53+
LogWrapper
54+
.e(TAG, "Adaptive icons cannot be used in notifications. Ignoring icon id: " + iconId);
5555
return DEFAULT_ICON;
5656
}
5757

firebase-appdistribution/src/main/java/com/google/firebase/appdistribution/impl/FeedbackActivity.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ private void setupScreenshot() {
112112
v -> imageView.setVisibility(checkBox.isChecked() ? VISIBLE : GONE));
113113
});
114114
} else {
115-
LogWrapper.getInstance().e(TAG, "No screenshot available");
115+
LogWrapper.e(TAG, "No screenshot available");
116116
runOnUiThread(
117117
() -> {
118118
CheckBox checkBox = findViewById(R.id.screenshotCheckBox);
@@ -135,12 +135,12 @@ private Bitmap readScreenshot() {
135135
SCREENSHOT_TARGET_WIDTH_PX,
136136
SCREENSHOT_TARGET_HEIGHT_PX);
137137
} catch (IOException | SecurityException e) {
138-
LogWrapper.getInstance()
138+
LogWrapper
139139
.e(TAG, "Could not read screenshot image from URI: " + screenshotUri, e);
140140
return null;
141141
}
142142
if (bitmap == null) {
143-
LogWrapper.getInstance().e(TAG, "Could not decode screenshot image: " + screenshotUri);
143+
LogWrapper.e(TAG, "Could not decode screenshot image: " + screenshotUri);
144144
}
145145
return bitmap;
146146
}
@@ -162,13 +162,13 @@ public void submitFeedback(View view) {
162162
screenshotCheckBox.isChecked() ? screenshotUri : null)
163163
.addOnSuccessListener(
164164
unused -> {
165-
LogWrapper.getInstance().i(TAG, "Feedback submitted");
165+
LogWrapper.i(TAG, "Feedback submitted");
166166
Toast.makeText(this, "Feedback submitted", Toast.LENGTH_LONG).show();
167167
finish();
168168
})
169169
.addOnFailureListener(
170170
e -> {
171-
LogWrapper.getInstance().e(TAG, "Failed to submit feedback", e);
171+
LogWrapper.e(TAG, "Failed to submit feedback", e);
172172
Toast.makeText(this, "Error submitting feedback", Toast.LENGTH_LONG).show();
173173
setSubmittingStateEnabled(false);
174174
});

firebase-appdistribution/src/main/java/com/google/firebase/appdistribution/impl/FirebaseAppDistributionImpl.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
* included in pre-release builds.
5555
*/
5656
class FirebaseAppDistributionImpl implements FirebaseAppDistribution {
57-
57+
private static final String TAG = "Impl";
5858
private static final int UNKNOWN_RELEASE_FILE_SIZE = -1;
5959

6060
private final FirebaseApp firebaseApp;
@@ -292,13 +292,13 @@ private UpdateTask updateApp(boolean showDownloadInNotificationManager) {
292292
return updateTask;
293293
}
294294
if (cachedNewRelease == null) {
295-
LogWrapper.getInstance().v("New release not found.");
295+
LogWrapper.v(TAG, "New release not found.");
296296
return getErrorUpdateTask(
297297
new FirebaseAppDistributionException(
298298
ErrorMessages.RELEASE_NOT_FOUND_ERROR, UPDATE_NOT_AVAILABLE));
299299
}
300300
if (cachedNewRelease.getDownloadUrl() == null) {
301-
LogWrapper.getInstance().v("Download failed to execute.");
301+
LogWrapper.v(TAG, "Download failed to execute.");
302302
return getErrorUpdateTask(
303303
new FirebaseAppDistributionException(
304304
ErrorMessages.DOWNLOAD_URL_NOT_FOUND,
@@ -321,17 +321,17 @@ public void startFeedback(@StringRes int infoTextResourceId) {
321321
@Override
322322
public void startFeedback(@NonNull CharSequence infoText) {
323323
if (!feedbackInProgress.compareAndSet(/* expect= */ false, /* update= */ true)) {
324-
LogWrapper.getInstance()
325-
.i("Ignoring startFeedback() call because feedback is already in progress");
324+
LogWrapper
325+
.i(TAG, "Ignoring startFeedback() call because feedback is already in progress");
326326
return;
327327
}
328-
LogWrapper.getInstance().i("Starting feedback");
328+
LogWrapper.i(TAG, "Starting feedback");
329329
screenshotTaker
330330
.takeScreenshot()
331331
.addOnFailureListener(
332332
taskExecutor,
333333
e -> {
334-
LogWrapper.getInstance().w("Failed to take screenshot for feedback", e);
334+
LogWrapper.w(TAG, "Failed to take screenshot for feedback", e);
335335
doStartFeedback(infoText, null);
336336
})
337337
.addOnSuccessListener(
@@ -346,8 +346,8 @@ public void startFeedback(@StringRes int infoTextResourceId, @Nullable Uri scree
346346
@Override
347347
public void startFeedback(@NonNull CharSequence infoText, @Nullable Uri screenshotUri) {
348348
if (!feedbackInProgress.compareAndSet(/* expect= */ false, /* update= */ true)) {
349-
LogWrapper.getInstance()
350-
.i("Ignoring startFeedback() call because feedback is already in progress");
349+
LogWrapper
350+
.i(TAG, "Ignoring startFeedback() call because feedback is already in progress");
351351
return;
352352
}
353353
doStartFeedback(infoText, screenshotUri);
@@ -377,8 +377,8 @@ private void doStartFeedback(CharSequence infoText, @Nullable Uri screenshotUri)
377377
taskExecutor,
378378
e -> {
379379
feedbackInProgress.set(false);
380-
LogWrapper.getInstance()
381-
.e("Failed to sign in tester. Could not collect feedback.", e);
380+
LogWrapper
381+
.e(TAG, "Failed to sign in tester. Could not collect feedback.", e);
382382
})
383383
.onSuccessTask(
384384
taskExecutor,
@@ -388,7 +388,7 @@ private void doStartFeedback(CharSequence infoText, @Nullable Uri screenshotUri)
388388
.addOnFailureListener(
389389
e -> {
390390
feedbackInProgress.set(false);
391-
LogWrapper.getInstance().e("Failed to identify release", e);
391+
LogWrapper.e(TAG, "Failed to identify release", e);
392392
Toast.makeText(
393393
firebaseApp.getApplicationContext(),
394394
R.string.feedback_unidentified_release,
@@ -403,8 +403,8 @@ private void doStartFeedback(CharSequence infoText, @Nullable Uri screenshotUri)
403403
.addOnFailureListener(
404404
e -> {
405405
feedbackInProgress.set(false);
406-
LogWrapper.getInstance()
407-
.e("Failed to launch feedback flow", e);
406+
LogWrapper
407+
.e(TAG, "Failed to launch feedback flow", e);
408408
Toast.makeText(
409409
firebaseApp.getApplicationContext(),
410410
R.string.feedback_launch_failed,
@@ -417,7 +417,7 @@ private Task<Void> launchFeedbackActivity(
417417
@Nullable String releaseName, CharSequence infoText, @Nullable Uri screenshotUri) {
418418
return lifecycleNotifier.consumeForegroundActivity(
419419
activity -> {
420-
LogWrapper.getInstance().i("Launching feedback activity");
420+
LogWrapper.i(TAG, "Launching feedback activity");
421421
Intent intent = new Intent(activity, FeedbackActivity.class);
422422
// in development-mode the releaseName might be null
423423
intent.putExtra(FeedbackActivity.RELEASE_NAME_KEY, releaseName);
@@ -480,7 +480,7 @@ void onActivityDestroyed(@NonNull Activity activity) {
480480
}
481481

482482
if (activity instanceof FeedbackActivity) {
483-
LogWrapper.getInstance().i("FeedbackActivity destroyed");
483+
LogWrapper.i(TAG, "FeedbackActivity destroyed");
484484
if (activity.isFinishing()) {
485485
feedbackInProgress.set(false);
486486

firebase-appdistribution/src/main/java/com/google/firebase/appdistribution/impl/FirebaseAppDistributionNotificationsManager.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
import com.google.firebase.appdistribution.InterruptionLevel;
3232

3333
class FirebaseAppDistributionNotificationsManager {
34-
private static final String TAG = "FirebaseAppDistributionNotificationsManager";
34+
private static final String TAG = "NotificationsManager";
3535

3636
private static final String PACKAGE_PREFIX = "com.google.firebase.appdistribution";
3737

@@ -73,7 +73,7 @@ void showAppUpdateNotification(long totalBytes, long downloadedBytes, int string
7373
// Create the NotificationChannel, but only on API 26+ because
7474
// the NotificationChannel class is new and not in the support library
7575
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
76-
LogWrapper.getInstance().i(TAG, "Creating app update notification channel group");
76+
LogWrapper.i(TAG, "Creating app update notification channel group");
7777
createChannel(
7878
Notification.APP_UPDATE,
7979
R.string.app_update_notification_channel_name,
@@ -82,8 +82,8 @@ void showAppUpdateNotification(long totalBytes, long downloadedBytes, int string
8282
}
8383

8484
if (!notificationManager.areNotificationsEnabled()) {
85-
LogWrapper.getInstance()
86-
.w("Not showing app update notifications because app notifications are disabled");
85+
LogWrapper
86+
.w(TAG, "Not showing app update notifications because app notifications are disabled");
8787
return;
8888
}
8989

@@ -109,7 +109,7 @@ private PendingIntent createAppLaunchIntent() {
109109
// Query the package manager for the best launch intent for the app
110110
Intent intent = context.getPackageManager().getLaunchIntentForPackage(context.getPackageName());
111111
if (intent == null) {
112-
LogWrapper.getInstance().w(TAG, "No activity found to launch app");
112+
LogWrapper.w(TAG, "No activity found to launch app");
113113
return null;
114114
}
115115
return getPendingIntent(intent, PendingIntent.FLAG_ONE_SHOT);
@@ -129,7 +129,7 @@ public void showFeedbackNotification(
129129
// Create the NotificationChannel, but only on API 26+ because
130130
// the NotificationChannel class is new and not in the support library
131131
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
132-
LogWrapper.getInstance().i(TAG, "Creating feedback notification channel group");
132+
LogWrapper.i(TAG, "Creating feedback notification channel group");
133133
createChannel(
134134
Notification.FEEDBACK,
135135
R.string.feedback_notification_channel_name,
@@ -138,7 +138,7 @@ public void showFeedbackNotification(
138138
}
139139

140140
if (!notificationManager.areNotificationsEnabled()) {
141-
LogWrapper.getInstance()
141+
LogWrapper
142142
.w(TAG, "Not showing notification because app notifications are disabled");
143143
return;
144144
}
@@ -159,13 +159,13 @@ public void showFeedbackNotification(
159159
.setOnlyAlertOnce(true)
160160
.setAutoCancel(false)
161161
.setContentIntent(getPendingIntent(intent, /* extraFlags= */ 0));
162-
LogWrapper.getInstance().i(TAG, "Showing feedback notification");
162+
LogWrapper.i(TAG, "Showing feedback notification");
163163
notificationManager.notify(
164164
Notification.FEEDBACK.tag, Notification.FEEDBACK.id, builder.build());
165165
}
166166

167167
public void cancelFeedbackNotification() {
168-
LogWrapper.getInstance().i(TAG, "Cancelling feedback notification");
168+
LogWrapper.i(TAG, "Cancelling feedback notification");
169169
NotificationManagerCompat.from(context)
170170
.cancel(Notification.FEEDBACK.tag, Notification.FEEDBACK.id);
171171
}

firebase-appdistribution/src/main/java/com/google/firebase/appdistribution/impl/FirebaseAppDistributionRegistrar.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
public class FirebaseAppDistributionRegistrar implements ComponentRegistrar {
4545
private static final String LIBRARY_NAME = "fire-appdistribution";
4646

47-
private static String TAG = "FirebaseAppDistributionRegistrar";
47+
private static String TAG = "Registrar";
4848

4949
@Override
5050
public @NonNull List<Component<?>> getComponents() {
@@ -119,7 +119,7 @@ private FirebaseAppDistribution buildFirebaseAppDistribution(
119119
Application firebaseApplication = (Application) context;
120120
firebaseApplication.registerActivityLifecycleCallbacks(lifecycleNotifier);
121121
} else {
122-
LogWrapper.getInstance()
122+
LogWrapper
123123
.e(
124124
TAG,
125125
String.format(

firebase-appdistribution/src/main/java/com/google/firebase/appdistribution/impl/FirebaseAppDistributionTesterApiClient.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
/** Client that makes requests to the App Distribution Tester API. */
3636
class FirebaseAppDistributionTesterApiClient {
37+
private static final String TAG = "TesterApiClient";
3738

3839
/** A potentially long-running job that requires a FID and a FIS auth token */
3940
private interface FidDependentJob<TResult> {
@@ -52,7 +53,6 @@ private interface FidDependentJob<TResult> {
5253
private static final String IAS_ARTIFACT_ID_KEY = "iasArtifactId";
5354
private static final String DOWNLOAD_URL_KEY = "downloadUrl";
5455

55-
private static final String TAG = "FirebaseAppDistributionTesterApiClient";
5656
private static final String FETCH_NEW_RELEASE_TAG = "Fetching new release";
5757
private static final String FIND_RELEASE_TAG = "Finding installed release";
5858
private static final String CREATE_FEEDBACK_TAG = "Creating feedback";
@@ -136,7 +136,7 @@ private String findRelease(String fid, String token, String binaryIdParam, Strin
136136
Task<String> createFeedback(String testerReleaseName, String feedbackText) {
137137
return runWithFidAndToken(
138138
(unused, token) -> {
139-
LogWrapper.getInstance().i("Creating feedback for release: " + testerReleaseName);
139+
LogWrapper.i(TAG, "Creating feedback for release: " + testerReleaseName);
140140
String path = String.format("v1alpha/%s/feedbackReports", testerReleaseName);
141141
String requestBody = buildCreateFeedbackBody(feedbackText).toString();
142142
JSONObject responseBody =
@@ -154,7 +154,7 @@ Task<String> createFeedback(String testerReleaseName, String feedbackText) {
154154
Task<String> attachScreenshot(String feedbackName, Uri screenshotUri) {
155155
return runWithFidAndToken(
156156
(unused, token) -> {
157-
LogWrapper.getInstance().i("Uploading screenshot for feedback: " + feedbackName);
157+
LogWrapper.i(TAG, "Uploading screenshot for feedback: " + feedbackName);
158158
String path =
159159
String.format("upload/v1alpha/%s:uploadArtifact?type=SCREENSHOT", feedbackName);
160160
testerApiHttpClient.makeUploadRequest(UPLOAD_SCREENSHOT_TAG, path, token, screenshotUri);
@@ -167,7 +167,7 @@ Task<String> attachScreenshot(String feedbackName, Uri screenshotUri) {
167167
Task<Void> commitFeedback(String feedbackName) {
168168
return runWithFidAndToken(
169169
(unused, token) -> {
170-
LogWrapper.getInstance().i("Committing feedback: " + feedbackName);
170+
LogWrapper.i(TAG, "Committing feedback: " + feedbackName);
171171
String path = "v1alpha/" + feedbackName + ":commit";
172172
testerApiHttpClient.makePostRequest(
173173
COMMIT_FEEDBACK_TAG, path, token, /* requestBody= */ "");
@@ -223,10 +223,10 @@ private AppDistributionReleaseInternal parseNewRelease(JSONObject responseJson)
223223
.setDownloadUrl(downloadUrl)
224224
.build();
225225

226-
LogWrapper.getInstance().v("Zip hash for the new release " + newRelease.getApkHash());
226+
LogWrapper.v(TAG, "Zip hash for the new release " + newRelease.getApkHash());
227227
return newRelease;
228228
} catch (JSONException e) {
229-
LogWrapper.getInstance().e(TAG, "Error parsing the new release.", e);
229+
LogWrapper.e(TAG, "Error parsing the new release.", e);
230230
throw new FirebaseAppDistributionException(
231231
ErrorMessages.JSON_PARSING_ERROR, Status.UNKNOWN, e);
232232
}
@@ -237,7 +237,7 @@ private String parseJsonFieldFromResponse(JSONObject responseJson, String fieldN
237237
try {
238238
return responseJson.getString(fieldName);
239239
} catch (JSONException e) {
240-
LogWrapper.getInstance()
240+
LogWrapper
241241
.e(TAG, String.format("Field '%s' missing from response", fieldName), e);
242242
throw new FirebaseAppDistributionException(
243243
ErrorMessages.JSON_PARSING_ERROR, Status.UNKNOWN, e);

0 commit comments

Comments
 (0)