diff options
-rw-r--r-- | core/java/android/hardware/ICameraService.aidl | 7 | ||||
-rw-r--r-- | core/res/AndroidManifest.xml | 8 | ||||
-rw-r--r-- | core/res/res/values/strings.xml | 2 | ||||
-rw-r--r-- | services/core/java/com/android/server/camera/CameraService.java | 66 | ||||
-rw-r--r-- | services/java/com/android/server/SystemServer.java | 5 |
5 files changed, 88 insertions, 0 deletions
diff --git a/core/java/android/hardware/ICameraService.aidl b/core/java/android/hardware/ICameraService.aidl index d5dfaf6..9bc2f46 100644 --- a/core/java/android/hardware/ICameraService.aidl +++ b/core/java/android/hardware/ICameraService.aidl @@ -75,4 +75,11 @@ interface ICameraService out BinderHolder device); int setTorchMode(String CameraId, boolean enabled, IBinder clientBinder); + + /** + * Notify the camera service of a system event. Should only be called from system_server. + * + * Callers require the android.permission.CAMERA_SEND_SYSTEM_EVENTS permission. + */ + oneway void notifySystemEvent(int eventId, int arg0); } diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml index 851c4bf..b272e4a 100644 --- a/core/res/AndroidManifest.xml +++ b/core/res/AndroidManifest.xml @@ -1220,6 +1220,14 @@ android:label="@string/permlab_cameraDisableTransmitLed" android:description="@string/permdesc_cameraDisableTransmitLed" /> + <!-- Allows sending the camera service notifications about system-wide events. + @hide --> + <permission android:name="android.permission.CAMERA_SEND_SYSTEM_EVENTS" + android:permissionGroup="android.permission-group.CAMERA" + android:protectionLevel="signature|system" + android:label="@string/permdesc_cameraSendSystemEvent" + android:description="@string/permdesc_cameraSendSystemEvent" /> + <!-- =========================================== --> <!-- Permissions associated with telephony state --> <!-- =========================================== --> diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml index 0c91f32..da2bf35 100644 --- a/core/res/res/values/strings.xml +++ b/core/res/res/values/strings.xml @@ -1758,6 +1758,8 @@ <string name="permlab_cameraDisableTransmitLed">disable transmit indicator LED when camera is in use</string> <!-- Description of a camera app permission, listed so the user can choose whether or not they want to allow it to disable the may-transmit light indicator. --> <string name="permdesc_cameraDisableTransmitLed">Allows a pre-installed system application to disable the camera use indicator LED.</string> + <!-- Description of a camera app permission, listed so that the user can send the camera service notifications about system-wide events. --> + <string name="permdesc_cameraSendSystemEvent">Allows a pre-installed system application to send the camera service system events.</string> <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. --> <string name="permlab_brick" product="tablet">permanently disable tablet</string> diff --git a/services/core/java/com/android/server/camera/CameraService.java b/services/core/java/com/android/server/camera/CameraService.java new file mode 100644 index 0000000..f9b17ed --- /dev/null +++ b/services/core/java/com/android/server/camera/CameraService.java @@ -0,0 +1,66 @@ +/* + * Copyright 2015 The Android Open Source 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 com.android.server.camera; + +import android.content.Context; +import android.hardware.ICameraService; +import android.os.IBinder; +import android.os.RemoteException; + +import com.android.server.SystemService; + +/** + * CameraService is the system_server analog to the camera service running in mediaserver. + * + * @hide + */ +public class CameraService extends SystemService { + + /** + * This must match the ICameraService.aidl definition + */ + private static final String CAMERA_SERVICE_BINDER_NAME = "media.camera"; + + // Event arguments to use with the camera service notifySystemEvent call: + public static final int NO_EVENT = 0; // NOOP + public static final int USER_SWITCHED = 1; // User changed, argument is the new user handle + + public CameraService(Context context) { + super(context); + } + + @Override + public void onStart() {} + + @Override + public void onSwitchUser(int userHandle) { + super.onSwitchUser(userHandle); + + /** + * Forward the user switch event to the native camera service running in mediaserver. + */ + IBinder cameraServiceBinder = getBinderService(CAMERA_SERVICE_BINDER_NAME); + if (cameraServiceBinder == null) { + return; // Camera service not active, there is no need to evict user clients. + } + ICameraService cameraServiceRaw = ICameraService.Stub.asInterface(cameraServiceBinder); + try { + cameraServiceRaw.notifySystemEvent(USER_SWITCHED, userHandle); + } catch (RemoteException e) { + // Do nothing, if camera service is dead, there is no need to evict user clients. + } + } +} diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java index 090c0f8..53da75b 100644 --- a/services/java/com/android/server/SystemServer.java +++ b/services/java/com/android/server/SystemServer.java @@ -53,6 +53,7 @@ import com.android.server.accessibility.AccessibilityManagerService; import com.android.server.accounts.AccountManagerService; import com.android.server.am.ActivityManagerService; import com.android.server.audio.AudioService; +import com.android.server.camera.CameraService; import com.android.server.clipboard.ClipboardService; import com.android.server.content.ContentService; import com.android.server.devicepolicy.DevicePolicyManagerService; @@ -408,6 +409,7 @@ public final class SystemServer { AudioService audioService = null; MmsServiceBroker mmsService = null; EntropyMixer entropyMixer = null; + CameraService cameraService = null; boolean disableStorage = SystemProperties.getBoolean("config.disable_storage", false); boolean disableBluetooth = SystemProperties.getBoolean("config.disable_bluetooth", false); @@ -436,6 +438,9 @@ public final class SystemServer { mContentResolver = context.getContentResolver(); + Slog.i(TAG, "Camera Service"); + mSystemServiceManager.startService(CameraService.class); + // The AccountManager must come before the ContentService try { // TODO: seems like this should be disable-able, but req'd by ContentService |