ma1co / OpenMemories-Launcher

Android launcher for Sony camcorders & action cams
5 stars 0 forks source link

AS100 - APK install failed? #1

Open mungewell opened 6 years ago

mungewell commented 6 years ago

Attempted to install the launcher on my AS100, I think that the apk did not install but I can't be sure. Log attached, did I miss something?

When selecting the 'Live' option from the menu and pressing 'Rec' I get a flashing "prep" message and then "Auth" (which is likely due to the fake UStream credentials installed).

Prior to setting up WiFi and installing credentials I got the "NoSet" message.

launcher_log.txt ustream_fake.cfg.txt

mungewell commented 6 years ago

Used updater shell to look in 'mnt/app/' and there is a 'app-0.apk' which is identical to the launcher so I guess it did install...

>pull mnt/app/app-0.apk
Writing to ./app-0.apk...
100%
>exit
Done

simon@thevoid:~/Sony-PMCA-RE-git$ diff app-0.apk OpenMemories-Launcher-release-2.0.apk -s
Files app-0.apk and OpenMemories-Launcher-release-2.0.apk are identical
ma1co commented 6 years ago

Can you try running the install command in updatershell again? It doesn't seem to work very reliably...

mungewell commented 6 years ago

I had/have tried several installs and all show the same behavior. I even tried being systematic (with a factory reset, power off and battery remove) before the install. Is there some logging (ie /var/syslog) that I can enable (maybe via the shell) before installing to see what's happening?

I note that the 'packages' files in '/mnt/system/' seem to show that the pre-install app is still referenced after I attempted the install. Can anyone confirm that they should change?

<package name="com.sony.imaging.app.livestreaming" codePath="/system/app/ustream.apk" nativeLibraryPath="/data/lib/com.sony.imaging.app.livestreaming/lib" flags="1" ft="1466eeb5900" it="1466eeb5900" ut="1466eeb5900" version="1" userId="10004">
<sigs count="1">
<cert index="5" key="308202213082018aa003020102020450f8b33a300d06092a864886f70d01010505003054310b3009060355040613024a50310b3009060355040813024a50310b3009060355040713024a50310d300b060355040a1304536f6e79310d300b060355040b1304536f6e79310d300b06035504031304536f6e793020170d3133303131383032323831305a180f33303132303532313032323831305a3054310b3009060355040613024a50310b3009060355040813024a50310b3009060355040713024a50310d300b060355040a1304536f6e79310d300b060355040b1304536f6e79310d300b06035504031304536f6e7930819f300d06092a864886f70d010101050003818d003081890281810080289d8ca38d16e74e37109d72176ab608c928991b8d34b7b6e08ba6872f07852566b43d254b879894b6d5e4a5811aadbfb87eacd1b118e4932f50b5028b7d8936cf6e84d9df4c7f970e76f67309a11d101f38a8ee0d24672f1b82c0325405b7ade443beaf2ef6bf0d9a3d1b173d6e583b717765c4f7886e2f9fe75051a92c970203010001300d06092a864886f70d0101050500038181000e6f13ba72ea73f050a8328ea516f0b2ac15c1131cf6a762e0f14217511047c3d265457f150893f19b0cea7097c465a1363b6c0541ff724905dc605f64ebd7c26a1025fcdfa7c87b97311239c596237780d634a1b5ca25bfc099a6907aa8ed1250fef1dddd5116870eaa43042e5a884bf7fcadf46666556df6e12e9a03686c29" />
</sigs>
</package>

I'll also note that the USB install method fails, but that's probably not significant.

simon@thevoid:~/Sony-PMCA-RE-git$ sudo python3 pmca-console.py install -f OpenMemories-Launcher-release-2.0.apk
No native drivers available
Using drivers libusb-MSC, libusb-MTP
Looking for Sony devices

Querying mass storage device
Sony Camcorder is a camera in mass storage mode

Switching to app install mode
Traceback (most recent call last):
  File "pmca-console.py", line 96, in <module>
    main()
  File "pmca-console.py", line 72, in main
    installCommand(args.driver, args.apkFile, pkg, args.outFile, args.local)
  File "/home/simon/Sony-PMCA-RE-git/pmca/commands/usb.py", line 274, in installCommand
    switchToAppInstaller(device)
  File "/home/simon/Sony-PMCA-RE-git/pmca/commands/usb.py", line 37, in switchToAppInstaller
    SonyExtCmdCamera(dev).switchToAppInstaller()
  File "/home/simon/Sony-PMCA-RE-git/pmca/usb/sony.py", line 306, in switchToAppInstaller
    self._sendCommand(self.SONY_CMD_ScalarExtCmdPlugIn_NotifyScalarDlmode, readBufferSize=0)
  File "/home/simon/Sony-PMCA-RE-git/pmca/usb/sony.py", line 244, in _sendCommand
    ) + data).ljust(writeBufferSize, b'\0'), readBufferSize)
  File "/home/simon/Sony-PMCA-RE-git/pmca/usb/sony.py", line 67, in sendSonyExtCommand
    self._checkResponse(response)
  File "/home/simon/Sony-PMCA-RE-git/pmca/usb/__init__.py", line 36, in _checkResponse
    raise InvalidCommandException(msg)
pmca.usb.InvalidCommandException: Mass storage error: Sense 0x5 0x20 0x0

packages.list.txt packages.xml.txt

ma1co commented 6 years ago

@mungewell The installer should patch the version number and the certificate in packages.xml. This hasn't worked in your case. Maybe the camera restored the default packages.xml?

Can you provide a dump of the android data partition (pull /dev/nflasha17 in updatershell, then zip the file)?

mungewell commented 6 years ago

files zipped and attached. as100_install_test.zip

'packages.xml' has been reformated/processed some, but the data/cert contents looks similar.

mungewell commented 6 years ago

Cert is different, but the code path is the same. Before: <cert index="5" key="308202213... After: <cert index="6" key="308202bf3...

mungewell commented 6 years ago

And I checked with real credentials, just in case. Still appears to be running the original uStream APK. Screen goes from 'Live' -rec-> flashing 'PREP' -> 'OnAir' -rec-> 'Wait' -> 'Live'

ma1co commented 6 years ago

@mungewell I have found the issue. The bk1.bak / bk2.bak file format is slightly different on cameras like the as100 and the hx60. I'll have to fix updatershell.

ma1co commented 6 years ago

@mungewell The issue should be fixed.

mungewell commented 6 years ago

I pulled the 'Master' of Sony-RE and used the same APK. Definitely doing stuff now...

Using valid WiFi and fake uStream credentials I get the flashing 'PREP' message with a high pitch beeps (on each flash), then I get a single low pitch beep and the camera continues to flash 'PREP' - however at this point it is locked up. It does not respond to button presses (next, prev, rec) and does not do anything when connected to USB. Requires a battery out to recover.

I also noted that the '/mnt' directory is empty. Since installing the APK, it does not look like data partition is being mounted. This condition persists through a factory reset.

>pull /mnt/system/packages.xml
Error: Unknown error
>shell
sh: can't access tty; job control turned off

BusyBox v1.13.4 (2012-07-17 15:11:04 JST) built-in shell (ash)
Enter 'help' for a list of built-in commands.

/ # ls -al /mnt
/ # mount
rootfs on / type rootfs (rw)
/dev/root on / type cramfs (ro,noatime)
proc on /proc type proc (rw,relatime)
none on /sys type sysfs (rw,relatime)
tmpfs on /tmp_updater type tmpfs (rw,relatime,size=12582912)
/dev/loop0 on /tmp_updater/updater/bodyfs type cramfs (ro,noatime)
/dev/nflasha2 on /setting type vfat (rw,sync,noatime,fmask=0000,dmask=0000,allow_utime=0022,codepage=cp437,iocharset=ascii,shortname=mixed,posix_attr,avoid_dlink,errors=remount-ro)
ma1co commented 6 years ago

/mnt being empty is expected, I changed the way the install command works.

mungewell commented 6 years ago

OK. It seems that the previous APK is persistant across factory resets, how can I revert the camera back to using the pre-installed uStream APK.

I tried re-installing the original APK (ripped from f/w image) but now camera doesn't even show the 'PREP' when starting app.

mungewell commented 6 years ago

I'm beginning to think that in my excitement (and being impatient) I misinterpreted the behavior and that the APK is still not installing.

Prior to installing AKP.... Configured with invalid-wifi and invalid-ustream credentials: Flashing 'PREP' with multiple high beeps, then 'NO AP' message. I don't think it's actually running APK at this point.

Configure with valid-wifi and invalid-ustream credientials: Flashing 'PREP' with multiple high beeps, then silent flashing 'PREP', then single beep and 'Auth' message.

Configure with valid-wifi and valid-ustream credientials: Flashing 'PREP' with multiple high beeps, then silent flashing 'PREP', then 'ONAIR' message.

Post installing APK I get the same behaviour. :-( Using an older version of 'updatershell' I can pull 'packages.xml' and see that it still references the pre-installed 'ustream.apk'. Installing the 'Launcher' again results in the same.

Installing 'uStream' results in different behaviour. Instead of the 'PREP' message, the camera plays it's little 'fanfair' tune and appears to reboot. 'Packages.xml' from this state attached. Is there a way to inspect the cert/key from my on-disk APK? packages.xml.txt

mungewell commented 6 years ago

Regarding installing the 'ustream.apk', the 'reboot fault' is induced the first time that it is installed. It appears that it also wipes out the wifi/stream config, but the 'bad' apk remains until the camera is factory reset.

From Update_HDRAS100VV200.exe:

simon@thevoid:~/camera_fw/as100$ find . -name 'ustream.apk' -exec md5sum {} \;
b12228b1a07a2821b764d91dd0dddbb7  ./firmware.tar_unpacked/0700_part_image/dev/nflasha16_unpacked_unpacked/app/ustream.apk

Summary attached. summary.txt

ma1co commented 6 years ago

@mungewell Can you please do the following:

Please post the three dumps. Thanks!

mungewell commented 6 years ago

Zip file(s) attached. I did one for installing/running the Launcher and one for the U-Stream apk (ripped from firmware image).

launcher.zip ustream.zip

mungewell commented 6 years ago

As mentioned above I can't see files in '/mnt/system/', even if I use an older revision of 'pmca-console.py'.

It seems that something in the recent changes has 'stuck' (even through a factory reset), what is the recommended method to restore camera to original state?

ma1co commented 6 years ago

@mungewell Thanks for the dumps. A factory reset should be enough to revert back to the original ustream app. Just make sure to configure the wifi / social settings correctly.

I have found the issue with the installation. Firmwares built before october 2014 do an additional signature check when scanning for new apks. Since the launcher apk has a different signature from the installed ustream app, the check fails and the apk is not installed. The AS100V, QX1 and QX30 seem to be the only gen3 devices affected by this (other devices have a newer firmware update available).

mungewell commented 6 years ago

Yes FactoryReset seems to revert to a working uStream app, however I note that I can not see the '/mnt/system' directory in 'pmca-console.py'. Don't know if this is a problem (or not) for camera operation. just noting it's not the same as it was before.

I was trying to check the other files, I have some memory that the uStream config was stored in plan text and hinted what the 'unknown' setting might be...

On the APK check; does this mean that it's unlikely that the launcher will work on the AS100/QX1/QX30? Is this a (crypto) checksum that we can't reproduce/bypass? If so, then feel free to close out this issue.

And (as it can't be stated enough) thanks a lot for your RE efforts with these cameras!