Commit 885aa020 authored by Andrew Grieve's avatar Andrew Grieve Committed by Commit Bot

Reland "ProGuard: Move -checkdiscard for Log.* into @RemovableInRelease annotation"

Was reverted in: 54f75614.

Reason for reland: Includes fix for downstream targets.

Change-Id: I2a5f77cdbd40934ae206dd91b2e12e7b5e6553e1
Bug: 986693, 986693
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1715004Reviewed-by: default avatarSam Maier <smaier@chromium.org>
Commit-Queue: Andrew Grieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#680307}
parent a39ceac1
...@@ -87,6 +87,7 @@ public class Log { ...@@ -87,6 +87,7 @@ public class Log {
* Note: Has no effect on whether logs are sent or not. Use a method with * Note: Has no effect on whether logs are sent or not. Use a method with
* {@link RemovableInRelease} to log something in Debug builds only. * {@link RemovableInRelease} to log something in Debug builds only.
*/ */
@RemovableInRelease
public static boolean isLoggable(String tag, int level) { public static boolean isLoggable(String tag, int level) {
return android.util.Log.isLoggable(tag, level); return android.util.Log.isLoggable(tag, level);
} }
...@@ -105,6 +106,7 @@ public class Log { ...@@ -105,6 +106,7 @@ public class Log {
* @param args Arguments referenced by the format specifiers in the format string. If the last * @param args Arguments referenced by the format specifiers in the format string. If the last
* one is a {@link Throwable}, its trace will be printed. * one is a {@link Throwable}, its trace will be printed.
*/ */
@RemovableInRelease
private static void verbose(String tag, String messageTemplate, Object... args) { private static void verbose(String tag, String messageTemplate, Object... args) {
String message = formatLogWithStack(messageTemplate, args); String message = formatLogWithStack(messageTemplate, args);
Throwable tr = getThrowableToLog(args); Throwable tr = getThrowableToLog(args);
...@@ -190,6 +192,7 @@ public class Log { ...@@ -190,6 +192,7 @@ public class Log {
* @param args Arguments referenced by the format specifiers in the format string. If the last * @param args Arguments referenced by the format specifiers in the format string. If the last
* one is a {@link Throwable}, its trace will be printed. * one is a {@link Throwable}, its trace will be printed.
*/ */
@RemovableInRelease
private static void debug(String tag, String messageTemplate, Object... args) { private static void debug(String tag, String messageTemplate, Object... args) {
String message = formatLogWithStack(messageTemplate, args); String message = formatLogWithStack(messageTemplate, args);
Throwable tr = getThrowableToLog(args); Throwable tr = getThrowableToLog(args);
...@@ -362,6 +365,7 @@ public class Log { ...@@ -362,6 +365,7 @@ public class Log {
} }
/** Returns a string form of the origin of the log call, to be used as secondary tag.*/ /** Returns a string form of the origin of the log call, to be used as secondary tag.*/
@RemovableInRelease
private static String getCallOrigin() { private static String getCallOrigin() {
StackTraceElement[] st = Thread.currentThread().getStackTrace(); StackTraceElement[] st = Thread.currentThread().getStackTrace();
......
...@@ -48,13 +48,6 @@ ...@@ -48,13 +48,6 @@
static *** v(...); static *** v(...);
static *** isLoggable(...); static *** isLoggable(...);
} }
-checkdiscard class org.chromium.base.Log {
public static void d(...);
public static void v(...);
private static void debug(...);
private static void verbose(...);
private static String getCallOrigin(...);
}
# The following chart was created on July 20, 2016, to decide on 3 optimization # The following chart was created on July 20, 2016, to decide on 3 optimization
# passes for Chrome. # passes for Chrome.
......
...@@ -42,10 +42,15 @@ ...@@ -42,10 +42,15 @@
native <methods>; native <methods>;
} }
# Remove methods annotated with this if their return value is unused. # Remove methods with this annotation. Methods generally need to be void, or
# have unused return values in order to be removed. Compiles will fail if any
# such method was not able to be safely removed.
-assumenosideeffects class ** { -assumenosideeffects class ** {
@org.chromium.base.annotations.RemovableInRelease <methods>; @org.chromium.base.annotations.RemovableInRelease <methods>;
} }
-checkdiscard class ** {
@org.chromium.base.annotations.RemovableInRelease <methods>;
}
# Never inline classes or methods with this annotation, but allow shrinking and # Never inline classes or methods with this annotation, but allow shrinking and
# obfuscation. # obfuscation.
......
...@@ -137,13 +137,6 @@ ...@@ -137,13 +137,6 @@
static *** v(...); static *** v(...);
static *** isLoggable(...); static *** isLoggable(...);
} }
-checkdiscard class org.chromium.base.Log {
public static void d(...);
public static void v(...);
private static void debug(...);
private static void verbose(...);
private static String getCallOrigin(...);
}
# The following chart was created on July 20, 2016, to decide on 3 optimization # The following chart was created on July 20, 2016, to decide on 3 optimization
# passes for Chrome. # passes for Chrome.
...@@ -215,10 +208,15 @@ ...@@ -215,10 +208,15 @@
native <methods>; native <methods>;
} }
# Remove methods annotated with this if their return value is unused. # Remove methods with this annotation. Methods generally need to be void, or
# have unused return values in order to be removed. Compiles will fail if any
# such method was not able to be safely removed.
-assumenosideeffects class ** { -assumenosideeffects class ** {
@org.chromium.base.annotations.RemovableInRelease <methods>; @org.chromium.base.annotations.RemovableInRelease <methods>;
} }
-checkdiscard class ** {
@org.chromium.base.annotations.RemovableInRelease <methods>;
}
# Never inline classes or methods with this annotation, but allow shrinking and # Never inline classes or methods with this annotation, but allow shrinking and
# obfuscation. # obfuscation.
......
...@@ -73,8 +73,7 @@ public abstract class ConnectedTask<T extends ChromeGoogleApiClient> implements ...@@ -73,8 +73,7 @@ public abstract class ConnectedTask<T extends ChromeGoogleApiClient> implements
protected abstract void doWhenConnected(T client); protected abstract void doWhenConnected(T client);
/** /**
* Returns a name of a task. Implementations should not have side effects * Returns a name of a task (for debug logging).
* as we want to have the logging related calls removed.
*/ */
@RemovableInRelease @RemovableInRelease
protected abstract String getName(); protected abstract String getName();
...@@ -93,6 +92,10 @@ public abstract class ConnectedTask<T extends ChromeGoogleApiClient> implements ...@@ -93,6 +92,10 @@ public abstract class ConnectedTask<T extends ChromeGoogleApiClient> implements
*/ */
protected void connectionFailed() {} protected void connectionFailed() {}
private void debugLog(String message) {
Log.d(TAG, "%s:%s %s", mLogPrefix, getName(), message);
}
@Override @Override
@VisibleForTesting @VisibleForTesting
// We always only pass in a string literal here. // We always only pass in a string literal here.
...@@ -100,34 +103,30 @@ public abstract class ConnectedTask<T extends ChromeGoogleApiClient> implements ...@@ -100,34 +103,30 @@ public abstract class ConnectedTask<T extends ChromeGoogleApiClient> implements
public final void run() { public final void run() {
TraceEvent.begin("GCore:" + mLogPrefix + ":run"); TraceEvent.begin("GCore:" + mLogPrefix + ":run");
try { try {
Log.d(TAG, "%s:%s started", mLogPrefix, getName()); debugLog("started");
if (mClient.connectWithTimeout(CONNECTION_TIMEOUT_MS)) { if (mClient.connectWithTimeout(CONNECTION_TIMEOUT_MS)) {
try { try {
Log.d(TAG, "%s:%s connected", mLogPrefix, getName()); debugLog("connected");
doWhenConnected(mClient); doWhenConnected(mClient);
Log.d(TAG, "%s:%s finished", mLogPrefix, getName()); debugLog("finished");
} finally { } finally {
mClient.disconnect(); mClient.disconnect();
Log.d(TAG, "%s:%s disconnected", mLogPrefix, getName()); debugLog("disconnected");
cleanUp(); cleanUp();
Log.d(TAG, "%s:%s cleaned up", mLogPrefix, getName()); debugLog("cleaned up");
} }
} else { } else {
mRetryNumber++; mRetryNumber++;
if (mRetryNumber < RETRY_NUMBER_LIMIT && mClient.isGooglePlayServicesAvailable()) { if (mRetryNumber < RETRY_NUMBER_LIMIT && mClient.isGooglePlayServicesAvailable()) {
Log.d(TAG, "%s:%s calling retry", mLogPrefix, getName()); debugLog("calling retry");
retry(this, CONNECTION_RETRY_TIME_MS); retry(this, CONNECTION_RETRY_TIME_MS);
} else { } else {
connectionFailed(); connectionFailed();
Log.d(TAG, "%s:%s number of retries exceeded", mLogPrefix, getName()); debugLog("number of retries exceeded");
cleanUp(); cleanUp();
Log.d(TAG, "%s:%s cleaned up", mLogPrefix, getName()); debugLog("cleaned up");
} }
} }
} catch (RuntimeException e) {
Log.e(TAG, "%s:%s runtime exception %s: %s", mLogPrefix, getName(),
e.getClass().getName(), e.getMessage());
throw e;
} finally { } finally {
TraceEvent.end("GCore:" + mLogPrefix + ":run"); TraceEvent.end("GCore:" + mLogPrefix + ":run");
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment