diff options
Diffstat (limited to 'build/android')
32 files changed, 362 insertions, 278 deletions
diff --git a/build/android/apk_operations.py b/build/android/apk_operations.py index 0f8ed91c3..2532972a5 100755 --- a/build/android/apk_operations.py +++ b/build/android/apk_operations.py @@ -1318,7 +1318,16 @@ class _Command: def _FindSupportedDevices(self, devices): """Returns supported devices and reasons for each not supported one.""" app_abis = self.apk_helper.GetAbis() - logging.debug('App supports: %r', app_abis) + calling_script_name = os.path.basename(sys.argv[0]) + is_webview = 'webview' in calling_script_name + requires_32_bit = self.apk_helper.Get32BitAbiOverride() == '0xffffffff' + logging.debug('App supports (requires 32bit: %r, is webview: %r): %r', + requires_32_bit, is_webview, app_abis) + # Webview 32_64 targets can work even on 64-bit only devices since only the + # webview library in the target needs the correct bitness. + if requires_32_bit and not is_webview: + app_abis = [abi for abi in app_abis if '64' not in abi] + logging.debug('App supports (filtered): %r', app_abis) if not app_abis: # The app does not have any native libs, so all devices can support it. return devices, None @@ -1350,10 +1359,14 @@ class _Command: target_cpu = 'arm' else: target_cpu = '<something else>' + # pylint: disable=line-too-long + native_lib_link = 'https://chromium.googlesource.com/chromium/src/+/main/docs/android_native_libraries.md' not_supported_reasons[device.serial] = ( f"none of the app's ABIs ({','.join(app_abis)}) match this " f"device's ABIs ({','.join(device_abis)}), you may need to set " - f'target_cpu="{target_cpu}" in your args.gn.') + f'target_cpu="{target_cpu}" in your args.gn. If you already set ' + 'the target_cpu arg, you may need to use one of the _64 or _64_32 ' + f'targets, see {native_lib_link} for more details.') return fully_supported, not_supported_reasons def ProcessArgs(self, args): diff --git a/build/android/bytecode/java/org/chromium/bytecode/ByteCodeRewriter.java b/build/android/bytecode/java/org/chromium/bytecode/ByteCodeRewriter.java index b365cde29..56aabc525 100644 --- a/build/android/bytecode/java/org/chromium/bytecode/ByteCodeRewriter.java +++ b/build/android/bytecode/java/org/chromium/bytecode/ByteCodeRewriter.java @@ -25,9 +25,7 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; import java.util.zip.ZipOutputStream; -/** - * Base class for scripts that perform bytecode modifications on a jar file. - */ +/** Base class for scripts that perform bytecode modifications on a jar file. */ public abstract class ByteCodeRewriter { private static final String CLASS_FILE_SUFFIX = ".class"; @@ -53,9 +51,7 @@ public abstract class ByteCodeRewriter { /** Returns true if the class at the given path in the archive should be rewritten. */ protected abstract boolean shouldRewriteClass(String classPath); - /** - * Returns true if the class at the given {@link ClassReader} should be rewritten. - */ + /** Returns true if the class at the given {@link ClassReader} should be rewritten. */ protected boolean shouldRewriteClass(ClassReader classReader) { return true; } diff --git a/build/android/bytecode/java/org/chromium/bytecode/EmptyOverrideGeneratorClassAdapter.java b/build/android/bytecode/java/org/chromium/bytecode/EmptyOverrideGeneratorClassAdapter.java index 3cf3a83d4..fdd54ce65 100644 --- a/build/android/bytecode/java/org/chromium/bytecode/EmptyOverrideGeneratorClassAdapter.java +++ b/build/android/bytecode/java/org/chromium/bytecode/EmptyOverrideGeneratorClassAdapter.java @@ -31,7 +31,12 @@ class EmptyOverrideGeneratorClassAdapter extends ClassVisitor { } @Override - public void visit(int version, int access, String name, String signature, String superName, + public void visit( + int version, + int access, + String name, + String signature, + String superName, String[] interfaces) { super.visit(version, access, name, signature, superName, interfaces); @@ -52,8 +57,9 @@ class EmptyOverrideGeneratorClassAdapter extends ClassVisitor { continue; } - MethodVisitor mv = super.visitMethod( - method.access, method.methodName, method.description, null, null); + MethodVisitor mv = + super.visitMethod( + method.access, method.methodName, method.description, null, null); writeOverrideCode(mv, method.access, method.methodName, method.description); } diff --git a/build/android/bytecode/java/org/chromium/bytecode/MethodCheckerClassAdapter.java b/build/android/bytecode/java/org/chromium/bytecode/MethodCheckerClassAdapter.java index 6794a77a6..ecdb0496e 100644 --- a/build/android/bytecode/java/org/chromium/bytecode/MethodCheckerClassAdapter.java +++ b/build/android/bytecode/java/org/chromium/bytecode/MethodCheckerClassAdapter.java @@ -51,7 +51,12 @@ class MethodCheckerClassAdapter extends ClassVisitor { } @Override - public void visit(int version, int access, String name, String signature, String superName, + public void visit( + int version, + int access, + String name, + String signature, + String superName, String[] interfaces) { super.visit(version, access, name, signature, superName, interfaces); @@ -126,7 +131,9 @@ class MethodCheckerClassAdapter extends ClassVisitor { } } - static void checkParentClass(String superClassName, ArrayList<MethodDescription> methodsToCheck, + static void checkParentClass( + String superClassName, + ArrayList<MethodDescription> methodsToCheck, ClassLoader jarClassLoader) { try { ClassReader cr = new ClassReader(getClassAsStream(jarClassLoader, superClassName)); diff --git a/build/android/bytecode/java/org/chromium/bytecode/ParentMethodCheckerClassAdapter.java b/build/android/bytecode/java/org/chromium/bytecode/ParentMethodCheckerClassAdapter.java index 4656c34ab..d0ae0c1ec 100644 --- a/build/android/bytecode/java/org/chromium/bytecode/ParentMethodCheckerClassAdapter.java +++ b/build/android/bytecode/java/org/chromium/bytecode/ParentMethodCheckerClassAdapter.java @@ -36,7 +36,12 @@ class ParentMethodCheckerClassAdapter extends ClassVisitor { } @Override - public void visit(int version, int access, String name, String signature, String superName, + public void visit( + int version, + int access, + String name, + String signature, + String superName, String[] interfaces) { super.visit(version, access, name, signature, superName, interfaces); @@ -56,7 +61,8 @@ class ParentMethodCheckerClassAdapter extends ClassVisitor { } for (MethodDescription methodToCheck : mMethodsToCheck) { - if (methodToCheck.shouldCreateOverride != null || !methodToCheck.methodName.equals(name) + if (methodToCheck.shouldCreateOverride != null + || !methodToCheck.methodName.equals(name) || !methodToCheck.description.equals(descriptor)) { continue; } diff --git a/build/android/bytecode/java/org/chromium/bytecode/TraceEventAdder.java b/build/android/bytecode/java/org/chromium/bytecode/TraceEventAdder.java index 51020b5a4..81ebecc72 100644 --- a/build/android/bytecode/java/org/chromium/bytecode/TraceEventAdder.java +++ b/build/android/bytecode/java/org/chromium/bytecode/TraceEventAdder.java @@ -47,8 +47,9 @@ public class TraceEventAdder extends ByteCodeRewriter { args = ByteCodeRewriter.expandArgs(args); if (args.length < 2) { - System.err.println("Expected arguments: <':' separated list of input jar paths> " - + "<':' separated list of output jar paths>"); + System.err.println( + "Expected arguments: <':' separated list of input jar paths> " + + "<':' separated list of output jar paths>"); System.exit(1); } @@ -56,9 +57,11 @@ public class TraceEventAdder extends ByteCodeRewriter { String[] outputJars = args[1].split(":"); assert inputJars.length >= outputJars.length - : "Input list must be a superset of the output list, where the " + : "Input list must be a superset of the output list, where the " + "first N entries match, and N is the length of the output list." - + inputJars.length + " Outputs: " + outputJars.length; + + inputJars.length + + " Outputs: " + + outputJars.length; // outputJars[n] must be the same as inputJars[n] but with a suffix, validate this. for (int i = 0; i < outputJars.length; i++) { @@ -94,23 +97,35 @@ public class TraceEventAdder extends ByteCodeRewriter { @Override protected boolean shouldRewriteClass(ClassReader classReader) { - mMethodsToTrace = new ArrayList<>(Arrays.asList( - // Methods on View.java - new MethodDescription( - "dispatchTouchEvent", "(Landroid/view/MotionEvent;)Z", Opcodes.ACC_PUBLIC), - new MethodDescription("draw", "(Landroid/graphics/Canvas;)V", Opcodes.ACC_PUBLIC), - new MethodDescription("onMeasure", "(II)V", Opcodes.ACC_PROTECTED), - new MethodDescription("onLayout", "(ZIIII)V", Opcodes.ACC_PROTECTED), - // Methods on RecyclerView.java in AndroidX - new MethodDescription("scrollStep", "(II[I)V", 0), - // Methods on Animator.AnimatorListener - new MethodDescription( - "onAnimationStart", "(Landroid/animation/Animator;)V", Opcodes.ACC_PUBLIC), - new MethodDescription( - "onAnimationEnd", "(Landroid/animation/Animator;)V", Opcodes.ACC_PUBLIC), - // Methods on ValueAnimator.AnimatorUpdateListener - new MethodDescription("onAnimationUpdate", "(Landroid/animation/ValueAnimator;)V", - Opcodes.ACC_PUBLIC))); + mMethodsToTrace = + new ArrayList<>( + Arrays.asList( + // Methods on View.java + new MethodDescription( + "dispatchTouchEvent", + "(Landroid/view/MotionEvent;)Z", + Opcodes.ACC_PUBLIC), + new MethodDescription( + "draw", "(Landroid/graphics/Canvas;)V", Opcodes.ACC_PUBLIC), + new MethodDescription("onMeasure", "(II)V", Opcodes.ACC_PROTECTED), + new MethodDescription( + "onLayout", "(ZIIII)V", Opcodes.ACC_PROTECTED), + // Methods on RecyclerView.java in AndroidX + new MethodDescription("scrollStep", "(II[I)V", 0), + // Methods on Animator.AnimatorListener + new MethodDescription( + "onAnimationStart", + "(Landroid/animation/Animator;)V", + Opcodes.ACC_PUBLIC), + new MethodDescription( + "onAnimationEnd", + "(Landroid/animation/Animator;)V", + Opcodes.ACC_PUBLIC), + // Methods on ValueAnimator.AnimatorUpdateListener + new MethodDescription( + "onAnimationUpdate", + "(Landroid/animation/ValueAnimator;)V", + Opcodes.ACC_PUBLIC))); // This adapter will modify mMethodsToTrace to indicate which methods already exist in the // class and which ones need to be overridden. In case the class is not an Android view diff --git a/build/android/bytecode/java/org/chromium/bytecode/TraceEventAdderClassAdapter.java b/build/android/bytecode/java/org/chromium/bytecode/TraceEventAdderClassAdapter.java index f2d03fbcc..74e02db5d 100644 --- a/build/android/bytecode/java/org/chromium/bytecode/TraceEventAdderClassAdapter.java +++ b/build/android/bytecode/java/org/chromium/bytecode/TraceEventAdderClassAdapter.java @@ -25,15 +25,24 @@ class TraceEventAdderClassAdapter extends ClassVisitor { } @Override - public void visit(int version, int access, String name, String signature, String superName, + public void visit( + int version, + int access, + String name, + String signature, + String superName, String[] interfaces) { super.visit(version, access, name, signature, superName, interfaces); mShortClassName = name.substring(name.lastIndexOf('/') + 1); } @Override - public MethodVisitor visitMethod(final int access, final String name, String desc, - String signature, String[] exceptions) { + public MethodVisitor visitMethod( + final int access, + final String name, + String desc, + String signature, + String[] exceptions) { MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions); for (MethodDescription method : mMethodsToTrace) { diff --git a/build/android/bytecode/java/org/chromium/bytecode/TypeUtils.java b/build/android/bytecode/java/org/chromium/bytecode/TypeUtils.java index e62a912f8..188fe7544 100644 --- a/build/android/bytecode/java/org/chromium/bytecode/TypeUtils.java +++ b/build/android/bytecode/java/org/chromium/bytecode/TypeUtils.java @@ -35,6 +35,7 @@ class TypeUtils { static final String INT = "I"; static final String VOID = "V"; private static final Map<String, Type> PRIMITIVE_DESCRIPTORS; + static { PRIMITIVE_DESCRIPTORS = new HashMap<>(); PRIMITIVE_DESCRIPTORS.put(Type.BOOLEAN_TYPE.toString(), Type.BOOLEAN_TYPE); diff --git a/build/android/gtest_apk/java/src/org/chromium/build/gtest_apk/NativeTestInstrumentationTestRunner.java b/build/android/gtest_apk/java/src/org/chromium/build/gtest_apk/NativeTestInstrumentationTestRunner.java index 7f5c4a817..066259354 100644 --- a/build/android/gtest_apk/java/src/org/chromium/build/gtest_apk/NativeTestInstrumentationTestRunner.java +++ b/build/android/gtest_apk/java/src/org/chromium/build/gtest_apk/NativeTestInstrumentationTestRunner.java @@ -28,9 +28,7 @@ import java.util.ArrayList; import java.util.Queue; import java.util.concurrent.atomic.AtomicBoolean; -/** - * An Instrumentation that runs tests based on NativeTest. - */ +/** An Instrumentation that runs tests based on NativeTest. */ public class NativeTestInstrumentationTestRunner extends Instrumentation { private static final String EXTRA_NATIVE_TEST_ACTIVITY = "org.chromium.native_test.NativeTestInstrumentationTestRunner.NativeTestActivity"; @@ -64,12 +62,12 @@ public class NativeTestInstrumentationTestRunner extends Instrumentation { @Override public void onCreate(Bundle arguments) { - Context context = getContext(); mTransparentArguments = new Bundle(arguments); mNativeTestActivity = arguments.getString(EXTRA_NATIVE_TEST_ACTIVITY); if (mNativeTestActivity == null) { - Log.e(TAG, + Log.e( + TAG, "Unable to find org.chromium.native_test.NativeUnitTestActivity extra on " + "NativeTestInstrumentationTestRunner launch intent."); finish(Activity.RESULT_CANCELED, new Bundle()); @@ -90,8 +88,9 @@ public class NativeTestInstrumentationTestRunner extends Instrumentation { mStdoutFile = new File(stdoutFile); } else { try { - mStdoutFile = File.createTempFile( - ".temp_stdout_", ".txt", Environment.getExternalStorageDirectory()); + mStdoutFile = + File.createTempFile( + ".temp_stdout_", ".txt", Environment.getExternalStorageDirectory()); Log.i(TAG, "stdout file created: " + mStdoutFile.getAbsolutePath()); } catch (IOException e) { Log.e(TAG, "Unable to create temporary stdout file.", e); @@ -145,34 +144,38 @@ public class NativeTestInstrumentationTestRunner extends Instrumentation { mReceiver = new TestStatusReceiver(); mReceiver.register(getContext()); - mReceiver.registerCallback(new TestStatusReceiver.TestRunCallback() { - @Override - public void testRunStarted(int pid) { - if (pid != Process.myPid()) { - ShardMonitor m = new ShardMonitor(pid, System.nanoTime() + mShardNanoTimeout); - mMonitors.put(pid, m); - mHandler.post(m); - } - } + mReceiver.registerCallback( + new TestStatusReceiver.TestRunCallback() { + @Override + public void testRunStarted(int pid) { + if (pid != Process.myPid()) { + ShardMonitor m = + new ShardMonitor(pid, System.nanoTime() + mShardNanoTimeout); + mMonitors.put(pid, m); + mHandler.post(m); + } + } - @Override - public void testRunFinished(int pid) { - ShardMonitor m = mMonitors.get(pid); - if (m != null) { - m.stopped(); - mMonitors.remove(pid); - } - mHandler.post(new ShardEnder(pid)); - } + @Override + public void testRunFinished(int pid) { + ShardMonitor m = mMonitors.get(pid); + if (m != null) { + m.stopped(); + mMonitors.remove(pid); + } + mHandler.post(new ShardEnder(pid)); + } - @Override - public void uncaughtException(int pid, String stackTrace) { - mLogBundle.putString(Instrumentation.REPORT_KEY_STREAMRESULT, - String.format("Uncaught exception in test process (pid: %d)%n%s%n", pid, - stackTrace)); - sendStatus(0, mLogBundle); - } - }); + @Override + public void uncaughtException(int pid, String stackTrace) { + mLogBundle.putString( + Instrumentation.REPORT_KEY_STREAMRESULT, + String.format( + "Uncaught exception in test process (pid: %d)%n%s%n", + pid, stackTrace)); + sendStatus(0, mLogBundle); + } + }); mHandler.post(new ShardStarter()); } @@ -240,9 +243,7 @@ public class NativeTestInstrumentationTestRunner extends Instrumentation { return i; } - /** - * Starts the NativeTest Activity. - */ + /** Starts the NativeTest Activity. */ private class ShardStarter implements Runnable { @Override public void run() { diff --git a/build/android/gtest_apk/java/src/org/chromium/build/gtest_apk/NativeTestIntent.java b/build/android/gtest_apk/java/src/org/chromium/build/gtest_apk/NativeTestIntent.java index 202078445..88fd88cc2 100644 --- a/build/android/gtest_apk/java/src/org/chromium/build/gtest_apk/NativeTestIntent.java +++ b/build/android/gtest_apk/java/src/org/chromium/build/gtest_apk/NativeTestIntent.java @@ -4,9 +4,7 @@ package org.chromium.build.gtest_apk; -/** - * Extras for intent sent by NativeTestInstrumentationTestRunner. - */ +/** Extras for intent sent by NativeTestInstrumentationTestRunner. */ public class NativeTestIntent { public static final String EXTRA_COMMAND_LINE_FILE = "org.chromium.native_test.NativeTest.CommandLineFile"; diff --git a/build/android/gtest_apk/java/src/org/chromium/build/gtest_apk/TestStatusIntent.java b/build/android/gtest_apk/java/src/org/chromium/build/gtest_apk/TestStatusIntent.java index 98ebf443b..8acc32488 100644 --- a/build/android/gtest_apk/java/src/org/chromium/build/gtest_apk/TestStatusIntent.java +++ b/build/android/gtest_apk/java/src/org/chromium/build/gtest_apk/TestStatusIntent.java @@ -4,9 +4,7 @@ package org.chromium.build.gtest_apk; -/** - * Intent action and extras of broadcasts intercepted by TestStatusReceiver. - */ +/** Intent action and extras of broadcasts intercepted by TestStatusReceiver. */ public class TestStatusIntent { public static final String ACTION_TEST_RUN_STARTED = "org.chromium.test.reporter.TestStatusReporter.TEST_RUN_STARTED"; diff --git a/build/android/gtest_apk/java/src/org/chromium/build/gtest_apk/TestStatusReceiver.java b/build/android/gtest_apk/java/src/org/chromium/build/gtest_apk/TestStatusReceiver.java index 1fd5ca80f..5e5d3e3da 100644 --- a/build/android/gtest_apk/java/src/org/chromium/build/gtest_apk/TestStatusReceiver.java +++ b/build/android/gtest_apk/java/src/org/chromium/build/gtest_apk/TestStatusReceiver.java @@ -14,8 +14,7 @@ import java.util.ArrayList; import java.util.List; /** - Receives test status broadcasts sent from - {@link org.chromium.test.reporter.TestStatusReporter}. + * Receives test status broadcasts sent from {@link org.chromium.test.reporter.TestStatusReporter}. */ public class TestStatusReceiver extends BroadcastReceiver { private static final String TAG = "test_reporter"; @@ -24,6 +23,7 @@ public class TestStatusReceiver extends BroadcastReceiver { /** An IntentFilter that matches the intents that this class can receive. */ private static final IntentFilter INTENT_FILTER; + static { IntentFilter filter = new IntentFilter(); filter.addAction(TestStatusIntent.ACTION_TEST_RUN_STARTED); @@ -40,7 +40,9 @@ public class TestStatusReceiver extends BroadcastReceiver { /** A callback used when a test run has started or finished. */ public interface TestRunCallback { void testRunStarted(int pid); + void testRunFinished(int pid); + void uncaughtException(int pid, String stackTrace); } diff --git a/build/android/gyp/apkbuilder.py b/build/android/gyp/apkbuilder.py index fa5701b6d..19c9e4bdc 100755 --- a/build/android/gyp/apkbuilder.py +++ b/build/android/gyp/apkbuilder.py @@ -244,6 +244,12 @@ def _AddFiles(apk, details): alignment=alignment) +def _GetAbiAlignment(android_abi): + if '64' in android_abi: + return 0x4000 # 16k alignment + return 0x1000 # 4k alignment + + def _GetNativeLibrariesToAdd(native_libs, android_abi, fast_align, lib_always_compress): """Returns the list of file_detail tuples for native libraries in the apk. @@ -262,7 +268,10 @@ def _GetNativeLibrariesToAdd(native_libs, android_abi, fast_align, lib_android_abi = 'arm64-v8a-hwasan' apk_path = 'lib/%s/%s' % (lib_android_abi, basename) - alignment = 0 if compress and not fast_align else 0x1000 + if compress and not fast_align: + alignment = 0 + else: + alignment = _GetAbiAlignment(android_abi) libraries_to_add.append((apk_path, path, compress, alignment)) return libraries_to_add @@ -297,7 +306,8 @@ def main(args): # Python's zip implementation duplicates file comments in the central # directory, whereas zipalign does not, so use zipalign for official builds. requires_alignment = options.format == 'apk' - run_zipalign = requires_alignment and options.best_compression + # TODO(crbug.com/1495851): Re-enable zipalign once we are using Android V SDK. + run_zipalign = requires_alignment and options.best_compression and False fast_align = bool(requires_alignment and not run_zipalign) native_libs = sorted(options.native_libs) @@ -476,14 +486,16 @@ def main(args): # with stale builds when the only change is adding/removing # placeholders). apk_path = 'lib/%s/%s' % (options.android_abi, name) - add_to_zip(apk_path, '', alignment=0x1000) + alignment = _GetAbiAlignment(options.android_abi) + add_to_zip(apk_path, '', alignment=alignment) for name in sorted(secondary_native_lib_placeholders): # Note: Empty libs files are ignored by md5check (can cause issues # with stale builds when the only change is adding/removing # placeholders). apk_path = 'lib/%s/%s' % (options.secondary_android_abi, name) - add_to_zip(apk_path, '', alignment=0x1000) + alignment = _GetAbiAlignment(options.secondary_android_abi) + add_to_zip(apk_path, '', alignment=alignment) # 5. Resources logging.debug('Adding res/') diff --git a/build/android/gyp/create_app_bundle.py b/build/android/gyp/create_app_bundle.py index 6bef20b1e..d82150103 100755 --- a/build/android/gyp/create_app_bundle.py +++ b/build/android/gyp/create_app_bundle.py @@ -237,6 +237,7 @@ def _GenerateBundleConfigJson(uncompressed_assets, compress_dex, }, 'uncompressNativeLibraries': { 'enabled': True, + 'alignment': 'PAGE_ALIGNMENT_16K' }, 'uncompressDexFiles': { 'enabled': True, # Applies only for P+. diff --git a/build/android/gyp/dex.py b/build/android/gyp/dex.py index ae8729106..3b8df26a8 100755 --- a/build/android/gyp/dex.py +++ b/build/android/gyp/dex.py @@ -183,7 +183,15 @@ def _RunD8(dex_cmd, input_paths, output_path, warnings_as_errors, build_utils.CheckOutput(dex_cmd, stderr_filter=stderr_filter, fail_on_output=warnings_as_errors) - except Exception: + except Exception as e: + if isinstance(e, build_utils.CalledProcessError): + output = e.output # pylint: disable=no-member + if "global synthetic for 'Record desugaring'" in output: + sys.stderr.write('Java records are not supported.\n') + sys.stderr.write( + 'See https://chromium.googlesource.com/chromium/src/+/' + + 'main/styleguide/java/java.md#Records\n') + sys.exit(1) if orig_dex_cmd is not dex_cmd: sys.stderr.write('Full command: ' + shlex.join(orig_dex_cmd) + '\n') raise diff --git a/build/android/gyp/test/java/org/chromium/helloworld/HelloWorldMain.java b/build/android/gyp/test/java/org/chromium/helloworld/HelloWorldMain.java index 2c4d9a274..01a3bbfe7 100644 --- a/build/android/gyp/test/java/org/chromium/helloworld/HelloWorldMain.java +++ b/build/android/gyp/test/java/org/chromium/helloworld/HelloWorldMain.java @@ -12,4 +12,3 @@ public class HelloWorldMain { HelloWorldPrinter.print(); } } - diff --git a/build/android/gyp/test/java/org/chromium/helloworld/HelloWorldPrinter.java b/build/android/gyp/test/java/org/chromium/helloworld/HelloWorldPrinter.java index 2762b4f9e..5c0691aec 100644 --- a/build/android/gyp/test/java/org/chromium/helloworld/HelloWorldPrinter.java +++ b/build/android/gyp/test/java/org/chromium/helloworld/HelloWorldPrinter.java @@ -9,4 +9,3 @@ public class HelloWorldPrinter { System.out.println("Hello, world!"); } } - diff --git a/build/android/incremental_install/java/org/chromium/incrementalinstall/BootstrapAppComponentFactory.java b/build/android/incremental_install/java/org/chromium/incrementalinstall/BootstrapAppComponentFactory.java index c782143f4..bda84dde2 100644 --- a/build/android/incremental_install/java/org/chromium/incrementalinstall/BootstrapAppComponentFactory.java +++ b/build/android/incremental_install/java/org/chromium/incrementalinstall/BootstrapAppComponentFactory.java @@ -13,9 +13,7 @@ import android.content.ContentProvider; import android.content.Intent; import android.content.pm.ApplicationInfo; -/** - * Delegates to the real AppComponentFactory. - */ +/** Delegates to the real AppComponentFactory. */ public class BootstrapAppComponentFactory extends AppComponentFactory { static AppComponentFactory sDelegate; diff --git a/build/android/incremental_install/java/org/chromium/incrementalinstall/BootstrapApplication.java b/build/android/incremental_install/java/org/chromium/incrementalinstall/BootstrapApplication.java index d49a8274c..0c69fcc10 100644 --- a/build/android/incremental_install/java/org/chromium/incrementalinstall/BootstrapApplication.java +++ b/build/android/incremental_install/java/org/chromium/incrementalinstall/BootstrapApplication.java @@ -53,10 +53,13 @@ public final class BootstrapApplication extends Application { protected void attachBaseContext(Context context) { super.attachBaseContext(context); try { - ApplicationInfo appInfo = context.getPackageManager().getApplicationInfo( - context.getPackageName(), PackageManager.GET_META_DATA); - mActivityThread = Reflect.invokeMethod(Class.forName("android.app.ActivityThread"), - "currentActivityThread"); + ApplicationInfo appInfo = + context.getPackageManager() + .getApplicationInfo( + context.getPackageName(), PackageManager.GET_META_DATA); + mActivityThread = + Reflect.invokeMethod( + Class.forName("android.app.ActivityThread"), "currentActivityThread"); mClassLoaderPatcher = new ClassLoaderPatcher(context); mOrigInstrumentation = @@ -89,9 +92,10 @@ public final class BootstrapApplication extends Application { File instInstallLockFile = new File(instIncrementalRootDir, "install.lock"); File instFirstRunLockFile = new File(instIncrementalRootDir, "firstrun.lock"); - boolean isFirstRun = LockFile.installerLockExists(appFirstRunLockFile) - || (instPackageNameDiffers - && LockFile.installerLockExists(instFirstRunLockFile)); + boolean isFirstRun = + LockFile.installerLockExists(appFirstRunLockFile) + || (instPackageNameDiffers + && LockFile.installerLockExists(instFirstRunLockFile)); if (isFirstRun) { if (mClassLoaderPatcher.mIsPrimaryProcess) { // Wait for incremental_install.py to finish. @@ -157,8 +161,9 @@ public final class BootstrapApplication extends Application { Log.i(TAG, "Instantiating " + realApplicationName); Instrumentation anyInstrumentation = mRealInstrumentation != null ? mRealInstrumentation : mOrigInstrumentation; - mRealApplication = anyInstrumentation.newApplication( - getClassLoader(), realApplicationName, context); + mRealApplication = + anyInstrumentation.newApplication( + getClassLoader(), realApplicationName, context); // Between attachBaseContext() and onCreate(), ActivityThread tries to instantiate // all ContentProviders. The ContentProviders break without the correct Application @@ -171,9 +176,7 @@ public final class BootstrapApplication extends Application { } } - /** - * Instantiates and initializes mRealInstrumentation (the real Instrumentation class). - */ + /** Instantiates and initializes mRealInstrumentation (the real Instrumentation class). */ private Instrumentation initInstrumentation(String realInstrumentationName) throws ReflectiveOperationException { if (realInstrumentationName == null) { @@ -200,8 +203,15 @@ public final class BootstrapApplication extends Application { private void populateInstrumenationFields(Instrumentation target) throws ReflectiveOperationException { // Initialize the fields that are set by Instrumentation.init(). - String[] initFields = {"mAppContext", "mComponent", "mInstrContext", "mMessageQueue", - "mThread", "mUiAutomationConnection", "mWatcher"}; + String[] initFields = { + "mAppContext", + "mComponent", + "mInstrContext", + "mMessageQueue", + "mThread", + "mUiAutomationConnection", + "mWatcher" + }; for (String fieldName : initFields) { Reflect.setField(target, fieldName, Reflect.getField(mOrigInstrumentation, fieldName)); } @@ -236,9 +246,7 @@ public final class BootstrapApplication extends Application { } } - /** - * Nulls out ActivityThread.mBoundApplication.providers. - */ + /** Nulls out ActivityThread.mBoundApplication.providers. */ private void disableContentProviders() throws ReflectiveOperationException { Object data = Reflect.getField(mActivityThread, "mBoundApplication"); mStashedProviderList = Reflect.getField(data, "providers"); @@ -254,7 +262,10 @@ public final class BootstrapApplication extends Application { Reflect.setField(data, "providers", mStashedProviderList); if (mStashedProviderList != null && mClassLoaderPatcher.mIsPrimaryProcess) { Log.i(TAG, "Instantiating content providers"); - Reflect.invokeMethod(mActivityThread, "installContentProviders", mRealApplication, + Reflect.invokeMethod( + mActivityThread, + "installContentProviders", + mRealApplication, mStashedProviderList); } mStashedProviderList = null; diff --git a/build/android/incremental_install/java/org/chromium/incrementalinstall/BootstrapInstrumentation.java b/build/android/incremental_install/java/org/chromium/incrementalinstall/BootstrapInstrumentation.java index f1f507af8..57962e0f6 100644 --- a/build/android/incremental_install/java/org/chromium/incrementalinstall/BootstrapInstrumentation.java +++ b/build/android/incremental_install/java/org/chromium/incrementalinstall/BootstrapInstrumentation.java @@ -7,9 +7,7 @@ package org.chromium.incrementalinstall; import android.app.Instrumentation; import android.os.Bundle; -/** - * Notifies BootstrapApplication of the call to Instrumentation.onCreate(). - */ +/** Notifies BootstrapApplication of the call to Instrumentation.onCreate(). */ public final class BootstrapInstrumentation extends Instrumentation { private final BootstrapApplication mApp; diff --git a/build/android/incremental_install/java/org/chromium/incrementalinstall/ClassLoaderPatcher.java b/build/android/incremental_install/java/org/chromium/incrementalinstall/ClassLoaderPatcher.java index 13c7c5d63..864267312 100644 --- a/build/android/incremental_install/java/org/chromium/incrementalinstall/ClassLoaderPatcher.java +++ b/build/android/incremental_install/java/org/chromium/incrementalinstall/ClassLoaderPatcher.java @@ -42,12 +42,10 @@ final class ClassLoaderPatcher { Log.i(TAG, "uid=" + mProcessUid + " (isPrimary=" + mIsPrimaryProcess + ")"); } - /** - * Loads all dex files within |dexDir| into the app's ClassLoader. - */ + /** Loads all dex files within |dexDir| into the app's ClassLoader. */ @SuppressLint({ - "SetWorldReadable", - "SetWorldWritable", + "SetWorldReadable", + "SetWorldWritable", }) DexFile[] loadDexFiles(File dexDir, String packageName) throws ReflectiveOperationException, IOException { @@ -133,9 +131,7 @@ final class ClassLoaderPatcher { return ret; } - /** - * Sets up all libraries within |libDir| to be loadable by System.loadLibrary(). - */ + /** Sets up all libraries within |libDir| to be loadable by System.loadLibrary(). */ @SuppressLint("SetWorldReadable") void importNativeLibs(File libDir) throws ReflectiveOperationException, IOException { Log.i(TAG, "Importing native libraries from: " + libDir); @@ -155,9 +151,10 @@ final class ClassLoaderPatcher { private void safeCopyAllFiles(File srcDir, File dstDir) throws IOException { if (!mIsPrimaryProcess) { // TODO: Work around this issue by using APK splits to install each dex / lib. - throw new RuntimeException("Incremental install does not work on Android M+ " - + "with isolated processes. Build system should have removed this. " - + "Please file a bug."); + throw new RuntimeException( + "Incremental install does not work on Android M+ " + + "with isolated processes. Build system should have removed this. " + + "Please file a bug."); } // The library copying is not necessary on older devices, but we do it anyways to @@ -184,14 +181,16 @@ final class ClassLoaderPatcher { private void addNativeLibrarySearchPath(File nativeLibDir) throws ReflectiveOperationException { Object dexPathList = Reflect.getField(mClassLoader, "pathList"); Object currentDirs = Reflect.getField(dexPathList, "nativeLibraryDirectories"); - File[] newDirs = new File[] { nativeLibDir }; + File[] newDirs = new File[] {nativeLibDir}; // Switched from an array to an ArrayList in Lollipop. if (currentDirs instanceof List) { List<File> dirsAsList = (List<File>) currentDirs; dirsAsList.add(0, nativeLibDir); } else { File[] dirsAsArray = (File[]) currentDirs; - Reflect.setField(dexPathList, "nativeLibraryDirectories", + Reflect.setField( + dexPathList, + "nativeLibraryDirectories", Reflect.concatArrays(newDirs, newDirs, dirsAsArray)); } @@ -204,9 +203,11 @@ final class ClassLoaderPatcher { return; } Object[] additionalElements = makeNativePathElements(newDirs); - Reflect.setField(dexPathList, "nativeLibraryPathElements", - Reflect.concatArrays(nativeLibraryPathElements, additionalElements, - nativeLibraryPathElements)); + Reflect.setField( + dexPathList, + "nativeLibraryPathElements", + Reflect.concatArrays( + nativeLibraryPathElements, additionalElements, nativeLibraryPathElements)); } private static void copyChangedFiles(File srcDir, File dstDir) throws IOException { @@ -228,9 +229,13 @@ final class ClassLoaderPatcher { f.delete(); } } - String msg = String.format(Locale.US, - "copyChangedFiles: %d of %d updated. %d stale files removed.", numUpdated, - srcFiles.length, numDeleted); + String msg = + String.format( + Locale.US, + "copyChangedFiles: %d of %d updated. %d stale files removed.", + numUpdated, + srcFiles.length, + numDeleted); Log.i(TAG, msg); } @@ -293,8 +298,9 @@ final class ClassLoaderPatcher { for (int i = 0; i < files.length; ++i) { File file = files[i]; // loadDexFile requires that ret contain all previously added elements. - Object dexFile = Reflect.invokeMethod( - clazz, "loadDexFile", file, optimizedDirectory, mClassLoader, ret); + Object dexFile = + Reflect.invokeMethod( + clazz, "loadDexFile", file, optimizedDirectory, mClassLoader, ret); Object dexElement; if (Build.VERSION.SDK_INT >= 26) { dexElement = Reflect.newInstance(entryClazz, dexFile, file); diff --git a/build/android/incremental_install/java/org/chromium/incrementalinstall/LockFile.java b/build/android/incremental_install/java/org/chromium/incrementalinstall/LockFile.java index 08d4c66c3..b90236143 100644 --- a/build/android/incremental_install/java/org/chromium/incrementalinstall/LockFile.java +++ b/build/android/incremental_install/java/org/chromium/incrementalinstall/LockFile.java @@ -12,9 +12,7 @@ import java.io.IOException; import java.nio.channels.FileLock; import java.util.concurrent.Callable; -/** - * Helpers for dealing with .lock files used during install / first run. - */ +/** Helpers for dealing with .lock files used during install / first run. */ final class LockFile { private static final String TAG = "incrementalinstall"; @@ -28,9 +26,7 @@ final class LockFile { mFileLock = fileLock; } - /** - * Clears the lock file by writing to it (making it non-zero in length); - */ + /** Clears the lock file by writing to it (making it non-zero in length); */ static void clearInstallerLock(File lockFile) throws IOException { Log.i(TAG, "Clearing " + lockFile); // On Android M+, we can't delete files in /data/local/tmp, so we write to it instead. @@ -39,20 +35,20 @@ final class LockFile { os.close(); } - /** - * Waits for the given file to be non-zero in length. - */ + /** Waits for the given file to be non-zero in length. */ static void waitForInstallerLock(final File file, long timeoutMs) { - pollingWait(new Callable<Boolean>() { - @Override public Boolean call() { - return !installerLockExists(file); - } - }, file, timeoutMs); + pollingWait( + new Callable<Boolean>() { + @Override + public Boolean call() { + return !installerLockExists(file); + } + }, + file, + timeoutMs); } - /** - * Waits for the given file to be non-zero in length. - */ + /** Waits for the given file to be non-zero in length. */ private static void pollingWait(Callable<Boolean> func, File file, long timeoutMs) { long pollIntervalMs = 200; for (int i = 0; i < timeoutMs / pollIntervalMs; i++) { @@ -77,9 +73,7 @@ final class LockFile { throw new RuntimeException("Timed out waiting for lock file: " + file); } - /** - * Returns whether the given lock file is missing or is in the locked state. - */ + /** Returns whether the given lock file is missing or is in the locked state. */ static boolean installerLockExists(File file) { return !file.exists() || file.length() == 0; } @@ -104,20 +98,20 @@ final class LockFile { return null; } - /** - * Waits for the given file to not exist. - */ + /** Waits for the given file to not exist. */ static void waitForRuntimeLock(final File file, long timeoutMs) { - pollingWait(new Callable<Boolean>() { - @Override public Boolean call() { - return !file.exists(); - } - }, file, timeoutMs); + pollingWait( + new Callable<Boolean>() { + @Override + public Boolean call() { + return !file.exists(); + } + }, + file, + timeoutMs); } - /** - * Releases and deletes the lock file. - */ + /** Releases and deletes the lock file. */ void release() throws IOException { Log.i(TAG, "Deleting lock file: " + mFile); mFileLock.release(); diff --git a/build/android/incremental_install/java/org/chromium/incrementalinstall/Reflect.java b/build/android/incremental_install/java/org/chromium/incrementalinstall/Reflect.java index 6ce74eb81..31d62ab36 100644 --- a/build/android/incremental_install/java/org/chromium/incrementalinstall/Reflect.java +++ b/build/android/incremental_install/java/org/chromium/incrementalinstall/Reflect.java @@ -15,9 +15,7 @@ import java.lang.reflect.Method; import java.util.Arrays; import java.util.List; -/** - * Reflection helper methods. - */ +/** Reflection helper methods. */ final class Reflect { /** * Sets the value of an object's field (even if it's not visible). @@ -52,8 +50,10 @@ final class Reflect { * type. */ static Object[] concatArrays(Object[] arrType, Object[] left, Object[] right) { - Object[] result = (Object[]) Array.newInstance( - arrType.getClass().getComponentType(), left.length + right.length); + Object[] result = + (Object[]) + Array.newInstance( + arrType.getClass().getComponentType(), left.length + right.length); System.arraycopy(left, 0, result, 0, left.length); System.arraycopy(right, 0, result, left.length, right.length); return result; @@ -66,15 +66,13 @@ final class Reflect { static Object invokeMethod(Object instance, String name, Object... params) throws ReflectiveOperationException { boolean isStatic = instance instanceof Class; - Class<?> clazz = isStatic ? (Class<?>) instance : instance.getClass(); + Class<?> clazz = isStatic ? (Class<?>) instance : instance.getClass(); Method method = findMethod(clazz, name, params); method.setAccessible(true); return method.invoke(instance, params); } - /** - * Calls a constructor with zero or more parameters. - */ + /** Calls a constructor with zero or more parameters. */ static Object newInstance(Class<?> clazz, Object... params) throws ReflectiveOperationException { Constructor<?> constructor = findConstructor(clazz, params); @@ -93,8 +91,10 @@ final class Reflect { // Need to look in the super class. } } else { - List<Field> fields = isStatic ? HiddenApiBypass.getStaticFields(clazz) - : HiddenApiBypass.getInstanceFields(clazz); + List<Field> fields = + isStatic + ? HiddenApiBypass.getStaticFields(clazz) + : HiddenApiBypass.getInstanceFields(clazz); for (Field field : fields) { if (field.getName().equals(name)) { return field; @@ -115,8 +115,13 @@ final class Reflect { } } } - throw new NoSuchMethodException("Method " + name + " with parameters " - + Arrays.asList(params) + " not found in " + clazz); + throw new NoSuchMethodException( + "Method " + + name + + " with parameters " + + Arrays.asList(params) + + " not found in " + + clazz); } private static Constructor<?> findConstructor(Class<?> clazz, Object... params) @@ -126,8 +131,8 @@ final class Reflect { return constructor; } } - throw new NoSuchMethodException("Constructor with parameters " + Arrays.asList(params) - + " not found in " + clazz); + throw new NoSuchMethodException( + "Constructor with parameters " + Arrays.asList(params) + " not found in " + clazz); } private static boolean areParametersCompatible(Class<?>[] paramTypes, Object... params) { @@ -150,7 +155,7 @@ final class Reflect { if (left.isPrimitive()) { // TODO(agrieve): Fill in the rest as needed. return left == boolean.class && rightClazz == Boolean.class - || left == int.class && rightClazz == Integer.class; + || left == int.class && rightClazz == Integer.class; } return left.isAssignableFrom(rightClazz); } diff --git a/build/android/incremental_install/java/org/chromium/incrementalinstall/SecondInstrumentation.java b/build/android/incremental_install/java/org/chromium/incrementalinstall/SecondInstrumentation.java index ecf4870e8..49c7531d9 100644 --- a/build/android/incremental_install/java/org/chromium/incrementalinstall/SecondInstrumentation.java +++ b/build/android/incremental_install/java/org/chromium/incrementalinstall/SecondInstrumentation.java @@ -6,7 +6,5 @@ package org.chromium.incrementalinstall; import android.app.Instrumentation; -/** - * Exists to support an app having multiple instrumentations. - */ +/** Exists to support an app having multiple instrumentations. */ public final class SecondInstrumentation extends Instrumentation {} diff --git a/build/android/java/src/org/chromium/build/annotations/AlwaysInline.java b/build/android/java/src/org/chromium/build/annotations/AlwaysInline.java index 1a4d1ffe1..92b4d01f1 100644 --- a/build/android/java/src/org/chromium/build/annotations/AlwaysInline.java +++ b/build/android/java/src/org/chromium/build/annotations/AlwaysInline.java @@ -9,9 +9,7 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -/** - * Tells R8 to always inline the annotated method/constructor. - */ +/** Tells R8 to always inline the annotated method/constructor. */ @Target({ElementType.CONSTRUCTOR, ElementType.METHOD}) @Retention(RetentionPolicy.CLASS) public @interface AlwaysInline {} diff --git a/build/android/java/src/org/chromium/build/annotations/DoNotStripLogs.java b/build/android/java/src/org/chromium/build/annotations/DoNotStripLogs.java index be96d9a59..cb864cc50 100644 --- a/build/android/java/src/org/chromium/build/annotations/DoNotStripLogs.java +++ b/build/android/java/src/org/chromium/build/annotations/DoNotStripLogs.java @@ -9,9 +9,7 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -/** - * The annotated method or class will have -maximumremovedandroidloglevel 0 applied to it. - */ +/** The annotated method or class will have -maximumremovedandroidloglevel 0 applied to it. */ @Target({ElementType.CONSTRUCTOR, ElementType.METHOD, ElementType.TYPE}) @Retention(RetentionPolicy.CLASS) public @interface DoNotStripLogs {} diff --git a/build/android/java/test/DefaultLocaleLintTest.java b/build/android/java/test/DefaultLocaleLintTest.java index d1f6e285b..d9a4394f7 100644 --- a/build/android/java/test/DefaultLocaleLintTest.java +++ b/build/android/java/test/DefaultLocaleLintTest.java @@ -6,9 +6,7 @@ package test; import android.app.Application; -/** - * Class which fails 'DefaultLocale' lint check. - */ +/** Class which fails 'DefaultLocale' lint check. */ public class DefaultLocaleLintTest extends Application { public String testTriggerDefaultLocaleCheck(int any) { // String format with an integer requires a Locale since it may be formatted differently. diff --git a/build/android/java/test/NewApiLintTest.java b/build/android/java/test/NewApiLintTest.java index 35a1f6228..5d3a8a650 100644 --- a/build/android/java/test/NewApiLintTest.java +++ b/build/android/java/test/NewApiLintTest.java @@ -6,9 +6,7 @@ package test; import android.app.Application; -/** - * Class which fails 'NewAPI' lint check. - */ +/** Class which fails 'NewAPI' lint check. */ public class NewApiLintTest extends Application { public String testTriggerNewApiCheck() { // This was added in API level 30. diff --git a/build/android/pylib/base/base_test_result.py b/build/android/pylib/base/base_test_result.py index b79ef5c6b..584ca84f6 100644 --- a/build/android/pylib/base/base_test_result.py +++ b/build/android/pylib/base/base_test_result.py @@ -15,9 +15,9 @@ from lib.results import result_types # pylint: disable=import-error # This must match the source adding the suffix: bit.ly/3Zmwwyx MULTIPROCESS_SUFFIX = '__multiprocess_mode' -# This must match the source adding the suffix (TODO(zbikowski): add link) -_NULL_MUTATION_SUFFIX = '_null_' -_MUTATION_SUFFIX_PATTERN = re.compile(r'^(.*)_([a-zA-Z]+)\.\.([a-zA-Z]+)_$') +# This must match the source adding the suffix: bit.ly/3Qt0Ww4 +_NULL_MUTATION_SUFFIX = '__null_' +_MUTATION_SUFFIX_PATTERN = re.compile(r'^(.*)__([a-zA-Z]+)\.\.([a-zA-Z]+)_$') class ResultType: @@ -98,13 +98,13 @@ class BaseTestResult: # The name can include suffixes encoding Webview variant data: # a Webview multiprocess mode suffix and an AwSettings mutation suffix. # If both are present, the mutation suffix will come after the multiprocess - # suffix. The mutation suffix can either be "_null_" or "_{key}..{value}_". + # suffix. The mutation suffix can either be "__null_" or "__{key}..{value}_" # # Examples: - # (...)AwSettingsTest#testAssetUrl__multiprocess_mode_allMutations..true_ - # (...)AwSettingsTest#testAssetUrl__multiprocess_mode_null_ - # (...)AwSettingsTest#testAssetUrl_allMutations..true_ - # org.chromium.android_webview.test.AwSettingsTest#testAssetUrl_null_ + # (...)AwSettingsTest#testAssetUrl__multiprocess_mode__allMutations..true_ + # (...)AwSettingsTest#testAssetUrl__multiprocess_mode__null_ + # (...)AwSettingsTest#testAssetUrl__allMutations..true_ + # org.chromium.android_webview.test.AwSettingsTest#testAssetUrl__null_ # first, strip any AwSettings mutation parameter information # from the RHS of the raw_name diff --git a/build/android/pylib/device/commands/java/src/org/chromium/android/commands/unzip/Unzip.java b/build/android/pylib/device/commands/java/src/org/chromium/android/commands/unzip/Unzip.java index 54ba8ac72..726f8cfc4 100644 --- a/build/android/pylib/device/commands/java/src/org/chromium/android/commands/unzip/Unzip.java +++ b/build/android/pylib/device/commands/java/src/org/chromium/android/commands/unzip/Unzip.java @@ -18,9 +18,7 @@ import java.io.PrintStream; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; -/** - * Minimal implementation of the command-line unzip utility for Android. - */ +/** Minimal implementation of the command-line unzip utility for Android. */ public class Unzip { private static final String TAG = "Unzip"; @@ -94,4 +92,3 @@ public class Unzip { unzip(args); } } - diff --git a/build/android/pylib/local/emulator/avd.py b/build/android/pylib/local/emulator/avd.py index 1387d9054..6f3a5d46a 100644 --- a/build/android/pylib/local/emulator/avd.py +++ b/build/android/pylib/local/emulator/avd.py @@ -556,7 +556,7 @@ class AvdConfig: # https://bit.ly/3agmjcM). # Wait for this step to complete since it can take a while for old OSs # like M, otherwise the avd may have "Encryption Unsuccessful" error. - instance.device.WaitUntilFullyBooted(decrypt=True, timeout=180, retries=0) + instance.device.WaitUntilFullyBooted(decrypt=True, timeout=360, retries=0) if additional_apks: for apk in additional_apks: @@ -884,8 +884,11 @@ class AvdConfig: with ini.update_ini_file(config_path) as config_contents: config_contents.update(properties) - # Create qt config file to disable adb warning when launched in window mode. + # Create qt config file to disable certain warnings when launched in window. with ini.update_ini_file(self._qt_config_path) as config_contents: + # Disable nested virtualization warning. + config_contents['General'] = {'showNestedWarning': 'false'} + # Disable adb warning. config_contents['set'] = {'autoFindAdb': 'false'} def _Initialize(self): diff --git a/build/android/stacktrace/java/org/chromium/build/FlushingReTrace.java b/build/android/stacktrace/java/org/chromium/build/FlushingReTrace.java index 3e2719754..10d7b3410 100644 --- a/build/android/stacktrace/java/org/chromium/build/FlushingReTrace.java +++ b/build/android/stacktrace/java/org/chromium/build/FlushingReTrace.java @@ -36,61 +36,70 @@ public class FlushingReTrace { private static final String LINE_PARSE_REGEX = // Eagerly match logcat prefix to avoid conflicting with the patterns below. LOGCAT_PREFIX - + "(?:" - // Based on default ReTrace regex, but with whitespaces allowed in file:line parentheses - // and "at" changed to to allow : - // E.g.: 06-22 13:58:02.895 4674 4674 E THREAD_STATE: bLA.a( PG : 173 ) - // Normal stack trace lines look like: - // \tat org.chromium.chrome.browser.tab.Tab.handleJavaCrash(Tab.java:682) - + "(?:.*?(?::|\\bat)\\s+%c\\.%m\\s*\\(\\s*%s(?:\\s*:\\s*%l\\s*)?\\))|" - // Stack trace from crbug.com/1300215 looks like: - // 0xffffffff (chromium-TrichromeChromeGoogle.aab-canary-490400033: 70) ii2.p - + "(?:.*?\\(\\s*%s(?:\\s*:\\s*%l\\s*)?\\)\\s*%c\\.%m)|" - // E.g.: Caused by: java.lang.NullPointerException: Attempt to read from field 'int bLA' - // on a null object reference - + "(?:.*java\\.lang\\.NullPointerException.*[\"']%t\\s*%c\\.(?:%f|%m\\(%a\\))[\"'].*)|" - // E.g.: java.lang.VerifyError: bLA - + "(?:java\\.lang\\.VerifyError: %c)|" - // E.g.: java.lang.NoSuchFieldError: No instance field e of type L...; in class LbxK; - + "(?:java\\.lang\\.NoSuchFieldError: No instance field %f of type .*? in class L%C;)|" - // E.g.: Object of type Clazz was not destroyed... (See LifetimeAssert.java) - + "(?:.*?Object of type %c .*)|" - // E.g.: VFY: unable to resolve new-instance 3810 (LSome/Framework/Class;) in Lfoo/Bar; - + "(?:.*L%C;.*)|" - // E.g.: END SomeTestClass#someMethod - + "(?:.*?%c#%m.*?)|" - // Special-case for a common junit logcat message: - // E.g.: java.lang.NoClassDefFoundError: SomeFrameworkClass in isTestClass for Foo - + "(?:.* isTestClass for %c)|" - // E.g.: Caused by: java.lang.RuntimeException: Intentional Java Crash - + "(?:Caused by: %c:.*)|" - // Quoted values and lines that end with a class / class+method: - // E.g.: The class: Foo - // E.g.: INSTRUMENTATION_STATUS: class=Foo - // E.g.: NoClassDefFoundError: SomeFrameworkClass in isTestClass for Foo - // E.g.: Could not find class 'SomeFrameworkClass', referenced from method Foo.bar - // E.g.: Could not find method SomeFrameworkMethod, referenced from method Foo.bar - // E.g.: The member "Foo.bar" - // E.g.: The class "Foobar" - // Be careful about matching %c without %m since language tags look like class names. - + "(?:.*?%c\\.%m)|" - + "(?:.*?\"%c\\.%m\".*)|" - + "(?:.*\\b(?:[Cc]lass|[Tt]ype)\\b.*?\"%c\".*)|" - + "(?:.*\\b(?:[Cc]lass|[Tt]ype)\\b.*?%c)|" - // E.g.: java.lang.RuntimeException: Intentional Java Crash - + "(?:%c:.*)|" - // See if entire line matches a class name (e.g. for manual deobfuscation) - + "(?:%c)" - + ")"; + + "(?:" + // Based on default ReTrace regex, but with whitespaces allowed in file:line + // parentheses and "at" changed to to allow : + // E.g.: 06-22 13:58:02.895 4674 4674 E THREAD_STATE: bLA.a( PG : 173 ) + // Normal stack trace lines look like: + // \tat org.chromium.chrome.browser.tab.Tab.handleJavaCrash(Tab.java:682) + + "(?:.*?(?::|\\bat)\\s+%c\\.%m\\s*\\(\\s*%s(?:\\s*:\\s*%l\\s*)?\\))|" + // Stack trace from crbug.com/1300215 looks like: + // 0xffffffff (chromium-TrichromeChromeGoogle.aab-canary-490400033: 70) ii2.p + + "(?:.*?\\(\\s*%s(?:\\s*:\\s*%l\\s*)?\\)\\s*%c\\.%m)|" + // E.g.: Caused by: java.lang.NullPointerException: Attempt to read from field + // 'int bLA' on a null object reference + + "(?:.*java\\.lang\\.NullPointerException.*[\"']%t\\s*%c\\.(?:%f|%m\\(%a\\))[\"'].*)|" + // E.g.: java.lang.VerifyError: bLA + + "(?:java\\.lang\\.VerifyError: %c)|" + // E.g.: java.lang.NoSuchFieldError: No instance field e of type L...; in class + // LbxK; + + "(?:java\\.lang\\.NoSuchFieldError: No instance field %f of type .*? in class" + + " L%C;)|" + // E.g.: Object of type Clazz was not destroyed... (See LifetimeAssert.java) + + "(?:.*?Object of type %c .*)|" + // E.g.: VFY: unable to resolve new-instance 3810 (LSome/Framework/Class;) in + // Lfoo/Bar; + + "(?:.*L%C;.*)|" + // E.g.: END SomeTestClass#someMethod + + "(?:.*?%c#%m.*?)|" + // Special-case for a common junit logcat message: + // E.g.: java.lang.NoClassDefFoundError: SomeFrameworkClass in isTestClass for + // Foo + + "(?:.* isTestClass for %c)|" + // E.g.: Caused by: java.lang.RuntimeException: Intentional Java Crash + + "(?:Caused by: %c:.*)|" + // Quoted values and lines that end with a class / class+method: + // E.g.: The class: Foo + // E.g.: INSTRUMENTATION_STATUS: class=Foo + // E.g.: NoClassDefFoundError: SomeFrameworkClass in isTestClass for Foo + // E.g.: Could not find class 'SomeFrameworkClass', referenced from method + // Foo.bar + // E.g.: Could not find method SomeFrameworkMethod, referenced from method + // Foo.bar + // E.g.: The member "Foo.bar" + // E.g.: The class "Foobar" + // Be careful about matching %c without %m since language tags look like class + // names. + + "(?:.*?%c\\.%m)|" + + "(?:.*?\"%c\\.%m\".*)|" + + "(?:.*\\b(?:[Cc]lass|[Tt]ype)\\b.*?\"%c\".*)|" + + "(?:.*\\b(?:[Cc]lass|[Tt]ype)\\b.*?%c)|" + // E.g.: java.lang.RuntimeException: Intentional Java Crash + + "(?:%c:.*)|" + // See if entire line matches a class name (e.g. for manual deobfuscation) + + "(?:%c)" + + ")"; private static void usage() { System.err.println("Usage: echo $OBFUSCATED_CLASS | java_deobfuscate Foo.apk.mapping"); System.err.println("Usage: java_deobfuscate Foo.apk.mapping < foo.log"); - System.err.println("Note: Deobfuscation of symbols outside the context of stack " - + "traces will work only when lines match the regular expression defined " - + "in FlushingReTrace.java."); - System.err.println("Also: Deobfuscation of method names without associated line " - + "numbers does not seem to work."); + System.err.println( + "Note: Deobfuscation of symbols outside the context of stack " + + "traces will work only when lines match the regular expression defined " + + "in FlushingReTrace.java."); + System.err.println( + "Also: Deobfuscation of method names without associated line " + + "numbers does not seem to work."); System.exit(1); } @@ -116,24 +125,26 @@ public class FlushingReTrace { .setRetracedStackTraceConsumer( retraced -> retraced.forEach(System.out::println)) .setRegularExpression(LINE_PARSE_REGEX) - .setStackTrace(new StackTraceSupplier() { - final BufferedReader mReader = new BufferedReader( - new InputStreamReader(System.in, "UTF-8")); + .setStackTrace( + new StackTraceSupplier() { + final BufferedReader mReader = + new BufferedReader( + new InputStreamReader(System.in, "UTF-8")); - @Override - public List<String> get() { - try { - String line = mReader.readLine(); - if (line == null) { - return null; + @Override + public List<String> get() { + try { + String line = mReader.readLine(); + if (line == null) { + return null; + } + return Collections.singletonList(line); + } catch (IOException e) { + e.printStackTrace(); + return null; + } } - return Collections.singletonList(line); - } catch (IOException e) { - e.printStackTrace(); - return null; - } - } - }) + }) .build(); Retrace.run(retraceCommand); } catch (IOException ex) { |