Translating adb commands into java commands for Tasker Beta

328 views
Skip to first unread message

Manfred Halper

unread,
Mar 8, 2019, 4:46:48 PM3/8/19
to Tasker
Hello,

I'm trying to transfer the adb command: "adb shell settings put system phone2_on 0" into a correspondiong java command for Tasker.

cr = CONTEXT.getContentResolver();
System.putString(cr,phone2_on, 0)

If I understand the syntax correct, you get the ContentResolver and put the values accordingly.
Is there a list of possible System.* commands available? Since it is an Integer and not a String that I liked to change. Searching the net and forums didn't reveal the answer to me. Perhaps I missed something?

Cheers,
Manfred.

Manfred Halper

unread,
Mar 10, 2019, 6:27:58 AM3/10/19
to Tasker
Okay one step back.

The Class Context() has no function getContenResolver(). Am I looking in the wrong place?

I also tried to instantiate the class Context

cr = new Context();
content_resolver = cr. getContentResolver()
android.provider.Settings$System.putInt(content_resolver, phone_2, 0)

Can't instantiate abstract class android.content.Context

adb shell settings list system
people_stripe=0
personal_mode_enabled=0
phone1_on=1
phone2_on=1
pms_notification_panel_brightness_adjustment=1
pointer_speed=0
prefered_ims_call=1
prefered_voice_call=1

Could it be that the new Beta only sets secure and global settings but no systems settings?
Version Tasker 5.7.0-beta.6
Phone Samsung S9 SDK 28 Release 9

Cheers
Manfred.

Manfred Halper

unread,
Mar 11, 2019, 8:43:10 AM3/11/19
to Tasker
My current iteration after the weekend. is as follows:

content_resolver = CONTEXT.getContentResolver{ContentResolver} ()
Secure.puInt(content_resolver, phone2_on, 0)

It runs without an Error message but the status of the SIM card does not change. 

I also tried this one without an effect:
Secure.puInt(content_resolver, phone2_on, 0)

Should I change the context from secure to system? Or is it possible that the deactivation of the SIM card isn't possible via this appraoch?

João Dias

unread,
Mar 11, 2019, 9:39:34 AM3/11/19
to tas...@googlegroups.com
To do that simply use the Custom Setting action :) Does exactly what you need :)

Thank you for your contact.

   Join: connect multiple devices (send pushes, remote SMS, notifications) on Android, Windows, Mac, Linux
   Tasker: customize/automate anything on your phone!
   AutoApps: add advanced functionality to Tasker via plugins

     

João Dias


--
You received this message because you are subscribed to the Google Groups "Tasker" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tasker+un...@googlegroups.com.
Visit this group at https://groups.google.com/group/tasker.
For more options, visit https://groups.google.com/d/optout.

Manfred Halper

unread,
Mar 12, 2019, 2:00:31 AM3/12/19
to Tasker
Thanks!

Sometimes I can't just see the easy solution when there is a complicated one.

With this I finally got my setup with a dual SIM Handy working. I switch the work SIM off from monday to friday between 8 pm and 7 am. This way I can't get calls from work and only my private SIM profile is up and running.

Thanks again for the solution!

Cheers,
Manfred.

João Dias

unread,
Mar 12, 2019, 7:07:04 AM3/12/19
to tas...@googlegroups.com
Nice :) Glad it works!!


Thank you for your contact.

   Join: connect multiple devices (send pushes, remote SMS, notifications) on Android, Windows, Mac, Linux
   Tasker: customize/automate anything on your phone!
   AutoApps: add advanced functionality to Tasker via plugins

     

João Dias

--

Karol McDonald

unread,
Apr 26, 2019, 7:55:47 AM4/26/19
to Tasker
Hi, would you mind posting the resulting task you created here? 

I have also tried the custom setting approach but cannot get it to work. I can detect the setting change but when I add it to a task it does not perform the required action. 

Thanks! 
Reply all
Reply to author
Forward
0 new messages