ma1co / OpenMemories-Framework

Build Android apps for your favorite Sony camera
MIT License
236 stars 35 forks source link

Make an app that starts when the camera is powered on #15

Open fsjunior opened 7 years ago

fsjunior commented 7 years ago

Hi There,

I'm trying to create an app that starts when the camera is powered on. I want to have full access in camera remotely via wireless, so I use Smart Remote Camera from Sony to take pictures, configure ISO, FNumber, exposure etc. SRC can be "configured" to start together with the camera (just power off the camera when SRC is running; the next time the camera is powered, the SRC will also start).

But, unfortunately, as I have an A5100, the SRC doesn't support file transfer and management. So I started to search an FTP Server for android. I find some FTP Servers that partially worked, but, unfortunately, they have the same problem: all of them doesn't boot with the camera.

I tried to create a proof-of-concept app in order to test if its possible to make an app start with the camera but I also have no success.

I'm not expert in Android development, so maybe I made some silly mistake:

I cloned PMCADemo app and tried to modify the AndroidManifest.xml. My intent was that BootCompletedReceiver receive some action on camera boot, so I will log that action it in the PMCADEMO/LOG.TXT.

Thus, I added the <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> permission and changed the intent-filter of the BootCompleteReceiver class to:

`

            <action android:name="android.intent.action.QUICKBOOT_POWERON" />
            <category android:name="android.intent.category.DEFAULT" />`

My guess is that some of that actions that I filtered will be executed in the camera boot, but I have no success. Only the com.android.server.DAConnectionManagerService.BootCompleted action apparently has some behaviour, but this action is only executed when the app is manually started.

Someone here already tried to create some app that boot with the camera? Anyone have any clue of what can I try?

Regards,

ma1co commented 7 years ago

android.intent.action.BOOT_COMPLETED is never broadcasted by the camera, because when you turn it on, it only restores a warm boot image to memory, which contains an already initialized android. So this approach doesn't work.

However, you can have your app be restored the same way SmartRemote does it (it will restore if you turned off your camera while it was running): In the onResume() method of your activity, send a broadcast similar to how it's done here: BetterManual. I hope this helps.

fsjunior commented 7 years ago

Hi ma1co,

Thank you for your help! A little after that I wrote this post, I actually found that apparently DAConnectionManagerService.BootCompleted is broadcasted when any android app starts. So I configurated the SRC to start with the camera and consumed the DAConnectionManagerService.BootCompleted in my FTP server when it is broadcasted. Now I can control my camera and access the files via FTP!

Regards,

fsjunior commented 6 years ago

Hi ma1co,

Sorry to reopen the issue. I found that SmartRemote is not suitable to my needs, so I need to develop a "customized" SmartRemote. Thus, I need that my own software starts with the camera.

I'm trying to implement what you suggest to do, similar to BetterManual, but I can't make it work. I'm trying to apply the changes that you suggested in a local fork of PMCADemo to validate the method. I changed the notifyAppInfo of PMCADemo BaseActivity class to behave similarly as notifyAppInfo of BetterManual (I've made a copy of the code of the notifyAppInfo method as well all the necessary constants). But when I turn off and turn on again the camera, the PMCADemo does not start automatically.

To be honest, very strangely, a few time the software starts with the camera. But most of the time (99% of the time) the software does not get restored.

I tried to analyze the code of BetterManual to see if I need another modification to make it starts automatically, but I found nothing.

There is something that I'm missing? Do I need to modify other parts of the code beside of notifyAppInfo?

Regards,

fsjunior commented 6 years ago

Hi ma1co.

Sorry for bothering you again with this. I'm still trying but I having no success to find what is the problem with my app.

Do you have any hint?