[location_rewriter] Handle all AsyncTask execution variants Since AsyncTask is a base class, the various execute methods are invoked on the child classes and thus cannot be easily identified by the location rewriter without re-ordering the build steps. Instead, an exception is made for executeOnExecutor. This CL also adds exceptions for executeOnTaskRunner and executeWithTaskTraits to correctly propagate location when an AsyncTask is executed using those methods. Bug: 448086090 Change-Id: I0ceb0f1e49392aac7396b4278e4c26836a9ff2b9 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7256878 Commit-Queue: Anand Ravi <anandrv@google.com> Commit-Queue: Andrew Grieve <agrieve@chromium.org> Auto-Submit: Anand Ravi <anandrv@google.com> Reviewed-by: Andrew Grieve <agrieve@chromium.org> Cr-Commit-Position: refs/heads/main@{#1558311}
diff --git a/build/android/location_rewriter/src/org/chromium/build/location_rewriter/LocationRewriterTargetMethods.java b/build/android/location_rewriter/src/org/chromium/build/location_rewriter/LocationRewriterTargetMethods.java index 468d7fe..cd0868e 100644 --- a/build/android/location_rewriter/src/org/chromium/build/location_rewriter/LocationRewriterTargetMethods.java +++ b/build/android/location_rewriter/src/org/chromium/build/location_rewriter/LocationRewriterTargetMethods.java
@@ -153,10 +153,15 @@ OVERLOAD_MAP.put(target, getDefaultOverload(target)); } - private static boolean isExecuteOnLocationAwareExecutor(VisitableMethod method) { - return "executeOnExecutor".equals(method.name) - && "(Lorg/chromium/base/task/LocationAwareExecutor;)Lorg/chromium/base/task/AsyncTask;" - .equals(method.descriptor); + private static boolean isExecuteAsyncTask(VisitableMethod method) { + return ("executeOnExecutor".equals(method.name) + && "(Lorg/chromium/base/task/LocationAwareExecutor;)Lorg/chromium/base/task/AsyncTask;" + .equals(method.descriptor)) + || ("executeOnTaskRunner".equals(method.name) + && "(Lorg/chromium/base/task/TaskRunner;)Lorg/chromium/base/task/AsyncTask;" + .equals(method.descriptor)) + || ("executeWithTaskTraits".equals(method.name) + && "(I)Lorg/chromium/base/task/AsyncTask;".equals(method.descriptor)); } public static VisitableMethod getOverload(VisitableMethod method) { @@ -169,7 +174,7 @@ // is moved to a later stage in the build pipeline and runs once per APK or module. For now, // there is only one method in the codebase that has this combination of method name and // descriptor so we can be confident that the method owner is a subclass of AsyncTask. - if (isExecuteOnLocationAwareExecutor(method)) { + if (isExecuteAsyncTask(method)) { return getDefaultOverload(method); }