IllegalStateException if apex is unavailable.

apexservice is expected to be active before zygote is run. In the
exceptional case it isn't we should fail fast and throw a clear error
message. The current version of the code would just assign "null" to the
mApexService variable, thus causing a null pointer exception later in
the code.

Bug: 124363450
Test: device boots.
Change-Id: I07361163c6e9efd392a633b30e85ca6be9f58ab3
This commit is contained in:
Dario Freni
2019-02-14 15:37:54 +00:00
parent 3deb23fead
commit a1c5f63126

View File

@@ -27,6 +27,7 @@ import android.content.pm.PackageParser;
import android.content.pm.PackageParser.PackageParserException;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.ServiceManager.ServiceNotFoundException;
import android.util.Slog;
import com.android.internal.util.IndentingPrintWriter;
@@ -50,8 +51,12 @@ class ApexManager {
private final Map<String, PackageInfo> mActivePackagesCache;
ApexManager() {
mApexService = IApexService.Stub.asInterface(
ServiceManager.getService("apexservice"));
try {
mApexService = IApexService.Stub.asInterface(
ServiceManager.getServiceOrThrow("apexservice"));
} catch (ServiceNotFoundException e) {
throw new IllegalStateException("Required service apexservice not available");
}
mActivePackagesCache = populateActivePackagesCache();
}