Mark crashpad_handler testonly on Android and remove crashpad_handler_named_as_so

The only supported way to use Crashpad on Android is to via:
* StartHandlerWithLinker*
* StartJavaHandler*

The stand-alone handler binary is not longer used, except in crashpad's
own tests.

Bug: chromium:425948259
Change-Id: I7a7d2f40452ba53e967ceea1ba18dde62d9b3b74
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/7892465
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Andrew Grieve <agrieve@chromium.org>
diff --git a/BUILD.gn b/BUILD.gn
index db7ece7..512867c 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -53,6 +53,7 @@
     }
     if (crashpad_is_android) {
       use_raw_android_executable = true
+      deps += [ "handler:crashpad_handler" ]
 
       # crbug.com/418874703 - This is a workaround to propagate the data deps to
       # //:crashpad_tests__dist for Android build.
diff --git a/client/BUILD.gn b/client/BUILD.gn
index e57e0e0..6d5677f 100644
--- a/client/BUILD.gn
+++ b/client/BUILD.gn
@@ -226,7 +226,7 @@
     "../util",
   ]
 
-  if (!crashpad_is_ios && !crashpad_is_fuchsia) {
+  if (!crashpad_is_android && !crashpad_is_ios && !crashpad_is_fuchsia) {
     data_deps = [ "../handler:crashpad_handler" ]
   }
 
diff --git a/handler/BUILD.gn b/handler/BUILD.gn
index e72de3b..20a8cd6 100644
--- a/handler/BUILD.gn
+++ b/handler/BUILD.gn
@@ -200,22 +200,18 @@
     if (crashpad_is_linux) {
       deps += [ "../client:pthread_create" ]
     }
+
+    if (crashpad_is_android) {
+      # crashpad_handler_trampoline is used on Android, but crashpad_handler is
+      # needed by crashpad_client_linux_test.cc (which cannot use the
+      # trampoline because it runs as a normal executable, which it does
+      # because it does not have access to chromium's base::MultiProcessTest).
+      testonly = true
+    }
   }
 }
 
-# There is not any normal way to package native executables in an Android APK.
-# It is normal to package native code as a loadable module but Android's APK
-# installer will ignore files not named like a shared object, so give the
-# handler executable an acceptable name.
 if (crashpad_is_android) {
-  copy("crashpad_handler_named_as_so") {
-    deps = [ ":crashpad_handler" ]
-
-    sources = [ "$root_out_dir/crashpad_handler" ]
-
-    outputs = [ "$root_out_dir/libcrashpad_handler.so" ]
-  }
-
   crashpad_executable("crashpad_handler_trampoline") {
     output_name = "libcrashpad_handler_trampoline.so"