Merge "ApexManager: Post populateAllPackagesCacheIfNeeded to a background thread"

This commit is contained in:
Nikita Ioffe
2019-08-27 16:20:08 +00:00
committed by Android (Google) Code Review

View File

@@ -261,11 +261,12 @@ abstract class ApexManager {
mContext.registerReceiver(new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
populateAllPackagesCacheIfNeeded();
// Post populateAllPackagesCacheIfNeeded to a background thread, since it's
// expensive to run it in broadcast handler thread.
BackgroundThread.getHandler().post(() -> populateAllPackagesCacheIfNeeded());
mContext.unregisterReceiver(this);
}
}, new IntentFilter(Intent.ACTION_BOOT_COMPLETED), /* broadcastPermission */ null,
BackgroundThread.getHandler());
}, new IntentFilter(Intent.ACTION_BOOT_COMPLETED));
}
private void populateAllPackagesCacheIfNeeded() {