Loading services/core/java/com/android/server/camera/CameraServiceProxy.java +21 −15 Original line number Diff line number Diff line Loading @@ -50,7 +50,7 @@ import java.util.List; import java.util.Set; /** * CameraServiceProxy is the system_server analog to the camera service running in mediaserver. * CameraServiceProxy is the system_server analog to the camera service running in cameraserver. * * @hide */ Loading @@ -74,6 +74,7 @@ public class CameraServiceProxy extends SystemService private static final int MSG_SWITCH_USER = 1; private static final int RETRY_DELAY_TIME = 20; //ms private static final int RETRY_TIMES = 30; // Maximum entries to keep in usage history before dumping out private static final int MAX_USAGE_HISTORY = 100; Loading Loading @@ -171,7 +172,7 @@ public class CameraServiceProxy extends SystemService " camera service UID!"); return; } notifySwitchWithRetries(30); notifySwitchWithRetries(RETRY_TIMES); } @Override Loading Loading @@ -242,7 +243,8 @@ public class CameraServiceProxy extends SystemService public void onStartUser(int userHandle) { synchronized(mLock) { if (mEnabledCameraUsers == null) { // Initialize mediaserver, or update mediaserver if we are recovering from a crash. // Initialize cameraserver, or update cameraserver if we are recovering // from a crash. switchUserLocked(userHandle); } } Loading Loading @@ -324,9 +326,9 @@ public class CameraServiceProxy extends SystemService Set<Integer> currentUserHandles = getEnabledUserHandles(userHandle); mLastUser = userHandle; if (mEnabledCameraUsers == null || !mEnabledCameraUsers.equals(currentUserHandles)) { // Some user handles have been added or removed, update mediaserver. // Some user handles have been added or removed, update cameraserver. mEnabledCameraUsers = currentUserHandles; notifyMediaserverLocked(ICameraService.EVENT_USER_SWITCHED, currentUserHandles); notifySwitchWithRetriesLocked(RETRY_TIMES); } } Loading @@ -343,13 +345,17 @@ public class CameraServiceProxy extends SystemService private void notifySwitchWithRetries(int retries) { synchronized(mLock) { notifySwitchWithRetriesLocked(retries); } } private void notifySwitchWithRetriesLocked(int retries) { if (mEnabledCameraUsers == null) { return; } if (notifyMediaserverLocked(ICameraService.EVENT_USER_SWITCHED, mEnabledCameraUsers)) { if (notifyCameraserverLocked(ICameraService.EVENT_USER_SWITCHED, mEnabledCameraUsers)) { retries = 0; } } if (retries <= 0) { return; } Loading @@ -358,13 +364,13 @@ public class CameraServiceProxy extends SystemService RETRY_DELAY_TIME); } private boolean notifyMediaserverLocked(int eventType, Set<Integer> updatedUserHandles) { // Forward the user switch event to the native camera service running in the mediaserver private boolean notifyCameraserverLocked(int eventType, Set<Integer> updatedUserHandles) { // Forward the user switch event to the native camera service running in the cameraserver // process. if (mCameraServiceRaw == null) { IBinder cameraServiceBinder = getBinderService(CAMERA_SERVICE_BINDER_NAME); if (cameraServiceBinder == null) { Slog.w(TAG, "Could not notify mediaserver, camera service not available."); Slog.w(TAG, "Could not notify cameraserver, camera service not available."); return false; // Camera service not active, cannot evict user clients. } try { Loading @@ -380,7 +386,7 @@ public class CameraServiceProxy extends SystemService try { mCameraServiceRaw.notifySystemEvent(eventType, toArray(updatedUserHandles)); } catch (RemoteException e) { Slog.w(TAG, "Could not notify mediaserver, remote exception: " + e); Slog.w(TAG, "Could not notify cameraserver, remote exception: " + e); // Not much we can do if camera service is dead. return false; } Loading Loading
services/core/java/com/android/server/camera/CameraServiceProxy.java +21 −15 Original line number Diff line number Diff line Loading @@ -50,7 +50,7 @@ import java.util.List; import java.util.Set; /** * CameraServiceProxy is the system_server analog to the camera service running in mediaserver. * CameraServiceProxy is the system_server analog to the camera service running in cameraserver. * * @hide */ Loading @@ -74,6 +74,7 @@ public class CameraServiceProxy extends SystemService private static final int MSG_SWITCH_USER = 1; private static final int RETRY_DELAY_TIME = 20; //ms private static final int RETRY_TIMES = 30; // Maximum entries to keep in usage history before dumping out private static final int MAX_USAGE_HISTORY = 100; Loading Loading @@ -171,7 +172,7 @@ public class CameraServiceProxy extends SystemService " camera service UID!"); return; } notifySwitchWithRetries(30); notifySwitchWithRetries(RETRY_TIMES); } @Override Loading Loading @@ -242,7 +243,8 @@ public class CameraServiceProxy extends SystemService public void onStartUser(int userHandle) { synchronized(mLock) { if (mEnabledCameraUsers == null) { // Initialize mediaserver, or update mediaserver if we are recovering from a crash. // Initialize cameraserver, or update cameraserver if we are recovering // from a crash. switchUserLocked(userHandle); } } Loading Loading @@ -324,9 +326,9 @@ public class CameraServiceProxy extends SystemService Set<Integer> currentUserHandles = getEnabledUserHandles(userHandle); mLastUser = userHandle; if (mEnabledCameraUsers == null || !mEnabledCameraUsers.equals(currentUserHandles)) { // Some user handles have been added or removed, update mediaserver. // Some user handles have been added or removed, update cameraserver. mEnabledCameraUsers = currentUserHandles; notifyMediaserverLocked(ICameraService.EVENT_USER_SWITCHED, currentUserHandles); notifySwitchWithRetriesLocked(RETRY_TIMES); } } Loading @@ -343,13 +345,17 @@ public class CameraServiceProxy extends SystemService private void notifySwitchWithRetries(int retries) { synchronized(mLock) { notifySwitchWithRetriesLocked(retries); } } private void notifySwitchWithRetriesLocked(int retries) { if (mEnabledCameraUsers == null) { return; } if (notifyMediaserverLocked(ICameraService.EVENT_USER_SWITCHED, mEnabledCameraUsers)) { if (notifyCameraserverLocked(ICameraService.EVENT_USER_SWITCHED, mEnabledCameraUsers)) { retries = 0; } } if (retries <= 0) { return; } Loading @@ -358,13 +364,13 @@ public class CameraServiceProxy extends SystemService RETRY_DELAY_TIME); } private boolean notifyMediaserverLocked(int eventType, Set<Integer> updatedUserHandles) { // Forward the user switch event to the native camera service running in the mediaserver private boolean notifyCameraserverLocked(int eventType, Set<Integer> updatedUserHandles) { // Forward the user switch event to the native camera service running in the cameraserver // process. if (mCameraServiceRaw == null) { IBinder cameraServiceBinder = getBinderService(CAMERA_SERVICE_BINDER_NAME); if (cameraServiceBinder == null) { Slog.w(TAG, "Could not notify mediaserver, camera service not available."); Slog.w(TAG, "Could not notify cameraserver, camera service not available."); return false; // Camera service not active, cannot evict user clients. } try { Loading @@ -380,7 +386,7 @@ public class CameraServiceProxy extends SystemService try { mCameraServiceRaw.notifySystemEvent(eventType, toArray(updatedUserHandles)); } catch (RemoteException e) { Slog.w(TAG, "Could not notify mediaserver, remote exception: " + e); Slog.w(TAG, "Could not notify cameraserver, remote exception: " + e); // Not much we can do if camera service is dead. return false; } Loading