Hello,
on my Samsung Galaxy S10 I can choose the torch brightness using the quick setting toggle provided by Samsung ( https://www.samsung.com/ae/support/mobi ... brightness ).
Unfortunately, using "flashlight" action in Automagic (and in most of the apps) enables the minimun brightness torch, and, unfortunately again, i don't think there's a simple way to replicate the action performed by the quick toggle (even on rooted devices like mine, but I'll take suggestions).
Some apps (most of old apps) though, are able to toggle the brightest torch mode. Digging a bit into the topic let me discover that these old apps still use the old camera API (still supported by many firmwares), and using methods like:
Camera.Parameters.getSupportedFlashModes
Camera.Parameters.setFlashMode
Camera.startPreview()
release()
they can switch ON and OFF the brightest torch mode from camera.
Here's 3 examples of really simple apps that can toggle this mode:
https://play.google.com/store/apps/deta ... l&hl=en_US
https://play.google.com/store/apps/deta ... h&hl=en_US
https://play.google.com/store/apps/deta ... y&hl=en_US
Martin, when you have some time, could you please add an action to enable/disable powerful torch mode using the old Camera API ?
Ps. Moved from MM to Pie, and still enjoying my Automagic mate
Enable bright flashlight Torch (using old Camera API)
Moderator: Martin
Re: Enable bright flashlight Torch (using old Camera API)
This maybe can be done using calljavamethod(). But as I try that, I got error of unsupported something. Maybe because mine is camera2 API all the level. But it should still support old API for compatibility. Maybe anuraag can help you with this.
If the calljavamethod works, there will be a higher chance that Martin will include this feature somewhere in the future.
If the calljavamethod works, there will be a higher chance that Martin will include this feature somewhere in the future.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Re: Enable bright flashlight Torch (using old Camera API)
Code: Select all
camera = callJavaStaticMethod("android.hardware.Camera", "open()");
parameters = callJavaMethod(camera, "android.hardware.Camera", "getParameters()");
flashModes = callJavaMethod(parameters, "android.hardware.Camera$Parameters", "getSupportedFlashModes()");
flashOnParameter = null;
if (containsElement(flashModes, "torch")) {flashOnParameter = "torch"}
else if (containsElement(flashModes, "on")) {flashOnParameter = "on"}
else if (containsElement(flashModes, "auto")) {flashOnParameter = "auto"}
callJavaMethod(parameters, "android.hardware.Camera$Parameters", "setFlashMode(java.lang.String)", flashOnParameter);
callJavaMethod(camera, "android.hardware.Camera", "setParameters(android.hardware.Camera$Parameters)", parameters);
callJavaMethod(camera, "android.hardware.Camera", "setPreviewTexture(android.graphics.SurfaceTexture)", callJavaConstructor("android.graphics.SurfaceTexture", "SurfaceTexture(int)", 0));
callJavaMethod(camera, "android.hardware.Camera", "startPreview()");
sleep("10s");
callJavaMethod(camera, "android.hardware.Camera", "stopPreview()");
callJavaMethod(camera, "android.hardware.Camera", "release()");
camera=null
Edit: on my Samsung a7(2017) Automagic's built-in action turns full flashlight by default. And above code doesn't work well in my device.
Last edited by anuraag on 10 Jan 2020 23:31, edited 1 time in total.
Re: Enable bright flashlight Torch (using old Camera API)
Thanks for the suggestion Desmanto, infact the script from anuraag:Desmanto wrote: ↑07 Jan 2020 16:30This maybe can be done using calljavamethod(). But as I try that, I got error of unsupported something. Maybe because mine is camera2 API all the level. But it should still support old API for compatibility. Maybe anuraag can help you with this.
If the calljavamethod works, there will be a higher chance that Martin will include this feature somewhere in the future.
Works brilliantly, thanks a lot mate!!!
I'm sharing a flow with trigger: Shortcut that will activate and deactivate alternatively the brighter torch (using deprecated Camera API) and also will turn off torch after 10 minutes.
This might work also on other devices like Sony Xperia ones (my Z5c used to have different flashlight powers for torch apps and for camera flash but also got quite hot with full power flash on )
Thanks guys for the support.
ps: i have another request directly for Martin: add Condition: service running and Condition: process running for rooted devices > Nougat. I had to search the web to find the right root commands for the purpose and had to refine the flows to apply the condition correctly.
- Attachments
-
- flow_Brighter_Torch_camera_API_20200109_192312.zip
- (1.41 KiB) Downloaded 1227 times
Re: Enable bright flashlight Torch (using old Camera API)
Glad it works.
It will be better if you use global Variable instead of opening camera 2 times. Here is modified flow.
http://automagic4android.com/flow.php?i ... 50ba37e3f5
It will be better if you use global Variable instead of opening camera 2 times. Here is modified flow.
http://automagic4android.com/flow.php?i ... 50ba37e3f5
Re: Enable bright flashlight Torch (using old Camera API)
@emaeee : Glad it works. Hopefully it will be added in the next EAP version. But no this AM 1.38, because adding new feature require longer testing. I just wish AM 1.38 released as stable ASAP, as it contains the new read log permission which open the door of more possibilities to many non-root users.
@anuraag : Thanks for the java, as usual, it is working perfectly. Mine don't have the strong flash, but the code still can toggle properly. Which mean your code can be implemented as built-in action without interferring with other devices.
@anuraag : Thanks for the java, as usual, it is working perfectly. Mine don't have the strong flash, but the code still can toggle properly. Which mean your code can be implemented as built-in action without interferring with other devices.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Re: Enable bright flashlight Torch (using old Camera API)
Thanks for the suggestion and for the share.anuraag wrote: ↑09 Jan 2020 23:08Glad it works.
It will be better if you use global Variable instead of opening camera 2 times. Here is modified flow.
http://automagic4android.com/flow.php?i ... 50ba37e3f5
-
- Posts: 179
- Joined: 16 Oct 2019 17:38
Re: Enable bright flashlight Torch (using old Camera API)
I didn't know about the hidden menus, nor the brightness levels for the torch.
It works on my S10 running Android 10.
Many thanks all round!
It works on my S10 running Android 10.
Many thanks all round!
Crude but it works.
Re: Enable bright flashlight Torch (using old Camera API)
I wasn't aware that automagics torch was the lowest brightness!
Anuraag that is brilliant!
Running s9+
Anuraag that is brilliant!
Running s9+
Every life altering decision you have made, has lead to you reading this.