Android 5.0/Lollipop: Force rescan of /system/priv-app

pms will scan /system/app(priv-app) at start. so just kill process systemserver :) it work at my lollipop emulator. just take a little while to showing "upgrade android, opt app..."


Comparing the source code of PackageManagerService between KitKat and Lollipop you can see significant changes, and some that are obviously related to this change.

PackageManagerService.java on Lollipop

PackageManagerService.java on KitKat

The most significant change to the question topic is the removal of all references to AppDirObserver (a nested class of PackageManagerService) that was initialized to monitor all directories (the attached image shows a comparison of the relevant code where it was used. Right side shows KitKat code and left side shows Lollipop) enter image description here

Still haven't found a solution for this but might help someone figure it out.


Based on your logcat messages, looks like the PackageManagerService is not even seeing the folder/file changes.

Here is one way to circumvent/trigger a rescan, simulate a a "boot completed" event with broadcast action:

    adb shell am broadcast -a android.intent.action.BOOT_COMPLETED

This should trigger a rescan by the PackageManagerService