Automatically enable disabled package from appdrawer

The right place to talk JavaScript
Post Reply
Wern-YuenTan
Posts: 7
Joined: Sun Jan 27, 2019 3:41 pm

Automatically enable disabled package from appdrawer

Post by Wern-YuenTan » Fri May 24, 2019 4:19 pm

I'd like to create a script that checks if a package is disabled, and if it is use a shell command to enable it, before launching the activity itself

This script can then be added to all items in the app drawer to allow automatic launching of disabled apps

Combine this with Tasker's latest app changed context and one can create a "greenify" or "icebox" feature in the main app drawer

I can write the script to get the intent and package of the item but am struggling with the package enable command. Can script gurus @F43nd1r or @TrianguloY help? Thanks!

User avatar
Pierrot
Site Admin
Posts: 181
Joined: Wed Jan 23, 2019 12:18 pm
Location: French Alps

Re: Automatically enable disabled package from appdrawer

Post by Pierrot » Sun May 26, 2019 5:46 am

Keep in mind that disabled apps or components will disappear from the app drawer, so to make it work I either need to modify the app drawer to display disabled apps (this is possible) or apps need to be manually added to a desktop before to be disabled.

To enable the whole app you can use something like:

Code: Select all

PackageManager pm=context.getPackageManager();
pm.setApplicationEnabledSetting(package_name, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, 0);
And the variant to enable/disable a single component:

Code: Select all

setComponentEnabledSetting

Wern-YuenTan
Posts: 7
Joined: Sun Jan 27, 2019 3:41 pm

Re: Automatically enable disabled package from appdrawer

Post by Wern-YuenTan » Mon May 27, 2019 4:22 am

Thanks Pierre. I just realized that the official LL app drawer does not allow for adding events/actions to either all items or even specific items. One can create a container that mimics app drawer functionality to achieve this, but is there a better workaround?

I also tried the script you provided and replaced "package_name" with the package name variable, as well as the hard coded package name, but both did not work. Threw up an error in the first line. Is it because of how I am defining context (or not), or do I need an import action upfront?

User avatar
Pierrot
Site Admin
Posts: 181
Joined: Wed Jan 23, 2019 12:18 pm
Location: French Alps

Re: Automatically enable disabled package from appdrawer

Post by Pierrot » Sat Jun 01, 2019 6:21 am

The context is the one you can get through Lightning.getActiveScreen().getContext() (for instance).
In fact it is possible to set custom actions on app drawer items (through scripting!) but I would discourage this as it can break the app drawer behavior.

eruben
Posts: 11
Joined: Sun Sep 15, 2019 4:38 pm

Re: Automatically enable disabled package from appdrawer

Post by eruben » Fri Sep 27, 2019 8:54 pm

Can you please explain more detailed how can I create a shortcut on desktop for a disabled app to enable it before launch and disable after closing. If it is possible.

Post Reply