KeyMapper icon indicating copy to clipboard operation
KeyMapper copied to clipboard

Allowing camera "Pro" mode to be launched by KeyMapper

Open Gitoffthelawn opened this issue 5 years ago • 100 comments

Thank you for creating this great app!

It's oh so close to being exactly what I want, and I think it probably can be enhanced to do what I want.

I want to be able to open the "Pro" mode of Samsung's native camera app using your app. Samsung's native camera app comes with it's own launcher icon (like all apps) and within their Camera app, there is an option to create another launcher icon for the "Pro" mode.

Although the icon for that "Pro" mode appears in any launcher (including third-party launchers), it is not available in KeyMapper.

Can we work together to make it available?

Gitoffthelawn avatar Mar 04 '20 21:03 Gitoffthelawn

Yeah!

We need to figure out what is the Intent it is sending. Have you ever used ADB (Android Debug Bridge)? If not, I'll guide you through setting it up (if you need it) and entering commands to figure it out.

this is for future reference command to type in: adb shell; dumpsys activity broadcasts |grep -iE ".+.[0-9A-Z_-]+:$" |sort

sds100 avatar Mar 19 '20 15:03 sds100

Several years ago, I used ADB quite a bit. I haven't needed to use it since then, so I'm a bit rusty, but I imagine it's like riding a bicycle.

I have v22 and v26 ready to go, as that's what I was using at the time. Will those versions work with Nougat 7.0? I don't want to mess up my day-to-day phone, especially with COVID-19 being a big issue.

If I need a newer version of ADB, just let me know.

Also, what steps would you like me to take while dumpsys is running?

Outside of ADB, another possibility is that I have Nova Launcher Pro installed, and it can generate backup files. If creating a Nova backup and looking in that file might give you the answers you need, that would be real fast and easy for me.

Gitoffthelawn avatar Mar 19 '20 19:03 Gitoffthelawn

Yeah, can you post the nova launcher backup file on here so I can take a look?

sds100 avatar Mar 20 '20 08:03 sds100

I can do better than that! :)

I happen to be skilled at data and file analysis. Looking in the backup file with a hex editor, I determined it is a renamed compressed ZIP file (using the Deflate algorithm) with XML and SQL files inside.

Here is all the relevant data from those files:

intent #Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x14200000;component=com.sec.android.app.camera/.Camera;S.activity_name=com.sec.android.app.camera.shootingmode.pro;l.profile=-1;end

iconPackage com.sec.android.app.camera

iconResource com.sec.android.app.camera:drawable/home_ic_pro_pressed

Gitoffthelawn avatar Mar 20 '20 09:03 Gitoffthelawn

oh wow, thank you! ill have a go making an action today. ill upload an apk for you test with here

sds100 avatar Mar 20 '20 09:03 sds100

You're welcome... and thank you!.

Gitoffthelawn avatar Mar 20 '20 09:03 Gitoffthelawn

here, try this. the action is at the bottom of the "other" tab. app-debug.zip

sds100 avatar Mar 20 '20 10:03 sds100

Thank you so much! I will test it very soon and report back to you how it goes.

Gitoffthelawn avatar Mar 21 '20 01:03 Gitoffthelawn

I gave it a try. Here's what I did and what happened:

Steps Taken:

  1. Installed app-debug.apk on Android 7.0
  2. Launched it
  3. Turned on accessibility services for it
  4. Did not do anything else (did not turn off battery optimization, did not enable WRITE_SECURE_SETTINGS, did not enable "Keycode"/"Key"/"Text", did not give Do Not Disturb access.)
  5. Clicked the red plus sign
  6. Clicked Choose Action
  7. Scrolled to Other heading
  8. Selected "Samsung Camera Pro Mode"
  9. Pressed Test

Result: Nothing happens for 5-6 seconds. Then the app crashes.

I repeated steps 2-9 (skipping step 3, as it was unneeded for repeat tests) 5 times, and each time the result was identical.

I then turned on in-app logging and repeated the test, but nothing besides the "Accessibility service enabled" message appeared in the log.

That's my report! :)

Gitoffthelawn avatar Mar 21 '20 08:03 Gitoffthelawn

okay, thanks for trying! i'll make sure the crash is reported into the app's log and then try again to figure out what is causing it to crash.

sds100 avatar Mar 21 '20 09:03 sds100

try this! app-debug.zip

sds100 avatar Mar 21 '20 09:03 sds100

Thanks. Here's the error:

android.content.ActivityNotFoundException: Unable to find explicit activity class {com.sec.android.app.camera/Camera}; have you declared this activity in your AndroidManifest.xml?

Gitoffthelawn avatar Mar 21 '20 10:03 Gitoffthelawn

try this app-debug.zip

sds100 avatar Mar 21 '20 10:03 sds100

Same error in log.

Gitoffthelawn avatar Mar 21 '20 10:03 Gitoffthelawn

im trying to figure out the activity name... app-debug (2).zip

sds100 avatar Mar 21 '20 10:03 sds100

It's not just com.sec.android.app.camera.shootingmode.pro?

Gitoffthelawn avatar Mar 21 '20 10:03 Gitoffthelawn

oh, yeah it is. my bad. I meant I am trying to figure out the "component" in the Intent. maybe i dont need it... try this... app-debug (3).zip

sds100 avatar Mar 21 '20 10:03 sds100

ok... I tried app-debug (2).zip - it didn't crash, but brought up the regular (non Pro) camera. There was a message in the log about not supporting Samsung Dex.

Trying app-debug (3).zip momentarily.

Gitoffthelawn avatar Mar 21 '20 10:03 Gitoffthelawn

You successfully launched the Gallery. That might be useful too. :)

Gitoffthelawn avatar Mar 21 '20 10:03 Gitoffthelawn

haha, can you try this one... app-debug (4).zip

sds100 avatar Mar 21 '20 10:03 sds100

Testing it momentarily. BTW, I just asked Stanley (https://f-droid.org/en/packages/fr.xgouchet.packageexplorer/) for details, but I don't see anything that I think will be helpful.

The camcorder activity is .Camcoder. That would be a great one to have as well.

Gitoffthelawn avatar Mar 21 '20 10:03 Gitoffthelawn

can you upload the apk so I can have a look at Stanley?

sds100 avatar Mar 21 '20 10:03 sds100

the camera

sds100 avatar Mar 21 '20 11:03 sds100

i like to use this... https://play.google.com/store/apps/details?id=com.javiersantos.mlmanager

sds100 avatar Mar 21 '20 11:03 sds100

thanks

sds100 avatar Mar 21 '20 11:03 sds100

can you upload it again, i accidently stopped the download and cant download again.

sds100 avatar Mar 21 '20 11:03 sds100

i wont mess up this time....

sds100 avatar Mar 21 '20 11:03 sds100

got it. :)

sds100 avatar Mar 21 '20 11:03 sds100

did you try app-debug (4).zip?

sds100 avatar Mar 21 '20 11:03 sds100

Yes, it loads the camera in non-Pro mode.

Gitoffthelawn avatar Mar 21 '20 11:03 Gitoffthelawn

try this one... we will get there eventually. 😄 app-debug (5).zip

sds100 avatar Mar 21 '20 11:03 sds100

I have great confidence in you. :)

Gitoffthelawn avatar Mar 21 '20 11:03 Gitoffthelawn

It also loads the camera in non-Pro mode.

I tried shoving the entire device into the Ethernet port to send it directly to you, but it didn't fit. ;)

Gitoffthelawn avatar Mar 21 '20 11:03 Gitoffthelawn

haha, 😂 i dont know why it isn't working... try this....

app-debug (6).zip

sds100 avatar Mar 21 '20 11:03 sds100

also try this...

app-debug (7).zip

sds100 avatar Mar 21 '20 11:03 sds100

try this...

app-debug (8).zip

sds100 avatar Mar 21 '20 11:03 sds100

v6 = non-pro cam v7 = error 'Unable to find explicit activity class...' v8 = error 'Unable to find explicit activity class...'

If you need the exact error strings, I can get those for you.

Gitoffthelawn avatar Mar 21 '20 12:03 Gitoffthelawn

I don't know if it's relevant, but there is an S. before the activity name:

#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x14200000;component=com.sec.android.app.camera/.Camera;S.activity_name=com.sec.android.app.camera.shootingmode.pro;l.profile=-1;end

What's the significance of the S.?

Gitoffthelawn avatar Mar 21 '20 12:03 Gitoffthelawn

i have no idea 😂 but it isnt a part of the activity name. can you give me the exact error strings?

sds100 avatar Mar 21 '20 12:03 sds100

actually, i have an idea what it is....

sds100 avatar Mar 21 '20 13:03 sds100

try this...

app-debug (9).zip

sds100 avatar Mar 21 '20 13:03 sds100

Here are the full error strings for v7 and v8:

v7 android.content.ActivityNotFoundException: Unable to find explicit activity class {com.sec.android.app.camera/com.sec.android.app.camera.shootingmode.pro}; have you declared this activity in your AndroidManifest.xml?

v8 android.content.ActivityNotFoundException: Unable to find explicit activity class {com.sec.android.app.camera/.shootingmode.pro}; have you declared this activity in your AndroidManifest.xml?

Ill try v9 now.

Gitoffthelawn avatar Mar 21 '20 13:03 Gitoffthelawn

SUCCESS!!!!! :)

What was it?

Gitoffthelawn avatar Mar 21 '20 13:03 Gitoffthelawn

yaayyy. the S. and l. were very significant. they are the data types of the Extras attached to the Intent. E.g S. means the Intent has a string extra called "com.sec.android.app.camera.shootingmode.pro". Thank you for making me think harder about it and question myself! 😄

sds100 avatar Mar 21 '20 13:03 sds100

so it works reliably? can you try remapping a key to it and seeing what happens.

sds100 avatar Mar 21 '20 13:03 sds100

I had a hunch! :)

What does an I. represent?

Can you add an item for the camcorder too?

The camcorder activity is .Camcoder

I'll try remapping a key now.

Gitoffthelawn avatar Mar 21 '20 13:03 Gitoffthelawn

It is an L. the L means Long. hard to distinguish between 1, I, and l in many fonts. 😄 yeah, I'll that as well.... gimme a few mins...

sds100 avatar Mar 21 '20 13:03 sds100

Long integer?

I mapped the Pro camera mode to the camera button, and it works! There is a fairly long delay though. Maybe 3 seconds after pressing the camera button, the camera loads. Normally it's instantaneous.

Gitoffthelawn avatar Mar 21 '20 13:03 Gitoffthelawn

Within Key Mapper or another app, it's instant; but from the launcher it's 3-4 seconds. Hmmm...

Gitoffthelawn avatar Mar 21 '20 13:03 Gitoffthelawn

yeah, a Long integer. So the keymap works instantaneously from all apps except the launcher?

sds100 avatar Mar 21 '20 13:03 sds100

Correct.

Gitoffthelawn avatar Mar 21 '20 13:03 Gitoffthelawn

thats strange. since it is just the launcher and not globally, I'll assume it isn't my fault for now.... do you have a different launcher to try it with?

sds100 avatar Mar 21 '20 13:03 sds100

what other camera modes does the samsung camera app have? I might as well add them all...

sds100 avatar Mar 21 '20 13:03 sds100

can you give me the same intent information you gave me before.

sds100 avatar Mar 21 '20 13:03 sds100

I'm using Nova Launcher Prime v6.2.9.

I just tried it with the default Samsung launcher (TouchWiz? I don't know), and there is no delay.

Why in the world would there be a delay in Nova?

intent #Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x14200000;component=com.sec.android.app.camera/.Camera;S.activity_name=com.sec.android.app.camera.shootingmode.pro;l.profile=-1;end

The activity name for the camcorder is .Camcoder I'll get the other camera modes.

Gitoffthelawn avatar Mar 21 '20 13:03 Gitoffthelawn

i have no idea. thank you.

sds100 avatar Mar 21 '20 13:03 sds100

Think harder! :) :) :) LOL

The camera settings are: .setting.CameraSettingActivity

More to follow...

Gitoffthelawn avatar Mar 21 '20 13:03 Gitoffthelawn

can you make shortcuts for the other modes and extract the intent data for them as well? i need to know the S.activity_name and l.profile

sds100 avatar Mar 21 '20 13:03 sds100

The regular camera is ,Camera The camcorder is .Camcorder

For settings, there is also .SettingReceiveActivity, but I kinda doubt that is useful.

All the other activities are help activities and other stuff that I don't think anyone would find useful.


Just got your last message. Yes, I can definitely do that. Would it be okay with you if we resume in 10-15 hours?

Gitoffthelawn avatar Mar 21 '20 13:03 Gitoffthelawn

yeah, no problem! just send me the stuff whenever you can and I'll get on top of it as soon as possible.

sds100 avatar Mar 21 '20 13:03 sds100

Thanks so much for everything. It's great working with you.

Gitoffthelawn avatar Mar 21 '20 13:03 Gitoffthelawn

That was a long hour!

Here are all the intents. The only things I haven't been able to figure out are:

  1. The l.profile=-1. Any ideas?
  2. The long delay in Nova Launcher Prime. Any chance that could be related to l.profile=-1?

BTW, notice that the launchFlags are not all identical.

Live Broadcast #Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x30220000;component=com.sec.android.app.camera.plb/.Camera;S.activity_name=com.sec.android.app.camera.plb.Camera;end

Virtual shot #Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x14200000;component=com.sec.android.app.camera/.Camera;S.activity_name=com.sec.android.app.camera.shootingmode.virtualshot;end

Video collage #Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x14200000;component=com.sec.android.app.camera/.Camera;S.activity_name=com.sec.android.app.camera.shootingmode.videocollage;end

Slow motion #Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x14200000;component=com.sec.android.app.camera/.Camera;S.activity_name=com.sec.android.app.camera.shootingmode.slowmotion;end

Selective focus #Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x14200000;component=com.sec.android.app.camera/.Camera;S.activity_name=com.sec.android.app.camera.shootingmode.selectivefocus;end

Pro #Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x14200000;component=com.sec.android.app.camera/.Camera;S.activity_name=com.sec.android.app.camera.shootingmode.pro;l.profile=-1;end

Pro #Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x14200000;component=com.sec.android.app.camera/.Camera;S.activity_name=com.sec.android.app.camera.shootingmode.pro;end

Panorama #Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x14200000;component=com.sec.android.app.camera/.Camera;S.activity_name=com.sec.android.app.camera.shootingmode.panorama;end

Fast motion #Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x14200000;component=com.sec.android.app.camera/.Camera;S.activity_name=com.sec.android.app.camera.shootingmode.fastmotion;end

Auto #Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x14200000;component=com.sec.android.app.camera/.Camera;S.activity_name=com.sec.android.app.camera.shootingmode.auto;end

Camera #Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=com.sec.android.app.camera/.Camera;l.profile=-1;end

Gitoffthelawn avatar Mar 22 '20 07:03 Gitoffthelawn

thank you! i have no idea what L.profile means now. I thought it meant something to do with the "mode" (profile) to launch the camera in. E.g -1 = pro mode. But that doesn't seem to be the case. I'll send you an apk which doesn't attach the L.profile to the intent.

sds100 avatar Mar 22 '20 11:03 sds100

can you test this WITHOUT the L.profile please.

app-debug-10.zip

sds100 avatar Mar 22 '20 11:03 sds100

I've added all the camera modes... test if they all work!

app-debug (11).zip

sds100 avatar Mar 22 '20 12:03 sds100

Great! Is v11 the same as v10, but v10 doesn't have the L.profile and v11 does?

Can you make a single version with L.profile and without? Then I can quickly test them back-to-back to see if there are differences. You can postfix items with L.profile with (L) in the UI for now.

Gitoffthelawn avatar Mar 22 '20 12:03 Gitoffthelawn

V10 is exact same as v9 but doesn't have the l.profile.

sds100 avatar Mar 22 '20 13:03 sds100

So I can test all the possibilities together, can you add the two l.profile items to v11?

Gitoffthelawn avatar Mar 22 '20 13:03 Gitoffthelawn

Yes to both questions. If you could test V10 and V11 to see if all the modes work, that would be great. let me know which ones work and don't work.

sds100 avatar Mar 23 '20 09:03 sds100

ok... So both v10 and v11 have all the modes (and v11 adds l.profile, whereas v10 has no l.profile intents)?

I'm a little confused because reading through our thread it looks like v10 was finished before you added all the modes.

Gitoffthelawn avatar Mar 23 '20 09:03 Gitoffthelawn

Yeah, only v11 has all the modes. V10 is exact same as V9 except for I made V10 to test whether the l.profile is even needed for any of the intents which seem to need it.

sds100 avatar Mar 23 '20 09:03 sds100

That's what I thought. Don't we need to test both of the intents that have l.profile (in the details I provided) with and without the use of the l.profile param?

Gitoffthelawn avatar Mar 23 '20 09:03 Gitoffthelawn

Yeah, I'll do that once I know that the l.profile is even required for atleast one of them. If the Pro mode doesn't open without l.profile and doesn't make a difference to the Nova launcher behaviour, then I'll assume that it is needed for them all.

sds100 avatar Mar 23 '20 10:03 sds100

OK... I'm curious to see if l.profile makes a difference for any of the intents, even if it's not required. That's why I was thinking of having a version where all the intents are available without l.profile (I currently don't have the option to test). Does that make sense to you?

Gitoffthelawn avatar Mar 23 '20 10:03 Gitoffthelawn

Yeah, I'll do that now... first test v10 and v11 while I do this...

sds100 avatar Mar 23 '20 10:03 sds100

NO l.profile is attached to any of the intents in this apk

app-debug (12).zip

sds100 avatar Mar 23 '20 10:03 sds100

Only Pro mode and the normal Camera mode have l.profile attached in this apk.

app-debug (13).zip

sds100 avatar Mar 23 '20 10:03 sds100

Sorry for the short delay in testing this. A few high priority items hit at the same time.

Gitoffthelawn avatar Mar 24 '20 11:03 Gitoffthelawn

Don't worry. There is no rush.

sds100 avatar Mar 24 '20 11:03 sds100

ok... not rushing... but definitely soon... haven't forgotten... just real busy.

Gitoffthelawn avatar Mar 26 '20 13:03 Gitoffthelawn

Hi. I invested some time testing Key Mapper debug versions 10-13. The results are below.

Note that the "video mode" always opened in "auto mode", but perhaps there is no distinct video mode for this version of Samsung Camera. I recommend just including it for the sake of completeness and in case other versions of the Samsung Camera app support a special video mode. Also, you'll likely want to make sure you check the code for video mode just to make sure there isn't an error for that mode.


Debug v10

Pro - Yes Long Delay for Trigger to Respond from Nova Launcher - Yes Able to still open default camera afterwards - Yes


Debug v11

Camera - Y Video - NO, Opened in Auto Mode Pro - Y Live Broadcast - Crashed Key Mapper Virtual Shot - Y Video Collage - Y Slow Motion - Y Selective Focus - Y Panorama - Y Fast Motion - Y Auto - Y Long Delay for Trigger to Respond from Nova Launcher - Yes Able to still open default camera afterwards - Yes


Debug v12

Pro - Error android.content.ActivityNotFoundException: Unable to find explicit activity class (com.sec.android.app.camera/.Camera); have you declared this activity in your AndroidManifest.xml?


Debug v13

Camera - Y Video - NO, Opened in Auto Mode Pro - Y Live Broadcast - Crashed Key Mapper Virtual Shot - Y Video Collage - Y Slow Motion - Y Selective Focus - Y Panorama - Y Fast Motion - Y Auto - Y Long Delay for Trigger to Respond from Nova Launcher - No!!! Able to still open default camera afterwards - Yes Weird Behavior - Home button now tries to load Google Assistant, even though nothing has been remapped for that button

Gitoffthelawn avatar Apr 09 '20 08:04 Gitoffthelawn

the video mode didn't work because I forgot to add the activity name for it when creating the intent. fixing that now...

sds100 avatar Apr 10 '20 09:04 sds100

app-debug (14).zip

i think i've fixed the video issue. i've tried something different with the live broadcast one, not sure it fixes it.

sds100 avatar Apr 10 '20 09:04 sds100

I'll give v14 a whirl. Do you know why v13 worked so well with Nova Launcher, as compared to the previous versions? Also, any insight as to why it messed up the Home button?

Gitoffthelawn avatar Apr 10 '20 11:04 Gitoffthelawn

I've got no idea why it messed up the Home button. 😄

sds100 avatar Apr 23 '20 17:04 sds100

implemented

sds100 avatar Jun 02 '20 16:06 sds100

@sds100 Thanks. I don't think I performed all the testing and variations you wanted. Doing so has been on my list, but I've been so busy. I am sorry. If you want me to test something, just point me to it.

Gitoffthelawn avatar Jun 04 '20 04:06 Gitoffthelawn

Oh yeah, we didn't finish testing. I thought it was implemented by mistake

sds100 avatar Jun 04 '20 10:06 sds100

Can you just test v14? I felt confident that everything had been fixed.

sds100 avatar Jun 04 '20 10:06 sds100

Can you just test v14? I felt confident that everything had been fixed.

Yes. I've prioritised the task, but if I don't get it done soon enough for you, just let me know and I'll make room for it in the urgent queue one way or another.

Gitoffthelawn avatar Jun 05 '20 09:06 Gitoffthelawn

There is no rush or deadline. I consider this your feature since no one else has requested it. I will just merge it into whatever release is ready whenever you have tested it..

sds100 avatar Jun 05 '20 10:06 sds100

Thank you. It's actually been weighing on me that I haven't had the time to get it done. I'm going to make a push for it this weekend. I have already blocked off 30 minutes in my schedule for this project. I just hope the phone doesn't keep ringing with urgent issues.

Gitoffthelawn avatar Jun 05 '20 22:06 Gitoffthelawn

@Gitoffthelawn keymapper-samsung-camera-actions-v15.zip This is updated to the latest version of Key Mapper.

sds100 avatar Jun 17 '20 11:06 sds100

Got it. Thank you.

Gitoffthelawn avatar Jun 17 '20 11:06 Gitoffthelawn

@Gitoffthelawn I remember us talking about this 2 years ago 😂 Still here?

sds100 avatar Jun 21 '22 21:06 sds100

@sds100 Hi Seth. I'm still here. Glad you are too. :)

Gitoffthelawn avatar Jun 22 '22 12:06 Gitoffthelawn

Do the samsung camera actions I put in that apk from 2 years ago work?

sds100 avatar Jun 22 '22 12:06 sds100

@Gitoffthelawn Do you still want this feature? Otherwise I'll just close it. Have a 2 year old branch 😂😂

sds100 avatar Jun 22 '22 14:06 sds100

@sds100 Yes, I'm still interested in this feature. 😃 I thought, perhaps mistakenly, that when you wrote "This is updated to the latest version of Key Mapper." that you meant you added it to the main branch. Did you happen to mean something else?

Gitoffthelawn avatar Jun 23 '22 04:06 Gitoffthelawn

It looks like I was asking you to test v14, can you test it?

sds100 avatar Jun 23 '22 08:06 sds100