Adding nullptr check for some framework components
Summary: Some framework components do not check
whether the system service being called is null or not
causing "FATAL EXCEPTION" in zygote system process.
Adding nullptr or NULL obj check before calling.
Test: m
flash the device
verify the zygote is running stable and not hitting
FATAL EXECEPTION.
Change-Id: Icd504fb529716ff0870d0d911b1cd8b356bf9bb7
Signed-off-by: Abdelrahman Daim <adaim@meta.com>
diff --git a/location/java/android/location/Geocoder.java b/location/java/android/location/Geocoder.java
index cdde7c6..9746dab 100644
--- a/location/java/android/location/Geocoder.java
+++ b/location/java/android/location/Geocoder.java
@@ -83,8 +83,11 @@
* succeed.
*/
public static boolean isPresent() {
- ILocationManager lm = Objects.requireNonNull(ILocationManager.Stub.asInterface(
- ServiceManager.getService(Context.LOCATION_SERVICE)));
+ ILocationManager lm = ILocationManager.Stub.asInterface(
+ ServiceManager.getService(Context.LOCATION_SERVICE));
+ if (lm == null) {
+ return false;
+ }
try {
return lm.isGeocodeAvailable();
} catch (RemoteException e) {