vidstige / jadb

ADB Client in pure Java.
Apache License 2.0
640 stars 178 forks source link

push apk to /data/local/tmp/ instead of sdcard, otherwise packagemanager cannot install from sdcard #130

Closed root-intruder closed 4 years ago

root-intruder commented 4 years ago

otherwise the package manager on newest android gives me error:

pm install x.apk 
avc:  denied  { read } for  scontext=u:r:system_server:s0 tcontext=u:object_r:sdcardfs:s0 tclass=file permissive=0
System server has no access to read file context u:object_r:sdcardfs:s0 (from path /storage/emulated/0/tmp/x.apk, context u:r:system_server:s0)
Error: Unable to open file: x.apk
Consider using a file under /data/local/tmp/
Error: Can't open file: x.apk

Exception occurred while executing:
java.lang.IllegalArgumentException: Error: Can't open file: x.apk
        at com.android.server.pm.PackageManagerShellCommand.setParamsSize(PackageManagerShellCommand.java:461)
        at com.android.server.pm.PackageManagerShellCommand.runInstall(PackageManagerShellCommand.java:1060)
        at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:169)
        at android.os.ShellCommand.exec(ShellCommand.java:104)
        at com.android.server.pm.PackageManagerService.onShellCommand(PackageManagerService.java:21729)
        at android.os.Binder.shellCommand(Binder.java:881)
        at android.os.Binder.onTransact(Binder.java:765)
        at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:4860)
        at com.android.server.pm.PackageManagerService.onTransact(PackageManagerService.java:4014)
        at android.os.Binder.execTransactInternal(Binder.java:1021)
        at android.os.Binder.execTransact(Binder.java:994)
vidstige commented 4 years ago

Please also update the test. Click the "Details" link to find out more. Should be easy to fix up.

root-intruder commented 4 years ago

there you go!

vidstige commented 4 years ago

Thanks! No test was updated, but ok. :-)

root-intruder commented 4 years ago

well that was because your master also was failing in the CI when I committed...the previous merge brought the failing CI back up ;-) ...so I just integrated that commit

root-intruder commented 4 years ago

however, a test would be hard to generate, since the error would only occur when interacting with a real device or emulator!

vidstige commented 4 years ago

Ah, that's the best way to fix a build. :-) :see_no_evil:

But no, it would be very easy to add such a test. In fact there are already similar tests here. The idea is that you set the mock up to expect the file to be pushed at a specific location, if the file is pushed else where the test will fail.

vidstige commented 4 years ago

But a bugfix is always welcome! Again, thanks a lot. :ok_hand:

root-intruder commented 4 years ago

I could not follow your link concerning the test...did you mean this?

vidstige commented 4 years ago

Oh, wonder what happened there. I mean here: https://github.com/vidstige/jadb/blob/master/test/se/vidstige/jadb/test/unit/PackageManagerTest.java