Commit Graph

52 Commits

Author SHA1 Message Date
baldurk 3f4f9902cb Remove error that will commonly falsely fire & replace with explicit log 2018-11-16 15:59:44 +00:00
baldurk 024a737033 Use CheckAndroidServerVersion to verify apk install. Refs #1132 2018-11-14 18:32:35 +00:00
baldurk ed388f6df6 Launch 64-bit remote server on android where possible 2018-11-14 18:32:35 +00:00
baldurk 588642c4c8 Add check for android activity being valid 2018-11-13 12:49:51 +00:00
tabi.katalin 6c39b58d0b Handle failed APK installation and patching
If "adb install" command is used with "-g" flag, we may get java.lang.SecurityException on some devices because granting runtime permissions at installation time is only allowed for system apps (however we can enable it in the device's Developer options menu).
Also, pulling APK from /data/app/ may be restricted. We can workaround by copying the APK to a directory which we can access then try to pull the APK from there.
2018-11-13 11:38:44 +00:00
baldurk 09fbe3d34f Add an error if we fail to find the PID for a launched android package 2018-11-12 19:26:36 +00:00
baldurk afb67f9035 Use library location not binary location to locate relative paths
* This means that things will work successfully even if the 'executable' is
  actually e.g. python3 in a system directory and nowhere related to where the
  renderdoc library is.
2018-10-24 15:57:50 +01:00
baldurk fee02414cb Don't resize to negative size if reading length fails for any reason 2018-08-07 12:42:50 +01:00
baldurk df1a494fa7 Add friendlier error if trying to use Android < 6.0 device. Closes #1060 2018-07-31 14:37:38 +01:00
baldurk d060eb354e don't wait for adb start-server as it may never exit 2018-07-26 17:37:12 +01:00
baldurk 6e9d8cb1a8 Initialise adb on another thread
* Otherwise the first adb access will stall heavily starting the daemon.
2018-07-26 17:24:29 +01:00
baldurk 12e43443ab Shut down adb when closing qrenderdoc if it's our adb
* This has some possible problems - e.g. if one copy of qrenderdoc is closed and
  kills the server used by another copy. However it seems impossible to reliably
  manage adb and we need to ensure we don't leave the process lingering around.
* At the moment 95% of users don't use android, so it's most important that they
  have a smooth experience.
* This was the cause of problems around updating versions because adb.exe would
  hang around and then be 'in use' and not able to be overwritten.
2018-07-26 17:24:27 +01:00
baldurk 0e826a9263 Pass -n when launching android activity to process arguments. Refs #987 2018-06-05 21:08:06 +01:00
Remi Palandri 83ba2e95e7 add support for VR end-of-frame markers via glDebugMessageInsert 2018-05-31 09:44:48 +01:00
baldurk 858b02480b Pass command-line args as 'intent args' when launching apk. Refs #987 2018-05-24 21:42:29 +01:00
baldurk e40ca6f59d Support installing android APKs from local ABI-specific build folders 2018-05-11 20:39:43 +01:00
baldurk 6a0aa28ea3 Remove some android log spam while idle, promote debug print to error 2018-05-11 20:39:42 +01:00
baldurk e96f290772 If a method is found in a superclass, filter on that class not a child
* This could cause a matching event to never happen, if we filtered on
  MethodEntry on the child class, but the method we wanted was on a
  superclass.
2018-05-04 17:44:23 +01:00
baldurk 4d004fe484 Location is correctly a classID and methoID, not two objectIDs 2018-05-04 17:44:21 +01:00
baldurk ae454edb03 JDWP compile fixes for linux 2018-04-25 20:49:13 +01:00
baldurk becfe157b4 Experimental fix to allow for JDWP connections with different ID sizes 2018-04-25 19:11:06 +01:00
tabi.katalin f84eb1f180 Get default Activity on Android 6.0
"cmd package resolve-activity" is only available from Android 7.0. Pre Android 7.0 we can use "pm dump <packagename>" to get the default Activity name.
2018-04-19 18:13:16 +01:00
baldurk 97fcff0254 Try to identify versions of adb that have whacky error prints 2018-04-04 17:56:33 +01:00
baldurk 35865efef2 Always use git commit hash to identify android build
* This prevents reinstall issues if the UI is looking for a plain major/
  minor versionName and the apk was built with a commit hash.
2018-04-04 16:52:44 +01:00
Baldur Karlsson f49dfadc9a Try alternative ps for some android devices that don't support ps -A 2018-03-13 17:31:32 +00:00
Baldur Karlsson 103618c2eb Add error messages if RenderDoc app fails to install 2018-03-12 15:46:44 +00:00
Baldur Karlsson dd1d7bd2ba Handle 'slice' apks with many apks in the shell pm path. 2018-03-12 15:46:44 +00:00
michaelrgb 327da91706 Use ps -A when looking for PID of injected process. 2018-03-01 18:45:21 +00:00
baldurk 13c1cf6ad4 Return ReplayStatus when launching/injecting, use to indicate JDWP error
* If android studio or other android tools are open when a package is
  launched for debugging, they greedily jump on it and connect which
  prevents us from connecting.
2018-02-20 11:54:57 +00:00
baldurk ea929668a7 Create android package data directory in case app doesn't do it natively 2018-02-15 16:43:11 +00:00
baldurk 04fac1d6f8 Use android properties to pass capture options to the device 2018-02-14 19:22:23 +00:00
baldurk 60324e7e38 Add a small sleep into JDWP connection code to workaround JVM bugs
* It's unknown why this matters but on some android devices adding a
  small sleep prevents problems with JDWP replies not coming through.
2018-02-13 21:10:12 +00:00
baldurk 8622471277 Reset android vulkan layer property as late as possible
* We can't reliably know when we can safely remove the layer property
  at capture time because it's impossible to know if an android app will
  use vulkan or not. So instead we fall back to unsetting it whenever we
  need to - before opening a capture or when shutting down the remote
  server (in case after capturing, no frame capture was actually opened)
* This means that if the UI crashes without unsetting it, we will poison
  the state, but this seems unavoidable.
2018-02-09 14:02:31 +00:00
baldurk f2bd4b0351 Detect ls errors that appear on stdout instead of stderr 2018-02-09 10:51:45 +00:00
baldurk 0c89fac9b5 Make adb devices execute silently because otherwise it spams the log 2018-02-07 14:20:00 +00:00
baldurk bbb4fed8e1 De-prioritise our bundled android tools unless there's no other option
* This prevents our adb from fighting a system adb if it's used outside
  of renderdoc.
2018-02-02 18:40:29 +00:00
baldurk 84ea588036 Move android support files into /plugins/android/ in the build
* We also don't copy out of the android SDK anymore as that has a
  licensing impact. Instead we ship our own builds from a local AOSP
  checkout, the same way as other plugins.
2018-02-01 20:21:50 +00:00
baldurk b7e6d33f0f Fix incorrect size check (checking string length instead of line count) 2018-01-31 18:24:14 +00:00
baldurk b7aa522769 Wait for the API to be presenting before android package is "started"
* This closely resembles the behaviour before, when at least for vulkan
  the library wouldn't be loaded and open the connection until the
  instance is created and the layer is loaded.
* When injecting our libraries, the connection is made very early but it
  may be some time before the program initialises vulkan - we can't
  setprop debug.vulkan.layers back to empty until it has, so instead we
  wait for the API to be presenting.
2018-01-31 14:39:06 +00:00
baldurk 1778e4028d Don't do any injection if the library is already present
* We assume that if the user injected libVkLayer_GLES_RenderDoc.so then
  it's either a vulkan app and that's sufficient, or they linked
  against it.
* Injecting our libraries over the top of that could cause problems -
  at worst crashes, or at best we could end up with nested hooking with
  double overhead, or the loaded renderdoc library won't be the one that
  hooks and the workflow will break.
2018-01-31 14:36:56 +00:00
baldurk 969fdaa499 Add the ability to patch android binary XML manifests in-place
* This lets us add the debuggable flag we need, at the cost of needing
  to re-sign the APK. It works in many cases although sometimes it does
  fail - but this is provided just as a 'best effort' and not as a
  recommended workflow.
2018-01-29 22:37:55 +00:00
baldurk 83d921ea84 Install if we don't have all the server ABIs correctly 2018-01-29 22:22:26 +00:00
baldurk 280fe9ade2 clang compile fix - add braces around initialisation of union 2018-01-26 22:15:59 +00:00
baldurk ec7b2807d0 Build each architecture into its own APK
* This means we can have all the architectures we care about installed,
  and load the right library regardless of what the app does.
2018-01-26 21:19:16 +00:00
baldurk 077402bf11 Add failsafe so we don't wait the whole timeout if an apk closes/crashes 2018-01-26 21:19:15 +00:00
baldurk cb34a2daea Revamp android patching to only check for (& change) the debuggable flag
* We don't consider anything else, this includes permissions or the
  library being present. Since we no longer expect to patch in the
  library we also don't check its version (however we leave the tag in
  case it is useful in the future).
* If the user has root access we will never warn, assuming the injection
  will work fine even without the debuggable flag.
2018-01-26 21:19:14 +00:00
baldurk a019797f88 Move vulkan layer name and android library filename to global defines 2018-01-26 21:19:13 +00:00
baldurk 047bff7261 Add an new android hooking method using JDWP to inject & PLT hooks
* This is based on the GAPID method of injection, using the same steps
  to connect with JDWP and debug the application, breakpointing on key
  init-time steps to patch vulkan layer search paths and load libraries
  from our installed apk.
* We diverge by then using PLT hooks instead of trampolines to hook the
  EGL/GL calls - and so we also hook dlopen.
* This should work on any debuggable application - not currently checked
  but does not replace/break any of the previous injection, which can
  still work.
2018-01-26 21:19:13 +00:00
baldurk ec71b05173 Split out android patching code into separate file 2018-01-26 16:30:47 +00:00
baldurk 5527c57e68 Split out some miscellaneous utility functions
* We also wrap up and cache the fetching of friendly names by serial
  number to avoid some adb traffic.
2018-01-26 16:30:16 +00:00