am f082bb2a: Merge "camera: Add AIDL interface for CameraServiceProxy." into mnc-dev
* commit 'f082bb2a7f6ad064bbd608d079851c9df18ef0f4': camera: Add AIDL interface for CameraServiceProxy.
This commit is contained in:
@@ -146,6 +146,7 @@ LOCAL_SRC_FILES += \
|
||||
core/java/android/database/IContentObserver.aidl \
|
||||
core/java/android/hardware/ICameraService.aidl \
|
||||
core/java/android/hardware/ICameraServiceListener.aidl \
|
||||
core/java/android/hardware/ICameraServiceProxy.aidl \
|
||||
core/java/android/hardware/ICamera.aidl \
|
||||
core/java/android/hardware/ICameraClient.aidl \
|
||||
core/java/android/hardware/IConsumerIrService.aidl \
|
||||
|
||||
@@ -25,7 +25,11 @@ import android.hardware.camera2.utils.BinderHolder;
|
||||
import android.hardware.ICameraServiceListener;
|
||||
import android.hardware.CameraInfo;
|
||||
|
||||
/** @hide */
|
||||
/**
|
||||
* Binder interface for the native camera service running in mediaserver.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
interface ICameraService
|
||||
{
|
||||
/**
|
||||
|
||||
30
core/java/android/hardware/ICameraServiceProxy.aidl
Normal file
30
core/java/android/hardware/ICameraServiceProxy.aidl
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (C) 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 android.hardware;
|
||||
|
||||
/**
|
||||
* Binder interface for the camera service proxy running in system_server.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
interface ICameraServiceProxy
|
||||
{
|
||||
/**
|
||||
* Ping the service proxy to update the valid users for the camera service.
|
||||
*/
|
||||
oneway void pingForUserUpdate();
|
||||
}
|
||||
@@ -19,6 +19,7 @@ import android.app.ActivityManager;
|
||||
import android.content.Context;
|
||||
import android.content.pm.UserInfo;
|
||||
import android.hardware.ICameraService;
|
||||
import android.hardware.ICameraServiceProxy;
|
||||
import android.os.IBinder;
|
||||
import android.os.RemoteException;
|
||||
import android.os.UserManager;
|
||||
@@ -42,14 +43,30 @@ public class CameraService extends SystemService {
|
||||
*/
|
||||
private static final String CAMERA_SERVICE_BINDER_NAME = "media.camera";
|
||||
|
||||
public static final String CAMERA_SERVICE_PROXY_BINDER_NAME = "media.camera.proxy";
|
||||
|
||||
// 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
|
||||
|
||||
private final Context mContext;
|
||||
private UserManager mUserManager;
|
||||
|
||||
private final Object mLock = new Object();
|
||||
private Set<Integer> mEnabledCameraUsers;
|
||||
|
||||
private final ICameraServiceProxy.Stub mCameraServiceProxy = new ICameraServiceProxy.Stub() {
|
||||
@Override
|
||||
public void pingForUserUpdate() {
|
||||
// Binder call
|
||||
synchronized(mLock) {
|
||||
if (mEnabledCameraUsers != null) {
|
||||
notifyMediaserver(USER_SWITCHED, mEnabledCameraUsers);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public CameraService(Context context) {
|
||||
super(context);
|
||||
mContext = context;
|
||||
@@ -62,18 +79,27 @@ public class CameraService extends SystemService {
|
||||
// Should never see this unless someone messes up the SystemServer service boot order.
|
||||
throw new IllegalStateException("UserManagerService must start before CameraService!");
|
||||
}
|
||||
publishBinderService(CAMERA_SERVICE_PROXY_BINDER_NAME, mCameraServiceProxy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartUser(int userHandle) {
|
||||
if (mEnabledCameraUsers == null) {
|
||||
// Initialize mediaserver, or update mediaserver if we are recovering from a crash.
|
||||
onSwitchUser(userHandle);
|
||||
synchronized(mLock) {
|
||||
if (mEnabledCameraUsers == null) {
|
||||
// Initialize mediaserver, or update mediaserver if we are recovering from a crash.
|
||||
switchUserLocked(userHandle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSwitchUser(int userHandle) {
|
||||
synchronized(mLock) {
|
||||
switchUserLocked(userHandle);
|
||||
}
|
||||
}
|
||||
|
||||
private void switchUserLocked(int userHandle) {
|
||||
Set<Integer> currentUserHandles = getEnabledUserHandles(userHandle);
|
||||
if (mEnabledCameraUsers == null || !mEnabledCameraUsers.equals(currentUserHandles)) {
|
||||
// Some user handles have been added or removed, update mediaserver.
|
||||
@@ -82,7 +108,6 @@ public class CameraService extends SystemService {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private Set<Integer> getEnabledUserHandles(int currentUserHandle) {
|
||||
List<UserInfo> userProfiles = mUserManager.getEnabledProfiles(currentUserHandle);
|
||||
Set<Integer> handles = new HashSet<>(userProfiles.size());
|
||||
|
||||
Reference in New Issue
Block a user