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

Commit 5abb0f26 authored by dhacker29's avatar dhacker29 Committed by Gerrit Code Review
Browse files

SystemServer: Skip TorchService construction if no flash feature detected



* If a device doesn't have a flash, the torch service is unneeded
     and most likely will crash

Signed-off-by: default avatarBrandon McAnsh <brandon.mcansh@gmail.com>
Change-Id: Ideea6931979b87725fdd321d5a2ab447aa1e231a
parent 9ac5aa29
Loading
Loading
Loading
Loading
+9 −7
Original line number Diff line number Diff line
@@ -560,6 +560,7 @@ public class Camera {
    private void notifyTorch(boolean inUse) {
        IBinder b = ServiceManager.getService(Context.TORCH_SERVICE);
        ITorchService torchService = ITorchService.Stub.asInterface(b);
        if (torchService != null) {
            try {
                if (inUse) {
                    torchService.onCameraOpened(mTorchToken, mCameraId);
@@ -570,6 +571,7 @@ public class Camera {
                // Ignore
            }
        }
    }

    @Override
    protected void finalize() {
+2 −1
Original line number Diff line number Diff line
@@ -661,7 +661,8 @@ public final class SystemServer {
                }
            }

            if (!disableNonCoreServices) {
            if (!disableNonCoreServices &&
                    mPackageManager.hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH)) {
                try {
                    Slog.i(TAG, "TorchService");
                    ServiceManager.addService(Context.TORCH_SERVICE, new TorchService(context));