Script ‘Fix for Oreo app drawer not refreshed on LL 14.2’

Script ‘Fix for Oreo app drawer not refreshed on LL 14.2’

Important!

This is a script to fix the bug ‘apps are not updated on the app drawer automatically’. This happens on Android Oreo and above with LL version 14.2. If you don’t use Oreo or you are reading this from the future when a new LL version is available (to be more precise: if when you install a new app it is added automatically to the app drawer) then you do NOT need this script. Otherwise, if you have the mentioned bug, keep reading.

On Android Oreo the way to detect installed/uninstalled/updated apps was changed. Previously any app could register to a broadcast that was sent when a package was installed, uninstalled or updated. Since Oreo that feature was removed and the broadcast isn’t sent. There are two ways to fix this: register to the broadcast while the app is running (it will be lost if the app closes…and personally couldn’t make it work) or use a new function that tells you which packages were updated since a previous call.

I could make this second way work, with some caveats, but under normal circumstances it should work.

When running the script below the app drawer will be updated. It requires manual calling but it is fast so I recommend setting the script to run on the RESUMED event of the app drawer. This way when opening it will be updated.

Known bugs: when the device is restarted (turn off/on) the list is cleared, so if you install/uninstall an app and then restarts without running the script, that app won’t be updated correctly. Remember you can use the ‘refresh’ function from the app drawer to fix this.

Also, keep in mind this is a temporary fix that can have unknown bugs or work incorrectly on some devices/versions. Make a backup first!!! (just in case).

Comment anything you found, and if you know how to fix something or make the script more reliable don’t hesitate to do so and share!

To recap: make a backup, set this script to run in the resumed event of the app drawer, and keep in mind you will probably need to refresh after a device restart.

]]>

13 Commentsto Script ‘Fix for Oreo app drawer not refreshed on LL 14.2’

  1. Anonymous says:

    < ![CDATA[

    //receiver as defined in Lightning’s manifest


    bindClass(“net.pierrox.lightning_launcher.util.MPReceiver”);




    //global vars


    var cntx = getEvent().getScreen().getContext();//LL.getContext();


    var pm = cntx.getPackageManager();


    var mpr = new MPReceiver();


    var script = getCurrentScript();




    //get latest id tried


    var id = script.getTag() || 0;




    //if previous (last tried) is null, reset. Probably due to device restart


    if(id!=0 && pm.getChangedPackages(id-1)==null){


    id=0;


    }



    //get the list


    var packages = pm.getChangedPackages(id);



    //no list, no changes


    if(packages==null){


    return;


    }



    //get packages and save new id


    var list=packages.getPackageNames();


    script.setTag(packages.getSequenceNumber());




    //for each package…


    for(var t=0;t


    var name = list.get(t);




    //if no error, package exist, send ‘replaced’ (LL checks if it is not existent so ‘added’ is not necessary. Thanks Pierre!)


    var action = “android.intent.action.PACKAGE_REPLACED”;



    try {


    pm.getPackageInfo(name,pm.GET_META_DATA);


    } catch (e) {



    //if error, package doesn’t exist, send ‘removed’


    action = “android.intent.action.PACKAGE_REMOVED”;



    }




    //create Intent and send to LL


    var intent = new Intent();


    intent.setData(Uri.parse(name));


    intent.setAction(action);



    mpr.onReceive(cntx,intent);



    }

    ]]>

  2. Anonymous says:

    < ![CDATA[

    nice 1 👍

    ]]>

  3. Anonymous says:

    < ![CDATA[

    Now, if someone could just write a script to bring Pierre Hébert back…. 🤔



    Kidding, of course, but I do hope LL isn’t dead.



    Thank you for this script, TrianguloY.

    ]]>

  4. Anonymous says:

    < ![CDATA[

    function bringTheMainManBack(){



    return “Pierre Hebert”;



    }



    BringTheMainManBack();



    and now we wait…………. 😁

    ]]>

  5. Anonymous says:

    < ![CDATA[

    The method I’ve used for my drawer-anywhere script works correctly even if the device is rebooted. I bet something like this could also be built for the normal app drawer. For reference: https://github.com/F43nd1r/Multitool/blob/master/app/src/main/java/com/faendir/lightning_launcher/multitool/drawer/Drawer.java#L106

    ]]>

  6. Anonymous says:

    < ![CDATA[

    Lukas Morawietz


    Didn’t think about it, but yes that should work because you are comparing the list of installed apps with the list of present items. Is that correct? Although, isn’t that a bit slow? Maybe not. Also it seems your script doesn’t detects updated packages, if I’m not mistaken.



    This script uses the ‘official’ Oreo fix for this issue (one of them) calling that magic function that tells you the modified packages…although it doesn’t tell you if they are installed, updated or uninstalled (it is a terrible official fix in my opinion, it seems Google doesn’t like third party launchers).



    Maybe both scripts can be combined, or use one an the other as a fallback.


    Has anyone run both and check velocity and reliability?

    ]]>

  7. Anonymous says:

    < ![CDATA[

    Awesome! 👍

    ]]>

  8. Anonymous says:

    < ![CDATA[

    TrianguloY I think we only care about updated packages if the launcher intent changes, which would be detected by my script. Correct me if I’m wrong

    ]]>

  9. Anonymous says:

    < ![CDATA[

    Lukas Morawietz I think so, yes (nice use of streams by the way).


    That doesn’t trigger if the icon or the name changes though…not a big issue anyway.

    ]]>

  10. Anonymous says:

    < ![CDATA[

    TrianguloY true, I didn’t think about icon or label changes. I’d load them and compare hashes, but that would make it a lot slower. Currently it takes 50-500ms to run the snippet in my emulator, depending on how many apps changed (50=none, 500=all).

    ]]>

  11. Anonymous says:

    < ![CDATA[

    Lukas Morawietz Oh, that’s fast.


    What about checking the version code? I think you can retrieve it, and that will tell you if anything changed, probably more than needed but worth check it.

    ]]>

  12. Anonymous says:

    < ![CDATA[

    TrianguloY versionCode is available in PackageInfo, not in ResolveInfo, so we’d need an additional packagemanager call for each package. Those calls are slow, so I’m trying to avoid them

    ]]>

  13. Anonymous says:

    < ![CDATA[

    TrianguloY I just checked: loading the versionCode is about as slow as loading the icon and label for each app. Imo that’s not worth it just to fix the changed resource issue.

    ]]>

Leave a Reply

Your email address will not be published. Required fields are marked *