Loading services/audiopolicy/service/AudioPolicyService.cpp +23 −0 Original line number Diff line number Diff line Loading @@ -529,6 +529,11 @@ void AudioPolicyService::updateUidStates_l() for (size_t i =0; i < mAudioRecordClients.size(); i++) { sp<AudioRecordClient> current = mAudioRecordClients[i]; if (!isVirtualSource(current->attributes.source) && isUserSensorPrivacyEnabledForUid(current->uid)) { setAppState_l(current->portId, APP_STATE_IDLE); continue; } if (!current->active) { continue; } Loading Loading @@ -978,6 +983,16 @@ status_t AudioPolicyService::handleGetUidState(Vector<String16>& args, int out, return NO_INIT; } bool AudioPolicyService::isUserSensorPrivacyEnabledForUid(uid_t uid) { userid_t userId = multiuser_get_user_id(uid); if (mMicrophoneSensorPrivacyPolicies.find(userId) == mMicrophoneSensorPrivacyPolicies.end()) { sp<SensorPrivacyPolicy> userPolicy = new SensorPrivacyPolicy(this); userPolicy->registerSelfForMicrophoneOnly(userId); mMicrophoneSensorPrivacyPolicies[userId] = userPolicy; } return mMicrophoneSensorPrivacyPolicies[userId]->isSensorPrivacyEnabled(); } status_t AudioPolicyService::printHelp(int out) { return dprintf(out, "Audio policy service commands:\n" " get-uid-state <PACKAGE> [--user USER_ID] gets the uid state\n" Loading Loading @@ -1211,6 +1226,14 @@ void AudioPolicyService::SensorPrivacyPolicy::registerSelf() { spm.addSensorPrivacyListener(this); } void AudioPolicyService::SensorPrivacyPolicy::registerSelfForMicrophoneOnly(int userId) { SensorPrivacyManager spm; mSensorPrivacyEnabled = spm.isIndividualSensorPrivacyEnabled(userId, SensorPrivacyManager::INDIVIDUAL_SENSOR_MICROPHONE); spm.addIndividualSensorPrivacyListener(userId, SensorPrivacyManager::INDIVIDUAL_SENSOR_MICROPHONE, this); } void AudioPolicyService::SensorPrivacyPolicy::unregisterSelf() { SensorPrivacyManager spm; spm.removeSensorPrivacyListener(this); Loading services/audiopolicy/service/AudioPolicyService.h +5 −0 Original line number Diff line number Diff line Loading @@ -304,6 +304,8 @@ public: virtual status_t setRttEnabled(bool enabled); virtual bool isUserSensorPrivacyEnabledForUid(uid_t uid); bool isCallScreenModeSupported() override; void doOnNewAudioModulesAvailable(); Loading Loading @@ -466,6 +468,7 @@ private: : mService(service) {} void registerSelf(); void registerSelfForMicrophoneOnly(int userId); void unregisterSelf(); bool isSensorPrivacyEnabled(); Loading Loading @@ -939,6 +942,8 @@ private: MediaPackageManager mPackageManager; // To check allowPlaybackCapture CaptureStateNotifier mCaptureStateNotifier; std::map<userid_t, sp<SensorPrivacyPolicy>> mMicrophoneSensorPrivacyPolicies; }; } // namespace android Loading Loading
services/audiopolicy/service/AudioPolicyService.cpp +23 −0 Original line number Diff line number Diff line Loading @@ -529,6 +529,11 @@ void AudioPolicyService::updateUidStates_l() for (size_t i =0; i < mAudioRecordClients.size(); i++) { sp<AudioRecordClient> current = mAudioRecordClients[i]; if (!isVirtualSource(current->attributes.source) && isUserSensorPrivacyEnabledForUid(current->uid)) { setAppState_l(current->portId, APP_STATE_IDLE); continue; } if (!current->active) { continue; } Loading Loading @@ -978,6 +983,16 @@ status_t AudioPolicyService::handleGetUidState(Vector<String16>& args, int out, return NO_INIT; } bool AudioPolicyService::isUserSensorPrivacyEnabledForUid(uid_t uid) { userid_t userId = multiuser_get_user_id(uid); if (mMicrophoneSensorPrivacyPolicies.find(userId) == mMicrophoneSensorPrivacyPolicies.end()) { sp<SensorPrivacyPolicy> userPolicy = new SensorPrivacyPolicy(this); userPolicy->registerSelfForMicrophoneOnly(userId); mMicrophoneSensorPrivacyPolicies[userId] = userPolicy; } return mMicrophoneSensorPrivacyPolicies[userId]->isSensorPrivacyEnabled(); } status_t AudioPolicyService::printHelp(int out) { return dprintf(out, "Audio policy service commands:\n" " get-uid-state <PACKAGE> [--user USER_ID] gets the uid state\n" Loading Loading @@ -1211,6 +1226,14 @@ void AudioPolicyService::SensorPrivacyPolicy::registerSelf() { spm.addSensorPrivacyListener(this); } void AudioPolicyService::SensorPrivacyPolicy::registerSelfForMicrophoneOnly(int userId) { SensorPrivacyManager spm; mSensorPrivacyEnabled = spm.isIndividualSensorPrivacyEnabled(userId, SensorPrivacyManager::INDIVIDUAL_SENSOR_MICROPHONE); spm.addIndividualSensorPrivacyListener(userId, SensorPrivacyManager::INDIVIDUAL_SENSOR_MICROPHONE, this); } void AudioPolicyService::SensorPrivacyPolicy::unregisterSelf() { SensorPrivacyManager spm; spm.removeSensorPrivacyListener(this); Loading
services/audiopolicy/service/AudioPolicyService.h +5 −0 Original line number Diff line number Diff line Loading @@ -304,6 +304,8 @@ public: virtual status_t setRttEnabled(bool enabled); virtual bool isUserSensorPrivacyEnabledForUid(uid_t uid); bool isCallScreenModeSupported() override; void doOnNewAudioModulesAvailable(); Loading Loading @@ -466,6 +468,7 @@ private: : mService(service) {} void registerSelf(); void registerSelfForMicrophoneOnly(int userId); void unregisterSelf(); bool isSensorPrivacyEnabled(); Loading Loading @@ -939,6 +942,8 @@ private: MediaPackageManager mPackageManager; // To check allowPlaybackCapture CaptureStateNotifier mCaptureStateNotifier; std::map<userid_t, sp<SensorPrivacyPolicy>> mMicrophoneSensorPrivacyPolicies; }; } // namespace android Loading