Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 351c2c21 authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

Grumble, apps should check features before using.

Turns out several apps are blindly grabbing a FINGERPRINT_SERVICE
reference without checking to see if the device actually includes
that feature.

Hand pre-O apps a stubbed out Manager instance, but keep the new
ServiceNotFoundException behavior intact going forward, since it
prevents race conditions during boot or Binder service restarts.

Test: builds, boots
Bug: 32566669
Change-Id: Id1c0873e98e59b255f32e0f9204f4525a345f9ef
parent cf2c279a
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -92,6 +92,7 @@ import android.net.wifi.p2p.WifiP2pManager;
import android.nfc.NfcManager;
import android.os.BatteryManager;
import android.os.BatteryStats;
import android.os.Build;
import android.os.DropBoxManager;
import android.os.HardwarePropertiesManager;
import android.os.IBatteryPropertiesRegistrar;
@@ -674,7 +675,12 @@ final class SystemServiceRegistry {
                new CachedServiceFetcher<FingerprintManager>() {
            @Override
            public FingerprintManager createService(ContextImpl ctx) throws ServiceNotFoundException {
                IBinder binder = ServiceManager.getServiceOrThrow(Context.FINGERPRINT_SERVICE);
                final IBinder binder;
                if (ctx.getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.O) {
                    binder = ServiceManager.getServiceOrThrow(Context.FINGERPRINT_SERVICE);
                } else {
                    binder = ServiceManager.getService(Context.FINGERPRINT_SERVICE);
                }
                IFingerprintService service = IFingerprintService.Stub.asInterface(binder);
                return new FingerprintManager(ctx.getOuterContext(), service);
            }});