LauncherHijack icon indicating copy to clipboard operation
LauncherHijack copied to clipboard

Fixing from wake with tasker

Open oathzed opened this issue 5 years ago • 18 comments

With v4.0.3 of launcher hijack, when the device goes to sleep and wakes back up it goes back to the Amazon launcher. Now this is somewhat fixable when you install launch on boot app and set it to go to atv Launcher on wake. The problem is when you come out of wake and back out of the app without pressing the home button it will go to Amazon launcher. It does this one time only after wake, once you press the home button.

Now, I got rid of launch of boot and decided to mess around with tasker. So I made two profiles, 1 when device goes to sleep, launch ATV Launcher, and 1 when device wakes, launch ATV Launcher. Now, I don't have that back out issue, but now it just goes to my launcher home and not where I left off.

oathzed avatar Aug 16 '19 23:08 oathzed

Sorry about the delay, you can use the Custom Setting Tasker action to write to secure settings, the name of the field you need to modify is "enabled_accessibility_services".

HotdogWithMustard avatar Aug 17 '19 04:08 HotdogWithMustard

@hotdogwithmustard thanks for getting back! So what exactly would I put in these fields to enable accessibility in AutoInputs? If autoinputs package is com.joaomgcdf.autoinputs

http://imgur.com/a/qHwFpXI

Sorry, I'm just not super familiar with tasker. Thanks!

oathzed avatar Aug 17 '19 04:08 oathzed

I'm honestly not too familiar with messing around with custom settings, also at work right now so can't really mess with it. When I get home I'll do some research and see if I can whip up a task for you.

HotdogWithMustard avatar Aug 17 '19 09:08 HotdogWithMustard

Okay, thanks so much man I appreciate it

oathzed avatar Aug 17 '19 15:08 oathzed

Here's a working Task for enabling accessibility for AutoInput, It should work on the Fire Stick but I've only tested it on my phone:

<TaskerData sr="" dvi="1" tv="5.8.3">
	<Task sr="task59">
		<cdate>1565967768169</cdate>
		<edate>1566068173132</edate>
		<id>59</id>
		<nme>Secure Settings</nme>
		<pri>100</pri>
		<Action sr="act0" ve="7">
			<code>354</code>
			<Str sr="arg0" ve="3">%data</Str>
			<Str sr="arg1" ve="3">ComponentInfo{com.joaomgcd.autoinput/com.joaomgcd.autoinput.service.ServiceAccessibility}|com.joaomgcd.autoinput/com.joaomgcd.autoinput.service.ServiceAccessibility</Str>
			<Str sr="arg2" ve="3">|</Str>
		</Action>
		<Action sr="act1" ve="7">
			<code>235</code>
			<Int sr="arg0" val="1"/>
			<Str sr="arg1" ve="3">enabled_accessibility_services</Str>
			<Str sr="arg2" ve="3"/>
			<Int sr="arg3" val="0"/>
			<Str sr="arg4" ve="3">%setting</Str>
		</Action>
		<Action sr="act2" ve="7">
			<code>129</code>
			<se>false</se>
			<Str sr="arg0" ve="3">var setting_new = setting;

data.forEach(function(text)
{
    text_esc = text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&amp;');
    if (!setting.match(new RegExp(':' + text_esc + '|' + text_esc + ':')))
    {
        setting_new = setting_new + ':' + text;
    }
});</Str>
			<Str sr="arg1" ve="3"/>
			<Int sr="arg2" val="1"/>
			<Int sr="arg3" val="45"/>
		</Action>
		<Action sr="act3" ve="7">
			<code>548</code>
			<Str sr="arg0" ve="3">Current Value: %setting</Str>
			<Int sr="arg1" val="1"/>
		</Action>
		<Action sr="act4" ve="7">
			<code>37</code>
			<ConditionList sr="if">
				<Condition sr="c0" ve="3">
					<lhs>%setting_new</lhs>
					<op>1</op>
					<rhs>%setting</rhs>
				</Condition>
			</ConditionList>
		</Action>
		<Action sr="act5" ve="7">
			<code>547</code>
			<Str sr="arg0" ve="3">%AccessibilitySettingBackup</Str>
			<Str sr="arg1" ve="3">%setting</Str>
			<Int sr="arg2" val="0"/>
			<Int sr="arg3" val="0"/>
			<Int sr="arg4" val="0"/>
			<Int sr="arg5" val="3"/>
			<ConditionList sr="if">
				<Condition sr="c0" ve="3">
					<lhs>%AccessibilitySettingBackup</lhs>
					<op>13</op>
					<rhs></rhs>
				</Condition>
			</ConditionList>
		</Action>
		<Action sr="act6" ve="7">
			<code>548</code>
			<Str sr="arg0" ve="3">Writing Value: %setting_new</Str>
			<Int sr="arg1" val="1"/>
		</Action>
		<Action sr="act7" ve="7">
			<code>235</code>
			<Int sr="arg0" val="1"/>
			<Str sr="arg1" ve="3">enabled_accessibility_services</Str>
			<Str sr="arg2" ve="3">%setting_new</Str>
			<Int sr="arg3" val="0"/>
			<Str sr="arg4" ve="3"/>
		</Action>
		<Action sr="act8" ve="7">
			<code>38</code>
		</Action>
	</Task>
</TaskerData>

HotdogWithMustard avatar Aug 17 '19 18:08 HotdogWithMustard

How exactly do I get this to work in tasker? I'm adding this to an xml editor and saving as acc.tsk.xml but I get "error: bad data format" what's the easiest way to get this to add to tasker. Cheers!

oathzed avatar Aug 17 '19 18:08 oathzed

Whoops, I selected "Description to Clipboard" thinking that you would be able to import that, guess you can't lol, updated my post to include the XML.

HotdogWithMustard avatar Aug 17 '19 18:08 HotdogWithMustard

No worries lol. Thanks alot man, I'll be sure to try this out later on my fire tv.

One thing I'm worried about is be able to grant secure settings via adb for tasker to get this to work.

oathzed avatar Aug 17 '19 19:08 oathzed

Because last time I tried to do this:

pm grant net.dinglisch.android.taskerm android.permission.WRITE_SECURE_SETTINGS

I didn't get an error or anything but the task still kept asking for write secure settings lol

oathzed avatar Aug 17 '19 19:08 oathzed

@hotdogwithmustard

Referring to my previous comments

Someone on Reddit said:

"The error isn't talking about the WRITE_SECURE_SETTINGS permission. Instead this error involes the android.permission.WRITE_SETTINGS permission.

Although they sound similar, they separate permissions."

Any idea how I can enable that permission?

oathzed avatar Aug 18 '19 02:08 oathzed

You shouldn't need that permission, but you can grant it the same way that you did the other one:

pm grant net.dinglisch.android.taskerm android.permission.WRITE_SETTINGS

If that still doesn't work try exporting the task to an APK with appfactory and then grant that app permission, if that doesn't work then I'm honestly not sure. 😐

HotdogWithMustard avatar Aug 18 '19 04:08 HotdogWithMustard

Does anything specific need to be added to the app for it to "request" that permission?

oathzed avatar Aug 18 '19 04:08 oathzed

Not that I know of. Like I said, I only tested on my phone. Maybe there's something special that the app-debug APK does that I'm not aware of, or it could just be something to do with Tasker. When you run the Task on your Fire Stick what happens? It should output a toast message indicating that it's writing to secure settings when you first run it.

HotdogWithMustard avatar Aug 18 '19 14:08 HotdogWithMustard

Absolutely nothing happens when I run it. I feel like we're so close to figuring this out, but I just don't know why this stuff is happening lol

oathzed avatar Aug 18 '19 15:08 oathzed

If you run the following commands via ADB on your Fire Stick:

  • dumpsys package com.example.settest.settingstest
  • dumpsys package [YOUR APPFACTORY PACKAGE HERE]

You'll notice a couple of things:

  • The AppFactory APK is missing requested/installed permissions: WRITE_SECURE_SETTINGS.
  • The SettingsTest APK uses an additional Library: com.amazon.client.metrics.api (/system/priv-app/MetricsApi/MetricsApi.apk)

I've tried manually adding the permissions to the AppFactory APK and granting them with ADB right after, it still displays a message about missing permissions, this leads me to believe the additional library being used in SettingsTest might be the key.

Unfortunately there doesn't appear to be any source code on GitHub (That I could find anyway.. Perhaps I missed it?) and I don't have the time (or working computer) to decompile the APK and look through it, so I'm afraid at the moment I can't do much more to help. :/

HotdogWithMustard avatar Aug 18 '19 19:08 HotdogWithMustard

Ahh, this would make sense why it's not working, I'd think aswell.

No he didn't release the source for it. I appreciate all the stuff you've helped me with so far. When I get time, I'll take a look at decompiling SettingsTest apk and look through the code with my limited knowledge lol. Then report back here what I find

oathzed avatar Aug 18 '19 20:08 oathzed

@hotdogwithmustard

Hey man, I actually got to enable autoinputs accessibility. I'm just trying to figure out how exactly I would launch the app I was in before I went to sleep when it wakes up.

Because I think essentially what happens is when the fire TV goes to sleep it goes to Amazons launcher. Now I want autoinput to remember the last app it was in before it goes to sleep then launch that app when it wakes up.

How would I do that exactly? I'm very noob with autoinput lol

oathzed avatar Aug 27 '19 00:08 oathzed

@oathzed Did you ever use this with tasker on top of the two profile you helped me with in August? Seems lately the updates have caused some glitches in this. Sometimes I have to hit Home multiple times to get back to ATV Launcher

dashriprock007 avatar Mar 28 '20 15:03 dashriprock007