Improve the scan process

Use multi task to speed up the scan process

CRs-Fixed: 984513

base: fix native crash in system_server

Currently PackageManagerService uses multi-thread to scan
packages to speed up, when scan each package, it sometimes
will call SELinux's restorecon, then libselinux uses global
variable fc_sehandle to selabel_lookup and write in compile_regex,
so it's not thread-safe, so will cause invalid address with
possibility. From backtrace, the final crash happens in pcre_exec.

Add one lock in NativeLibraryHelper to make restorecon safe.

Change-Id: Ida43fcda01d3450befea6afa0be5da27bb195def
CRs-Fixed: 1002406, 1027381
4 files changed