Loading Android.mk +1 −0 Original line number Diff line number Diff line Loading @@ -137,6 +137,7 @@ LOCAL_SRC_FILES += \ core/java/android/hardware/IConsumerIrService.aidl \ core/java/android/hardware/IProCameraUser.aidl \ core/java/android/hardware/IProCameraCallbacks.aidl \ core/java/android/hardware/ITorchService.aidl \ core/java/android/hardware/camera2/ICameraDeviceUser.aidl \ core/java/android/hardware/camera2/ICameraDeviceCallbacks.aidl \ core/java/android/hardware/ISerialManager.aidl \ Loading core/java/android/content/Context.java +10 −0 Original line number Diff line number Diff line Loading @@ -2499,6 +2499,16 @@ public abstract class Context { */ public static final String THEME_SERVICE = "themes"; /** * Use with {@link #getSystemService} to retrieve a * {@link com.android.server.TorchService} for accessing torch service. * * @see #getSystemService * @see com.android.server.TorchService * @hide */ public static final String TORCH_SERVICE = "torch"; /** * Determine whether the given permission is allowed for a particular * process and user ID running in the system. Loading core/java/android/hardware/Camera.java +13 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import android.app.ActivityThread; import android.annotation.SdkConstant; import android.annotation.SdkConstant.SdkConstantType; import android.content.Context; import android.hardware.ITorchService; import android.graphics.ImageFormat; import android.graphics.Point; import android.graphics.Rect; Loading Loading @@ -326,6 +327,7 @@ public class Camera { * @see android.app.admin.DevicePolicyManager#getCameraDisabled(android.content.ComponentName) */ public static Camera open(int cameraId) { disableTorch(); return new Camera(cameraId); } Loading @@ -336,6 +338,7 @@ public class Camera { * @see #open(int) */ public static Camera open() { disableTorch(); int numberOfCameras = getNumberOfCameras(); CameraInfo cameraInfo = new CameraInfo(); for (int i = 0; i < numberOfCameras; i++) { Loading @@ -347,6 +350,16 @@ public class Camera { return null; } private static void disableTorch() { IBinder b = ServiceManager.getService(Context.TORCH_SERVICE); ITorchService torchService = ITorchService.Stub.asInterface(b); try { torchService.onCameraOpened(); } catch (RemoteException e) { // Ignore } } Camera(int cameraId) { mShutterCallback = null; mRawImageCallback = null; Loading core/java/android/hardware/ITorchService.aidl 0 → 100644 +26 −0 Original line number Diff line number Diff line /** * Copyright (c) 2014, The CyanogenMod Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.hardware; /** * {@hide} */ interface ITorchService { void onCameraOpened(); void onStartingTorch(); } services/java/com/android/server/SystemServer.java +9 −0 Original line number Diff line number Diff line Loading @@ -501,6 +501,15 @@ class ServerThread { } } if (!disableNonCoreServices) { try { Slog.i(TAG, "TorchService"); ServiceManager.addService(Context.TORCH_SERVICE, new TorchService(context)); } catch (Throwable e) { reportWtf("starting Torch Service", e); } } if (!disableNetwork) { try { Slog.i(TAG, "NetworkManagement Service"); Loading Loading
Android.mk +1 −0 Original line number Diff line number Diff line Loading @@ -137,6 +137,7 @@ LOCAL_SRC_FILES += \ core/java/android/hardware/IConsumerIrService.aidl \ core/java/android/hardware/IProCameraUser.aidl \ core/java/android/hardware/IProCameraCallbacks.aidl \ core/java/android/hardware/ITorchService.aidl \ core/java/android/hardware/camera2/ICameraDeviceUser.aidl \ core/java/android/hardware/camera2/ICameraDeviceCallbacks.aidl \ core/java/android/hardware/ISerialManager.aidl \ Loading
core/java/android/content/Context.java +10 −0 Original line number Diff line number Diff line Loading @@ -2499,6 +2499,16 @@ public abstract class Context { */ public static final String THEME_SERVICE = "themes"; /** * Use with {@link #getSystemService} to retrieve a * {@link com.android.server.TorchService} for accessing torch service. * * @see #getSystemService * @see com.android.server.TorchService * @hide */ public static final String TORCH_SERVICE = "torch"; /** * Determine whether the given permission is allowed for a particular * process and user ID running in the system. Loading
core/java/android/hardware/Camera.java +13 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import android.app.ActivityThread; import android.annotation.SdkConstant; import android.annotation.SdkConstant.SdkConstantType; import android.content.Context; import android.hardware.ITorchService; import android.graphics.ImageFormat; import android.graphics.Point; import android.graphics.Rect; Loading Loading @@ -326,6 +327,7 @@ public class Camera { * @see android.app.admin.DevicePolicyManager#getCameraDisabled(android.content.ComponentName) */ public static Camera open(int cameraId) { disableTorch(); return new Camera(cameraId); } Loading @@ -336,6 +338,7 @@ public class Camera { * @see #open(int) */ public static Camera open() { disableTorch(); int numberOfCameras = getNumberOfCameras(); CameraInfo cameraInfo = new CameraInfo(); for (int i = 0; i < numberOfCameras; i++) { Loading @@ -347,6 +350,16 @@ public class Camera { return null; } private static void disableTorch() { IBinder b = ServiceManager.getService(Context.TORCH_SERVICE); ITorchService torchService = ITorchService.Stub.asInterface(b); try { torchService.onCameraOpened(); } catch (RemoteException e) { // Ignore } } Camera(int cameraId) { mShutterCallback = null; mRawImageCallback = null; Loading
core/java/android/hardware/ITorchService.aidl 0 → 100644 +26 −0 Original line number Diff line number Diff line /** * Copyright (c) 2014, The CyanogenMod Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.hardware; /** * {@hide} */ interface ITorchService { void onCameraOpened(); void onStartingTorch(); }
services/java/com/android/server/SystemServer.java +9 −0 Original line number Diff line number Diff line Loading @@ -501,6 +501,15 @@ class ServerThread { } } if (!disableNonCoreServices) { try { Slog.i(TAG, "TorchService"); ServiceManager.addService(Context.TORCH_SERVICE, new TorchService(context)); } catch (Throwable e) { reportWtf("starting Torch Service", e); } } if (!disableNetwork) { try { Slog.i(TAG, "NetworkManagement Service"); Loading