Loading libs/binder/TEST_MAPPING +0 −3 Original line number Diff line number Diff line Loading @@ -24,9 +24,6 @@ { "name": "binderLibTest" }, { "name": "binderRpcTest" }, { "name": "binderStabilityTest" }, Loading libs/binder/tests/Android.bp +0 −1 Original line number Diff line number Diff line Loading @@ -154,7 +154,6 @@ cc_test { "binderRpcTestIface-cpp", "binderRpcTestIface-ndk_platform", ], test_suites: ["general-tests"], require_root: true, // Prevent the unit test target from running on sc-dev as it's not ready. test_options: { Loading services/sensorservice/SensorInterface.cpp +1 −19 Original line number Diff line number Diff line Loading @@ -92,31 +92,13 @@ ProximitySensor::ProximitySensor(const sensor_t& sensor, SensorService& service) } status_t ProximitySensor::activate(void* ident, bool enabled) { bool lastState = mSensorDevice.isSensorActive(mSensor.getHandle()); status_t status = HardwareSensor::activate(ident, enabled); if (status != NO_ERROR) { return status; } bool currentState = mSensorDevice.isSensorActive(mSensor.getHandle()); if (currentState != lastState) { mSensorService.onProximityActiveLocked(currentState); } mSensorService.checkAndReportProxStateChangeLocked(); return NO_ERROR; } void ProximitySensor::willDisableAllSensors() { if (mSensorDevice.isSensorActive(mSensor.getHandle())) { mSensorService.onProximityActiveLocked(false); } } void ProximitySensor::didEnableAllSensors() { if (mSensorDevice.isSensorActive(mSensor.getHandle())) { mSensorService.onProximityActiveLocked(true); } } // --------------------------------------------------------------------------- }; // namespace android services/sensorservice/SensorInterface.h +0 −7 Original line number Diff line number Diff line Loading @@ -44,9 +44,6 @@ public: virtual const Sensor& getSensor() const = 0; virtual bool isVirtual() const = 0; virtual void autoDisable(void* /*ident*/, int /*handle*/) = 0; virtual void willDisableAllSensors() = 0; virtual void didEnableAllSensors() = 0; }; class BaseSensor : public SensorInterface { Loading @@ -70,8 +67,6 @@ public: virtual const Sensor& getSensor() const override { return mSensor; } virtual void autoDisable(void* /*ident*/, int /*handle*/) override { } virtual void willDisableAllSensors() override { } virtual void didEnableAllSensors() override { } protected: SensorDevice& mSensorDevice; Sensor mSensor; Loading Loading @@ -115,8 +110,6 @@ public: status_t activate(void* ident, bool enabled) override; void willDisableAllSensors() override; void didEnableAllSensors() override; private: SensorService& mSensorService; }; Loading services/sensorservice/SensorService.cpp +23 −31 Original line number Diff line number Diff line Loading @@ -103,7 +103,7 @@ static const String16 sManageSensorsPermission("android.permission.MANAGE_SENSOR SensorService::SensorService() : mInitCheck(NO_INIT), mSocketBufferSize(SOCKET_BUFFER_SIZE_NON_BATCHED), mWakeLockAcquired(false), mProximityActiveCount(0) { mWakeLockAcquired(false), mLastReportedProxIsActive(false) { mUidPolicy = new UidPolicy(this); mSensorPrivacyPolicy = new SensorPrivacyPolicy(this); } Loading Loading @@ -204,7 +204,9 @@ void SensorService::onFirstRef() { } if (useThisSensor) { if (list[i].type == SENSOR_TYPE_PROXIMITY) { registerSensor(new ProximitySensor(list[i], *this)); SensorInterface* s = new ProximitySensor(list[i], *this); registerSensor(s); mProxSensorHandles.push_back(s->getSensor().getHandle()); } else { registerSensor(new HardwareSensor(list[i])); } Loading Loading @@ -331,6 +333,7 @@ void SensorService::onUidStateChanged(uid_t uid, UidState state) { conn->onSensorAccessChanged(hasAccess); } } checkAndReportProxStateChangeLocked(); } bool SensorService::hasSensorAccess(uid_t uid, const String16& opPackageName) { Loading Loading @@ -680,11 +683,8 @@ void SensorService::disableAllSensorsLocked(ConnectionSafeAutolock* connLock) { bool hasAccess = hasSensorAccessLocked(conn->getUid(), conn->getOpPackageName()); conn->onSensorAccessChanged(hasAccess); } mSensors.forEachEntry([](const SensorServiceUtil::SensorList::Entry& e) { e.si->willDisableAllSensors(); return true; }); dev.disableAllSensors(); checkAndReportProxStateChangeLocked(); // Clear all pending flush connections for all active sensors. If one of the active // connections has called flush() and the underlying sensor has been disabled before a // flush complete event is returned, we need to remove the connection from this queue. Loading @@ -709,14 +709,11 @@ void SensorService::enableAllSensorsLocked(ConnectionSafeAutolock* connLock) { } SensorDevice& dev(SensorDevice::getInstance()); dev.enableAllSensors(); mSensors.forEachEntry([](const SensorServiceUtil::SensorList::Entry& e) { e.si->didEnableAllSensors(); return true; }); for (const sp<SensorDirectConnection>& conn : connLock->getDirectConnections()) { bool hasAccess = hasSensorAccessLocked(conn->getUid(), conn->getOpPackageName()); conn->onSensorAccessChanged(hasAccess); } checkAndReportProxStateChangeLocked(); } void SensorService::capRates(userid_t userId) { Loading Loading @@ -1538,10 +1535,7 @@ status_t SensorService::resetToNormalModeLocked() { if (err == NO_ERROR) { mCurrentOperatingMode = NORMAL; dev.enableAllSensors(); mSensors.forEachEntry([](const SensorServiceUtil::SensorList::Entry& e) { e.si->didEnableAllSensors(); return true; }); checkAndReportProxStateChangeLocked(); } return err; } Loading Loading @@ -1606,28 +1600,26 @@ void SensorService::cleanupConnection(SensorDirectConnection* c) { mConnectionHolder.removeDirectConnection(c); } void SensorService::onProximityActiveLocked(bool isActive) { int prevCount = mProximityActiveCount; bool activeStateChanged = false; if (isActive) { mProximityActiveCount++; activeStateChanged = prevCount == 0; } else { mProximityActiveCount--; if (mProximityActiveCount < 0) { ALOGE("Proximity active count is negative (%d)!", mProximityActiveCount); void SensorService::checkAndReportProxStateChangeLocked() { if (mProxSensorHandles.empty()) return; SensorDevice& dev(SensorDevice::getInstance()); bool isActive = false; for (auto& sensor : mProxSensorHandles) { if (dev.isSensorActive(sensor)) { isActive = true; break; } activeStateChanged = prevCount > 0 && mProximityActiveCount <= 0; } if (activeStateChanged) { notifyProximityStateLocked(mProximityActiveListeners); if (isActive != mLastReportedProxIsActive) { notifyProximityStateLocked(isActive, mProximityActiveListeners); mLastReportedProxIsActive = isActive; } } void SensorService::notifyProximityStateLocked( const bool isActive, const std::vector<sp<ProximityActiveListener>>& listeners) { const bool isActive = mProximityActiveCount > 0; const uint64_t mySeq = ++curProxCallbackSeq; std::thread t([isActive, mySeq, listenersCopy = listeners]() { while (completedCallbackSeq.load() != mySeq - 1) Loading Loading @@ -1655,7 +1647,7 @@ status_t SensorService::addProximityActiveListener(const sp<ProximityActiveListe mProximityActiveListeners.push_back(callback); std::vector<sp<ProximityActiveListener>> listener(1, callback); notifyProximityStateLocked(listener); notifyProximityStateLocked(mLastReportedProxIsActive, listener); return OK; } Loading Loading
libs/binder/TEST_MAPPING +0 −3 Original line number Diff line number Diff line Loading @@ -24,9 +24,6 @@ { "name": "binderLibTest" }, { "name": "binderRpcTest" }, { "name": "binderStabilityTest" }, Loading
libs/binder/tests/Android.bp +0 −1 Original line number Diff line number Diff line Loading @@ -154,7 +154,6 @@ cc_test { "binderRpcTestIface-cpp", "binderRpcTestIface-ndk_platform", ], test_suites: ["general-tests"], require_root: true, // Prevent the unit test target from running on sc-dev as it's not ready. test_options: { Loading
services/sensorservice/SensorInterface.cpp +1 −19 Original line number Diff line number Diff line Loading @@ -92,31 +92,13 @@ ProximitySensor::ProximitySensor(const sensor_t& sensor, SensorService& service) } status_t ProximitySensor::activate(void* ident, bool enabled) { bool lastState = mSensorDevice.isSensorActive(mSensor.getHandle()); status_t status = HardwareSensor::activate(ident, enabled); if (status != NO_ERROR) { return status; } bool currentState = mSensorDevice.isSensorActive(mSensor.getHandle()); if (currentState != lastState) { mSensorService.onProximityActiveLocked(currentState); } mSensorService.checkAndReportProxStateChangeLocked(); return NO_ERROR; } void ProximitySensor::willDisableAllSensors() { if (mSensorDevice.isSensorActive(mSensor.getHandle())) { mSensorService.onProximityActiveLocked(false); } } void ProximitySensor::didEnableAllSensors() { if (mSensorDevice.isSensorActive(mSensor.getHandle())) { mSensorService.onProximityActiveLocked(true); } } // --------------------------------------------------------------------------- }; // namespace android
services/sensorservice/SensorInterface.h +0 −7 Original line number Diff line number Diff line Loading @@ -44,9 +44,6 @@ public: virtual const Sensor& getSensor() const = 0; virtual bool isVirtual() const = 0; virtual void autoDisable(void* /*ident*/, int /*handle*/) = 0; virtual void willDisableAllSensors() = 0; virtual void didEnableAllSensors() = 0; }; class BaseSensor : public SensorInterface { Loading @@ -70,8 +67,6 @@ public: virtual const Sensor& getSensor() const override { return mSensor; } virtual void autoDisable(void* /*ident*/, int /*handle*/) override { } virtual void willDisableAllSensors() override { } virtual void didEnableAllSensors() override { } protected: SensorDevice& mSensorDevice; Sensor mSensor; Loading Loading @@ -115,8 +110,6 @@ public: status_t activate(void* ident, bool enabled) override; void willDisableAllSensors() override; void didEnableAllSensors() override; private: SensorService& mSensorService; }; Loading
services/sensorservice/SensorService.cpp +23 −31 Original line number Diff line number Diff line Loading @@ -103,7 +103,7 @@ static const String16 sManageSensorsPermission("android.permission.MANAGE_SENSOR SensorService::SensorService() : mInitCheck(NO_INIT), mSocketBufferSize(SOCKET_BUFFER_SIZE_NON_BATCHED), mWakeLockAcquired(false), mProximityActiveCount(0) { mWakeLockAcquired(false), mLastReportedProxIsActive(false) { mUidPolicy = new UidPolicy(this); mSensorPrivacyPolicy = new SensorPrivacyPolicy(this); } Loading Loading @@ -204,7 +204,9 @@ void SensorService::onFirstRef() { } if (useThisSensor) { if (list[i].type == SENSOR_TYPE_PROXIMITY) { registerSensor(new ProximitySensor(list[i], *this)); SensorInterface* s = new ProximitySensor(list[i], *this); registerSensor(s); mProxSensorHandles.push_back(s->getSensor().getHandle()); } else { registerSensor(new HardwareSensor(list[i])); } Loading Loading @@ -331,6 +333,7 @@ void SensorService::onUidStateChanged(uid_t uid, UidState state) { conn->onSensorAccessChanged(hasAccess); } } checkAndReportProxStateChangeLocked(); } bool SensorService::hasSensorAccess(uid_t uid, const String16& opPackageName) { Loading Loading @@ -680,11 +683,8 @@ void SensorService::disableAllSensorsLocked(ConnectionSafeAutolock* connLock) { bool hasAccess = hasSensorAccessLocked(conn->getUid(), conn->getOpPackageName()); conn->onSensorAccessChanged(hasAccess); } mSensors.forEachEntry([](const SensorServiceUtil::SensorList::Entry& e) { e.si->willDisableAllSensors(); return true; }); dev.disableAllSensors(); checkAndReportProxStateChangeLocked(); // Clear all pending flush connections for all active sensors. If one of the active // connections has called flush() and the underlying sensor has been disabled before a // flush complete event is returned, we need to remove the connection from this queue. Loading @@ -709,14 +709,11 @@ void SensorService::enableAllSensorsLocked(ConnectionSafeAutolock* connLock) { } SensorDevice& dev(SensorDevice::getInstance()); dev.enableAllSensors(); mSensors.forEachEntry([](const SensorServiceUtil::SensorList::Entry& e) { e.si->didEnableAllSensors(); return true; }); for (const sp<SensorDirectConnection>& conn : connLock->getDirectConnections()) { bool hasAccess = hasSensorAccessLocked(conn->getUid(), conn->getOpPackageName()); conn->onSensorAccessChanged(hasAccess); } checkAndReportProxStateChangeLocked(); } void SensorService::capRates(userid_t userId) { Loading Loading @@ -1538,10 +1535,7 @@ status_t SensorService::resetToNormalModeLocked() { if (err == NO_ERROR) { mCurrentOperatingMode = NORMAL; dev.enableAllSensors(); mSensors.forEachEntry([](const SensorServiceUtil::SensorList::Entry& e) { e.si->didEnableAllSensors(); return true; }); checkAndReportProxStateChangeLocked(); } return err; } Loading Loading @@ -1606,28 +1600,26 @@ void SensorService::cleanupConnection(SensorDirectConnection* c) { mConnectionHolder.removeDirectConnection(c); } void SensorService::onProximityActiveLocked(bool isActive) { int prevCount = mProximityActiveCount; bool activeStateChanged = false; if (isActive) { mProximityActiveCount++; activeStateChanged = prevCount == 0; } else { mProximityActiveCount--; if (mProximityActiveCount < 0) { ALOGE("Proximity active count is negative (%d)!", mProximityActiveCount); void SensorService::checkAndReportProxStateChangeLocked() { if (mProxSensorHandles.empty()) return; SensorDevice& dev(SensorDevice::getInstance()); bool isActive = false; for (auto& sensor : mProxSensorHandles) { if (dev.isSensorActive(sensor)) { isActive = true; break; } activeStateChanged = prevCount > 0 && mProximityActiveCount <= 0; } if (activeStateChanged) { notifyProximityStateLocked(mProximityActiveListeners); if (isActive != mLastReportedProxIsActive) { notifyProximityStateLocked(isActive, mProximityActiveListeners); mLastReportedProxIsActive = isActive; } } void SensorService::notifyProximityStateLocked( const bool isActive, const std::vector<sp<ProximityActiveListener>>& listeners) { const bool isActive = mProximityActiveCount > 0; const uint64_t mySeq = ++curProxCallbackSeq; std::thread t([isActive, mySeq, listenersCopy = listeners]() { while (completedCallbackSeq.load() != mySeq - 1) Loading Loading @@ -1655,7 +1647,7 @@ status_t SensorService::addProximityActiveListener(const sp<ProximityActiveListe mProximityActiveListeners.push_back(callback); std::vector<sp<ProximityActiveListener>> listener(1, callback); notifyProximityStateLocked(listener); notifyProximityStateLocked(mLastReportedProxIsActive, listener); return OK; } Loading