From e26d821f071a6352161c1e4962da20ed22d23584 Mon Sep 17 00:00:00 2001 From: hmz007 Date: Fri, 25 Jul 2025 16:01:23 +0800 Subject: [PATCH] frameworks/native: merge commit '7d5047bc50..8cd7584f6d' Signed-off-by: hmz007 --- .../native/cmds/dumpstate/dumpstate.cpp | 31 +++++++++---------- .../native/cmds/servicemanager/main.cpp | 1 + frameworks/native/libs/input/Android.bp | 6 ++++ .../native/libs/input/InputVerifier.cpp | 4 ++- .../native/libs/input/input_verifier.rs | 24 +++++++++++--- .../dispatcher/InputDispatcher.cpp | 19 ++++++++---- .../inputflinger/dispatcher/InputDispatcher.h | 4 +-- .../CompositionEngine/src/OutputLayer.cpp | 16 +++++++--- .../native/services/surfaceflinger/Layer.cpp | 13 +++++++- .../surfaceflinger/SurfaceFlinger.cpp | 13 ++++++++ 10 files changed, 97 insertions(+), 34 deletions(-) diff --git a/frameworks/native/cmds/dumpstate/dumpstate.cpp b/frameworks/native/cmds/dumpstate/dumpstate.cpp index 7551d88adef..60295a4e58a 100644 --- a/frameworks/native/cmds/dumpstate/dumpstate.cpp +++ b/frameworks/native/cmds/dumpstate/dumpstate.cpp @@ -3491,6 +3491,21 @@ Dumpstate::RunStatus Dumpstate::RunInternal(int32_t calling_uid, need_change_prio = false; } + if (ds.options_->android_dump_demand || ds.options_->last_panic_dump) { + std::string destination = ds.CalledByApi() + ? StringPrintf("[fd:%d]", ds.options_->bugreport_fd.get()) + : ds.bugreport_internal_dir_.c_str(); + long long int max_log_size = (long long int)android::base::GetIntProperty("dumpstate.max_log_size", 300); + if (max_log_size <= 0) + max_log_size = 300; + long long int total_size = GetDirectorySize((char *)destination.c_str()); + MYLOGI("total_size (%lld), max log size is %lld\n", total_size, (max_log_size << 20)); + if (total_size >= (max_log_size << 20)) { + DelEarliestTwoBugreport(destination); + total_size = GetDirectorySize((char *)destination.c_str()); + } + } + if (options_->android_dump_demand) { android_bugrepot_reason = android::base::GetProperty("sys.bugreport_reason", "unknown"); android_dropbox_time = android::base::GetProperty("sys.bugreport_time", "0"); @@ -3770,22 +3785,6 @@ Dumpstate::RunStatus Dumpstate::RunInternal(int32_t calling_uid, anr_data_.clear(); shutdown_checkpoints_.clear(); - //----rk-change---- - if (ds.options_->android_dump_demand || ds.options_->last_panic_dump) { - std::string destination = ds.CalledByApi() - ? StringPrintf("[fd:%d]", ds.options_->bugreport_fd.get()) - : ds.bugreport_internal_dir_.c_str(); - long long int max_log_size = (long long int)android::base::GetIntProperty("dumpstate.max_log_size", 300); - if (max_log_size <= 0) - max_log_size = 300; - long long int total_size = GetDirectorySize((char *)destination.c_str()); - MYLOGI("total_size (%lld), max log size is %lld\n", total_size, (max_log_size << 20)); - if (total_size >= (max_log_size << 20)) { - DelEarliestTwoBugreport(destination); - total_size = GetDirectorySize((char *)destination.c_str()); - } - } - //--------------- return (consent_callback_ != nullptr && consent_callback_->getResult() == UserConsentResult::UNAVAILABLE) ? USER_CONSENT_TIMED_OUT diff --git a/frameworks/native/cmds/servicemanager/main.cpp b/frameworks/native/cmds/servicemanager/main.cpp index bc9cb1609d2..3e9b7b938ff 100644 --- a/frameworks/native/cmds/servicemanager/main.cpp +++ b/frameworks/native/cmds/servicemanager/main.cpp @@ -128,6 +128,7 @@ int main(int argc, char** argv) { IPCThreadState::self()->disableBackgroundScheduling(true); sp manager = sp::make(std::make_unique()); + manager->setRequestingSid(true); if (!manager->addService("manager", manager, false /*allowIsolated*/, IServiceManager::DUMP_FLAG_PRIORITY_DEFAULT).isOk()) { LOG(ERROR) << "Could not self register servicemanager"; } diff --git a/frameworks/native/libs/input/Android.bp b/frameworks/native/libs/input/Android.bp index 022dfaddc18..4a13e2d8713 100644 --- a/frameworks/native/libs/input/Android.bp +++ b/frameworks/native/libs/input/Android.bp @@ -65,6 +65,12 @@ rust_bindgen { bindgen_flags: [ "--verbose", "--allowlist-var=AMOTION_EVENT_FLAG_CANCELED", + //------rk add start------ + "--allowlist-var=AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED", + "--allowlist-var=AMOTION_EVENT_FLAG_WINDOW_IS_PARTIALLY_OBSCURED", + "--allowlist-var=AMOTION_EVENT_FLAG_IS_ACCESSIBILITY_EVENT", + "--allowlist-var=AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE", + //------rk add end------ "--allowlist-var=AMOTION_EVENT_ACTION_CANCEL", "--allowlist-var=AMOTION_EVENT_ACTION_UP", "--allowlist-var=AMOTION_EVENT_ACTION_POINTER_DOWN", diff --git a/frameworks/native/libs/input/InputVerifier.cpp b/frameworks/native/libs/input/InputVerifier.cpp index 9745e892344..634eab31068 100644 --- a/frameworks/native/libs/input/InputVerifier.cpp +++ b/frameworks/native/libs/input/InputVerifier.cpp @@ -41,7 +41,9 @@ Result InputVerifier::processMovement(int32_t deviceId, int32_t action, ui rust::Slice properties{rpp.data(), rpp.size()}; rust::String errorMessage = android::input::verifier::process_movement(*mVerifier, deviceId, action, properties, - flags); + //------rk modiry start------ + static_cast(flags)); + //------rk modiry end------ if (errorMessage.empty()) { return {}; } else { diff --git a/frameworks/native/libs/input/input_verifier.rs b/frameworks/native/libs/input/input_verifier.rs index dd2ac4ca917..64e246f13de 100644 --- a/frameworks/native/libs/input/input_verifier.rs +++ b/frameworks/native/libs/input/input_verifier.rs @@ -49,7 +49,9 @@ mod ffi { device_id: i32, action: u32, pointer_properties: &[RustPointerProperties], - flags: i32, + //------rk modify start------ + flags: u32, + //------rk modify end------ ) -> String; } @@ -69,7 +71,9 @@ fn process_movement( device_id: i32, action: u32, pointer_properties: &[RustPointerProperties], - flags: i32, + //------rk modify start------ + flags: u32, + //------rk modify end------ ) -> String { let result = verifier.process_movement( DeviceId(device_id), @@ -138,8 +142,20 @@ impl From for MotionAction { } bitflags! { - struct Flags: i32 { - const CANCELED = input_bindgen::AMOTION_EVENT_FLAG_CANCELED; + //------rk modify start------ + struct Flags: u32 { + const CANCELED = input_bindgen::AMOTION_EVENT_FLAG_CANCELED as u32; + /// FLAG_WINDOW_IS_OBSCURED + const WINDOW_IS_OBSCURED = input_bindgen::AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED; + /// FLAG_WINDOW_IS_PARTIALLY_OBSCURED + const WINDOW_IS_PARTIALLY_OBSCURED = + input_bindgen::AMOTION_EVENT_FLAG_WINDOW_IS_PARTIALLY_OBSCURED; + /// FLAG_IS_ACCESSIBILITY_EVENT + const IS_ACCESSIBILITY_EVENT = + input_bindgen::AMOTION_EVENT_FLAG_IS_ACCESSIBILITY_EVENT; + /// FLAG_NO_FOCUS_CHANGE + const NO_FOCUS_CHANGE = input_bindgen::AMOTION_EVENT_FLAG_NO_FOCUS_CHANGE; + //------rk modify end------ } } diff --git a/frameworks/native/services/inputflinger/dispatcher/InputDispatcher.cpp b/frameworks/native/services/inputflinger/dispatcher/InputDispatcher.cpp index 739407ac5cf..4f6920b90ba 100644 --- a/frameworks/native/services/inputflinger/dispatcher/InputDispatcher.cpp +++ b/frameworks/native/services/inputflinger/dispatcher/InputDispatcher.cpp @@ -6204,9 +6204,7 @@ void InputDispatcher::doDispatchCycleFinishedCommand(nsecs_t finishTime, bool restartEvent; if (dispatchEntry->eventEntry->type == EventEntry::Type::KEY) { - KeyEntry& keyEntry = static_cast(*(dispatchEntry->eventEntry)); - restartEvent = - afterKeyEventLockedInterruptable(connection, dispatchEntry, keyEntry, handled); + restartEvent = afterKeyEventLockedInterruptable(connection, dispatchEntry, handled); } else if (dispatchEntry->eventEntry->type == EventEntry::Type::MOTION) { MotionEntry& motionEntry = static_cast(*(dispatchEntry->eventEntry)); restartEvent = afterMotionEventLockedInterruptable(connection, dispatchEntry, motionEntry, @@ -6424,8 +6422,17 @@ void InputDispatcher::processConnectionResponsiveLocked(const Connection& connec } bool InputDispatcher::afterKeyEventLockedInterruptable( - const std::shared_ptr& connection, DispatchEntry* dispatchEntry, - KeyEntry& keyEntry, bool handled) { + const std::shared_ptr& connection, DispatchEntry* dispatchEntry, bool handled) { + // The dispatchEntry is currently valid, but it might point to a deleted object after we release + // the lock. For simplicity, make copies of the data of interest here and assume that + // 'dispatchEntry' is not valid after this section. + // Hold a strong reference to the EventEntry to ensure it's valid for the duration of this + // function, even if the DispatchEntry gets destroyed and releases its share of the ownership. + std::shared_ptr eventEntry = dispatchEntry->eventEntry; + const bool hasForegroundTarget = dispatchEntry->hasForegroundTarget(); + KeyEntry& keyEntry = static_cast(*(eventEntry)); + // To prevent misuse, ensure dispatchEntry is no longer valid. + dispatchEntry = nullptr; if (keyEntry.flags & AKEY_EVENT_FLAG_FALLBACK) { if (!handled) { // Report the key as unhandled, since the fallback was not handled. @@ -6442,7 +6449,7 @@ bool InputDispatcher::afterKeyEventLockedInterruptable( connection->inputState.removeFallbackKey(originalKeyCode); } - if (handled || !dispatchEntry->hasForegroundTarget()) { + if (handled || !hasForegroundTarget) { // If the application handles the original key for which we previously // generated a fallback or if the window is not a foreground window, // then cancel the associated fallback key, if any. diff --git a/frameworks/native/services/inputflinger/dispatcher/InputDispatcher.h b/frameworks/native/services/inputflinger/dispatcher/InputDispatcher.h index 2b8b37e42a3..53efd7475d2 100644 --- a/frameworks/native/services/inputflinger/dispatcher/InputDispatcher.h +++ b/frameworks/native/services/inputflinger/dispatcher/InputDispatcher.h @@ -685,8 +685,8 @@ private: REQUIRES(mLock); std::map mVerifiersByDisplay; bool afterKeyEventLockedInterruptable(const std::shared_ptr& connection, - DispatchEntry* dispatchEntry, KeyEntry& keyEntry, - bool handled) REQUIRES(mLock); + DispatchEntry* dispatchEntry, bool handled) + REQUIRES(mLock); bool afterMotionEventLockedInterruptable(const std::shared_ptr& connection, DispatchEntry* dispatchEntry, MotionEntry& motionEntry, bool handled) REQUIRES(mLock); diff --git a/frameworks/native/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp b/frameworks/native/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp index 6e2bf22bbb7..0ee606d0f26 100644 --- a/frameworks/native/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp +++ b/frameworks/native/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp @@ -182,12 +182,20 @@ FloatRect OutputLayer::calculateOutputSourceCrop(uint32_t internalDisplayRotatio } //RK code +// Fix White line in case that layer is mixed GPU and HW composite. +// +// In scenarios where the decimal part of certain rect values is 0.5, +// using the rounding method might result in inconsistencies where the GPU's internal calculations do not round up, +// while the CPU calculations do round up. +// Change to +0.499 than clip will better align between GPU and CPU result +// redmine: #547677 #540271 + static Rect ClipFloatRect2Rect(FloatRect rectf){ Rect r; - r.left = static_cast(rectf.left); - r.top = static_cast(rectf.top); - r.right = static_cast(rectf.right); - r.bottom = static_cast(rectf.bottom); + r.left = static_cast(rectf.left+0.499); + r.top = static_cast(rectf.top+0.499); + r.right = static_cast(rectf.right+0.499); + r.bottom = static_cast(rectf.bottom+0.499); return r; } //RK code diff --git a/frameworks/native/services/surfaceflinger/Layer.cpp b/frameworks/native/services/surfaceflinger/Layer.cpp index aef4f2eb9ca..995af69566f 100644 --- a/frameworks/native/services/surfaceflinger/Layer.cpp +++ b/frameworks/native/services/surfaceflinger/Layer.cpp @@ -2936,7 +2936,18 @@ void Layer::onLayerDisplayed(ftl::SharedFuture futureFenceResult, ch->previousReleaseFences.emplace_back(std::move(futureFenceResult)); ch->name = mName; } - mPreviouslyPresentedLayerStacks.push_back(layerStack); + //RK_code bgein--- + bool found_layer_stack = false; + for(auto &old_stack: mPreviouslyPresentedLayerStacks){ + if(layerStack == old_stack){ + found_layer_stack = true; + break; + } + } + if(!found_layer_stack){ + mPreviouslyPresentedLayerStacks.push_back(layerStack); + } + //RK_code end--- } void Layer::onSurfaceFrameCreated( diff --git a/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp b/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp index 53f6d379416..00bde8e1879 100644 --- a/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp +++ b/frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp @@ -935,6 +935,19 @@ void SurfaceFlinger::init() FTL_FAKE_GUARD(kMainThreadContext) { }); } + //-------rk-code-begin----- + // Check hotplug events after scheduler init, so no event will be missed. + bool isHotplugPending = false; + { + std::lock_guard lock(mHotplugMutex); + isHotplugPending = mPendingHotplugEvents.size()>0; + } + + if(mScheduler && isHotplugPending){ + mScheduler->scheduleConfigure(); + } + //-------rk-code-end----- + ALOGV("Done initializing"); }