Loading include/android/multinetwork.h +2 −2 Original line number Diff line number Diff line Loading @@ -126,8 +126,8 @@ enum ResNsendFlags : uint32_t { ANDROID_RESOLV_NO_RETRY = 1 << 0, /** * Do not cache the result of the lookup. The lookup may return a result that is already * in the cache, unless the ANDROID_RESOLV_NO_CACHE_LOOKUP flag is also specified. * Don't lookup this request in the cache, and don't cache the result of the lookup. * This flag implies {@link #ANDROID_RESOLV_NO_CACHE_LOOKUP}. */ ANDROID_RESOLV_NO_CACHE_STORE = 1 << 1, Loading libs/gui/Surface.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -110,7 +110,7 @@ Surface::Surface(const sp<IGraphicBufferProducer>& bufferProducer, bool controll mConnectedToCpu = false; mProducerControlledByApp = controlledByApp; mSwapIntervalZero = false; mMaxBufferCount = 0; mMaxBufferCount = NUM_BUFFER_SLOTS; } Surface::~Surface() { Loading Loading @@ -1585,6 +1585,7 @@ int Surface::disconnect(int api, IGraphicBufferProducer::DisconnectMode mode) { mStickyTransform = 0; mAutoPrerotation = false; mEnableFrameTimestamps = false; mMaxBufferCount = NUM_BUFFER_SLOTS; if (api == NATIVE_WINDOW_API_CPU) { mConnectedToCpu = false; Loading libs/gui/tests/EndToEndNativeInputTest.cpp +24 −0 Original line number Diff line number Diff line Loading @@ -104,6 +104,15 @@ public: return std::make_unique<InputSurface>(surfaceControl, width, height); } static std::unique_ptr<InputSurface> makeCursorInputSurface( const sp<SurfaceComposerClient> &scc, int width, int height) { sp<SurfaceControl> surfaceControl = scc->createSurface(String8("Test Cursor Surface"), 0 /* bufHeight */, 0 /* bufWidth */, PIXEL_FORMAT_RGBA_8888, ISurfaceComposerClient::eCursorWindow); return std::make_unique<InputSurface>(surfaceControl, width, height); } InputEvent* consumeEvent() { waitForEventAvailable(); Loading Loading @@ -134,12 +143,14 @@ public: EXPECT_EQ(AMOTION_EVENT_ACTION_DOWN, mev->getAction()); EXPECT_EQ(x, mev->getX(0)); EXPECT_EQ(y, mev->getY(0)); EXPECT_EQ(0, mev->getFlags() & VERIFIED_MOTION_EVENT_FLAGS); ev = consumeEvent(); ASSERT_NE(ev, nullptr); ASSERT_EQ(AINPUT_EVENT_TYPE_MOTION, ev->getType()); mev = static_cast<MotionEvent*>(ev); EXPECT_EQ(AMOTION_EVENT_ACTION_UP, mev->getAction()); EXPECT_EQ(0, mev->getFlags() & VERIFIED_MOTION_EVENT_FLAGS); } ~InputSurface() { Loading Loading @@ -537,5 +548,18 @@ TEST_F(InputSurfacesTest, input_respects_outscreen) { injectTap(0, 0); surface->expectTap(1, 1); } TEST_F(InputSurfacesTest, input_ignores_cursor_layer) { std::unique_ptr<InputSurface> surface = makeSurface(100, 100); std::unique_ptr<InputSurface> cursorSurface = InputSurface::makeCursorInputSurface(mComposerClient, 10, 10); surface->showAt(10, 10); surface->assertFocusChange(true); cursorSurface->showAt(10, 10); injectTap(11, 11); surface->expectTap(1, 1); } } } libs/gui/tests/Surface_test.cpp +26 −0 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ #include <gui/SurfaceComposerClient.h> #include <inttypes.h> #include <private/gui/ComposerService.h> #include <ui/BufferQueueDefs.h> #include <ui/Rect.h> #include <utils/String8.h> Loading Loading @@ -1974,4 +1975,29 @@ TEST_F(SurfaceTest, DequeueWithConsumerDrivenSize) { ASSERT_EQ(NO_ERROR, window->cancelBuffer(window.get(), buffer, fence)); } TEST_F(SurfaceTest, DefaultMaxBufferCountSetAndUpdated) { sp<IGraphicBufferProducer> producer; sp<IGraphicBufferConsumer> consumer; BufferQueue::createBufferQueue(&producer, &consumer); sp<DummyConsumer> dummyConsumer(new DummyConsumer); consumer->consumerConnect(dummyConsumer, false); sp<Surface> surface = new Surface(producer); sp<ANativeWindow> window(surface); int count = -1; ASSERT_EQ(NO_ERROR, window->query(window.get(), NATIVE_WINDOW_MAX_BUFFER_COUNT, &count)); EXPECT_EQ(BufferQueueDefs::NUM_BUFFER_SLOTS, count); consumer->setMaxBufferCount(10); ASSERT_EQ(NO_ERROR, native_window_api_connect(window.get(), NATIVE_WINDOW_API_CPU)); EXPECT_EQ(NO_ERROR, window->query(window.get(), NATIVE_WINDOW_MAX_BUFFER_COUNT, &count)); EXPECT_EQ(10, count); ASSERT_EQ(NO_ERROR, native_window_api_disconnect(window.get(), NATIVE_WINDOW_API_CPU)); ASSERT_EQ(NO_ERROR, window->query(window.get(), NATIVE_WINDOW_MAX_BUFFER_COUNT, &count)); EXPECT_EQ(BufferQueueDefs::NUM_BUFFER_SLOTS, count); } } // namespace android services/sensorservice/SensorEventConnection.cpp +12 −2 Original line number Diff line number Diff line Loading @@ -37,6 +37,7 @@ SensorService::SensorEventConnection::SensorEventConnection( mCacheSize(0), mMaxCacheSize(0), mTimeOfLastEventDrop(0), mEventsDropped(0), mPackageName(packageName), mOpPackageName(opPackageName), mDestroyed(false) { mChannel = new BitTube(mService->mSocketBufferSize); mTargetSdk = SensorService::getTargetSdkVersion(opPackageName); #if DEBUG_CONNECTIONS mEventsReceived = mEventsSentFromCache = mEventsSent = 0; mTotalAcksNeeded = mTotalAcksReceived = 0; Loading Loading @@ -439,9 +440,18 @@ bool SensorService::SensorEventConnection::noteOpIfRequired(const sensors_event_ bool success = true; const auto iter = mHandleToAppOp.find(event.sensor); if (iter != mHandleToAppOp.end()) { int32_t appOpMode = mService->sAppOpsManager.noteOp((*iter).second, mUid, mOpPackageName); // Special handling for step count/detect backwards compatibility: if the app's target SDK // is pre-Q, still permit delivering events to the app even if permission isn't granted // (since this permission was only introduced in Q) if ((event.type == SENSOR_TYPE_STEP_COUNTER || event.type == SENSOR_TYPE_STEP_DETECTOR) && mTargetSdk > 0 && mTargetSdk <= __ANDROID_API_P__) { success = true; } else { int32_t appOpMode = mService->sAppOpsManager.noteOp(iter->second, mUid, mOpPackageName); success = (appOpMode == AppOpsManager::MODE_ALLOWED); } } return success; } Loading Loading
include/android/multinetwork.h +2 −2 Original line number Diff line number Diff line Loading @@ -126,8 +126,8 @@ enum ResNsendFlags : uint32_t { ANDROID_RESOLV_NO_RETRY = 1 << 0, /** * Do not cache the result of the lookup. The lookup may return a result that is already * in the cache, unless the ANDROID_RESOLV_NO_CACHE_LOOKUP flag is also specified. * Don't lookup this request in the cache, and don't cache the result of the lookup. * This flag implies {@link #ANDROID_RESOLV_NO_CACHE_LOOKUP}. */ ANDROID_RESOLV_NO_CACHE_STORE = 1 << 1, Loading
libs/gui/Surface.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -110,7 +110,7 @@ Surface::Surface(const sp<IGraphicBufferProducer>& bufferProducer, bool controll mConnectedToCpu = false; mProducerControlledByApp = controlledByApp; mSwapIntervalZero = false; mMaxBufferCount = 0; mMaxBufferCount = NUM_BUFFER_SLOTS; } Surface::~Surface() { Loading Loading @@ -1585,6 +1585,7 @@ int Surface::disconnect(int api, IGraphicBufferProducer::DisconnectMode mode) { mStickyTransform = 0; mAutoPrerotation = false; mEnableFrameTimestamps = false; mMaxBufferCount = NUM_BUFFER_SLOTS; if (api == NATIVE_WINDOW_API_CPU) { mConnectedToCpu = false; Loading
libs/gui/tests/EndToEndNativeInputTest.cpp +24 −0 Original line number Diff line number Diff line Loading @@ -104,6 +104,15 @@ public: return std::make_unique<InputSurface>(surfaceControl, width, height); } static std::unique_ptr<InputSurface> makeCursorInputSurface( const sp<SurfaceComposerClient> &scc, int width, int height) { sp<SurfaceControl> surfaceControl = scc->createSurface(String8("Test Cursor Surface"), 0 /* bufHeight */, 0 /* bufWidth */, PIXEL_FORMAT_RGBA_8888, ISurfaceComposerClient::eCursorWindow); return std::make_unique<InputSurface>(surfaceControl, width, height); } InputEvent* consumeEvent() { waitForEventAvailable(); Loading Loading @@ -134,12 +143,14 @@ public: EXPECT_EQ(AMOTION_EVENT_ACTION_DOWN, mev->getAction()); EXPECT_EQ(x, mev->getX(0)); EXPECT_EQ(y, mev->getY(0)); EXPECT_EQ(0, mev->getFlags() & VERIFIED_MOTION_EVENT_FLAGS); ev = consumeEvent(); ASSERT_NE(ev, nullptr); ASSERT_EQ(AINPUT_EVENT_TYPE_MOTION, ev->getType()); mev = static_cast<MotionEvent*>(ev); EXPECT_EQ(AMOTION_EVENT_ACTION_UP, mev->getAction()); EXPECT_EQ(0, mev->getFlags() & VERIFIED_MOTION_EVENT_FLAGS); } ~InputSurface() { Loading Loading @@ -537,5 +548,18 @@ TEST_F(InputSurfacesTest, input_respects_outscreen) { injectTap(0, 0); surface->expectTap(1, 1); } TEST_F(InputSurfacesTest, input_ignores_cursor_layer) { std::unique_ptr<InputSurface> surface = makeSurface(100, 100); std::unique_ptr<InputSurface> cursorSurface = InputSurface::makeCursorInputSurface(mComposerClient, 10, 10); surface->showAt(10, 10); surface->assertFocusChange(true); cursorSurface->showAt(10, 10); injectTap(11, 11); surface->expectTap(1, 1); } } }
libs/gui/tests/Surface_test.cpp +26 −0 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ #include <gui/SurfaceComposerClient.h> #include <inttypes.h> #include <private/gui/ComposerService.h> #include <ui/BufferQueueDefs.h> #include <ui/Rect.h> #include <utils/String8.h> Loading Loading @@ -1974,4 +1975,29 @@ TEST_F(SurfaceTest, DequeueWithConsumerDrivenSize) { ASSERT_EQ(NO_ERROR, window->cancelBuffer(window.get(), buffer, fence)); } TEST_F(SurfaceTest, DefaultMaxBufferCountSetAndUpdated) { sp<IGraphicBufferProducer> producer; sp<IGraphicBufferConsumer> consumer; BufferQueue::createBufferQueue(&producer, &consumer); sp<DummyConsumer> dummyConsumer(new DummyConsumer); consumer->consumerConnect(dummyConsumer, false); sp<Surface> surface = new Surface(producer); sp<ANativeWindow> window(surface); int count = -1; ASSERT_EQ(NO_ERROR, window->query(window.get(), NATIVE_WINDOW_MAX_BUFFER_COUNT, &count)); EXPECT_EQ(BufferQueueDefs::NUM_BUFFER_SLOTS, count); consumer->setMaxBufferCount(10); ASSERT_EQ(NO_ERROR, native_window_api_connect(window.get(), NATIVE_WINDOW_API_CPU)); EXPECT_EQ(NO_ERROR, window->query(window.get(), NATIVE_WINDOW_MAX_BUFFER_COUNT, &count)); EXPECT_EQ(10, count); ASSERT_EQ(NO_ERROR, native_window_api_disconnect(window.get(), NATIVE_WINDOW_API_CPU)); ASSERT_EQ(NO_ERROR, window->query(window.get(), NATIVE_WINDOW_MAX_BUFFER_COUNT, &count)); EXPECT_EQ(BufferQueueDefs::NUM_BUFFER_SLOTS, count); } } // namespace android
services/sensorservice/SensorEventConnection.cpp +12 −2 Original line number Diff line number Diff line Loading @@ -37,6 +37,7 @@ SensorService::SensorEventConnection::SensorEventConnection( mCacheSize(0), mMaxCacheSize(0), mTimeOfLastEventDrop(0), mEventsDropped(0), mPackageName(packageName), mOpPackageName(opPackageName), mDestroyed(false) { mChannel = new BitTube(mService->mSocketBufferSize); mTargetSdk = SensorService::getTargetSdkVersion(opPackageName); #if DEBUG_CONNECTIONS mEventsReceived = mEventsSentFromCache = mEventsSent = 0; mTotalAcksNeeded = mTotalAcksReceived = 0; Loading Loading @@ -439,9 +440,18 @@ bool SensorService::SensorEventConnection::noteOpIfRequired(const sensors_event_ bool success = true; const auto iter = mHandleToAppOp.find(event.sensor); if (iter != mHandleToAppOp.end()) { int32_t appOpMode = mService->sAppOpsManager.noteOp((*iter).second, mUid, mOpPackageName); // Special handling for step count/detect backwards compatibility: if the app's target SDK // is pre-Q, still permit delivering events to the app even if permission isn't granted // (since this permission was only introduced in Q) if ((event.type == SENSOR_TYPE_STEP_COUNTER || event.type == SENSOR_TYPE_STEP_DETECTOR) && mTargetSdk > 0 && mTargetSdk <= __ANDROID_API_P__) { success = true; } else { int32_t appOpMode = mService->sAppOpsManager.noteOp(iter->second, mUid, mOpPackageName); success = (appOpMode == AppOpsManager::MODE_ALLOWED); } } return success; } Loading