diff --git a/core/java/android/hardware/ICameraService.aidl b/core/java/android/hardware/ICameraService.aidl index d5dfaf6d43a9c..9bc2f46c976b7 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 851c4bf17f80f..b272e4a891cd0 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" /> + + + diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml index 0c91f32eaad3c..da2bf356c9010 100644 --- a/core/res/res/values/strings.xml +++ b/core/res/res/values/strings.xml @@ -1758,6 +1758,8 @@ disable transmit indicator LED when camera is in use Allows a pre-installed system application to disable the camera use indicator LED. + + Allows a pre-installed system application to send the camera service system events. permanently disable tablet 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 0000000000000..f9b17ede4c27a --- /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 090c0f85c3fde..53da75bf5366c 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