From 6267b539d0d1ee7118aafd976d75cb8db397bc24 Mon Sep 17 00:00:00 2001 From: Ruben Brunk Date: Thu, 30 Apr 2015 17:44:07 -0700 Subject: camera2: Fix work-profile eviction handling. Bug: 20124384 Change-Id: I6fb82dbfd5f98746ed4befed81a583e3709bfee8 --- services/camera/libcameraservice/CameraService.h | 34 ++++++++++-------------- 1 file changed, 14 insertions(+), 20 deletions(-) (limited to 'services/camera/libcameraservice/CameraService.h') diff --git a/services/camera/libcameraservice/CameraService.h b/services/camera/libcameraservice/CameraService.h index 1041550..9b7163a 100644 --- a/services/camera/libcameraservice/CameraService.h +++ b/services/camera/libcameraservice/CameraService.h @@ -83,11 +83,6 @@ public: // Default number of messages to store in eviction log static const size_t DEFAULT_EVENT_LOG_LENGTH = 100; - enum { - // Default last user id - DEFAULT_LAST_USER_ID = 0, - }; - // Implementation of BinderService static char const* getServiceName() { return "media.camera"; } @@ -141,7 +136,7 @@ public: virtual status_t setTorchMode(const String16& cameraId, bool enabled, const sp& clientBinder); - virtual void notifySystemEvent(int eventId, int arg0); + virtual void notifySystemEvent(int32_t eventId, const int32_t* args, size_t length); // OK = supports api of that version, -EOPNOTSUPP = does not support virtual status_t supportsCameraApi( @@ -200,6 +195,9 @@ public: virtual void notifyError(ICameraDeviceCallbacks::CameraErrorCode errorCode, const CaptureResultExtras& resultExtras) = 0; + // Get the UID of the application client using this + virtual uid_t getClientUid() const; + // Get the PID of the application client using this virtual int getClientPid() const; @@ -469,7 +467,6 @@ private: const String16& clientPackageName, int clientUid, apiLevel effectiveApiLevel, bool legacyMode, bool shimUpdateOnly, /*out*/sp& device); - // Lock guarding camera service state Mutex mServiceLock; @@ -492,8 +489,8 @@ private: RingBuffer mEventLog; Mutex mLogLock; - // UID of last user. - int mLastUserId; + // Currently allowed user IDs + std::set mAllowedUsers; /** * Get the camera state for a given camera id. @@ -542,7 +539,7 @@ private: /** * Handle a notification that the current device user has changed. */ - void doUserSwitch(int newUserId); + void doUserSwitch(const int32_t* newUserId, size_t length); /** * Add an event log message. @@ -568,7 +565,8 @@ private: /** * Add an event log message that the current device user has been switched. */ - void logUserSwitch(int oldUserId, int newUserId); + void logUserSwitch(const std::set& oldUserIds, + const std::set& newUserIds); /** * Add an event log message that a device has been removed by the HAL @@ -699,6 +697,11 @@ private: int facing, int clientPid, uid_t clientUid, int servicePid, bool legacyMode, int halVersion, int deviceVersion, apiLevel effectiveApiLevel, /*out*/sp* client); + + status_t checkCameraAccess(const String16& opPackageName); + + static String8 toString(std::set intSet); + }; template @@ -775,15 +778,6 @@ status_t CameraService::connectHelper(const sp& cameraCb, const String if((ret = validateConnectLocked(cameraId, /*inout*/clientUid)) != NO_ERROR) { return ret; } - int userId = multiuser_get_user_id(clientUid); - - if (userId != mLastUserId && clientPid != getpid() ) { - // If no previous user ID had been set, set to the user of the caller. - logUserSwitch(mLastUserId, userId); - LOG_ALWAYS_FATAL_IF(mLastUserId != DEFAULT_LAST_USER_ID, - "Invalid state: Should never update user ID here unless was default"); - mLastUserId = userId; - } // Check the shim parameters after acquiring lock, if they have already been updated and // we were doing a shim update, return immediately -- cgit v1.1