Skip to content

Add BluetoothManagerServiceDiskRead violation rules#7013

Merged
TimoPtr merged 4 commits into
home-assistant:mainfrom
oungsi2000:add-violation-rules
Jun 16, 2026
Merged

Add BluetoothManagerServiceDiskRead violation rules#7013
TimoPtr merged 4 commits into
home-assistant:mainfrom
oungsi2000:add-violation-rules

Conversation

@oungsi2000

Copy link
Copy Markdown
Contributor

Summary

This PR fixes #7012.
On some OEM ROMs (observed on Samsung via obfuscated isSpeg/isSpegInWorking methods), the registerAdapter binder call internally performs a File.exists() disk read. Since this path was not on the StrictMode ignore list, it triggered a FailFast violation, crashing the app on startup.

Checklist

  • New or updated tests have been added to cover the changes following the testing guidelines.
  • The code follows the project's code style and best_practices.
  • The changes have been thoroughly tested, and edge cases have been considered.
  • Changes are backward compatible whenever feasible. Any breaking changes are documented in the changelog for users and/or in the code for developers depending on the relevance.

Copilot AI review requested due to automatic review settings June 12, 2026 07:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds a new StrictMode ignore rule to suppress a known OEM/system Bluetooth service disk-read violation that propagates back to the app via Binder.

Changes:

  • Register a new thread-policy ignore rule for BluetoothManagerService disk reads on affected OEM ROMs.
  • Implement stack-trace matching logic for the Bluetooth service violation.

Comment on lines +192 to +210
/**
* Ignore a [DiskReadViolation] in the system Bluetooth service (`BluetoothManagerService`).
*
* On some OEM ROMs (observed on Samsung, methods `isSpeg`/`isSpegInWorking`), registering a Bluetooth adapter
* performs an internal `File.exists()` check while handling the `registerAdapter` binder transaction. The
* StrictMode thread policy propagates across the binder call, so the disk read is reported back to the app even
* though it happens inside the system service and is beyond application control.
*/
private data object IgnoreSamsungBluetoothManagerServiceDiskRead : IgnoreViolationRule {
@RequiresApi(Build.VERSION_CODES.P)
override fun shouldIgnore(violation: Violation): Boolean {
if (violation !is DiskReadViolation) return false

return violation.stackTrace.any {
it.className == "com.android.server.bluetooth.BluetoothManagerService" &&
it.methodName == "isSpeg"
}
}
}

@home-assistant home-assistant Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @oungsi2000

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

@home-assistant

Copy link
Copy Markdown

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@home-assistant
home-assistant Bot marked this pull request as draft June 12, 2026 07:57
@oungsi2000
oungsi2000 marked this pull request as ready for review June 12, 2026 07:58
@home-assistant
home-assistant Bot dismissed their stale review June 12, 2026 07:58

Stale

@TimoPtr
TimoPtr enabled auto-merge (squash) June 15, 2026 13:39
auto-merge was automatically disabled June 15, 2026 13:49

Head branch was pushed to by a user without write access

@oungsi2000
oungsi2000 force-pushed the add-violation-rules branch from 9f6273f to ca4474c Compare June 15, 2026 13:55
@oungsi2000

Copy link
Copy Markdown
Contributor Author

@TimoPtr There was a timing conflict. I pushed to my branch around the same time you did, so things got a bit tangled up. I removed my commit and force-pushed to fix it. Could you check and re-enable auto-merge? I'm sorry about that

@TimoPtr
TimoPtr enabled auto-merge (squash) June 15, 2026 14:53
@oungsi2000

Copy link
Copy Markdown
Contributor Author

@TimoPtr
The Instrumentation Test app and Test Results required checks are stuck on "Expected — Waiting for status to be reported" in the merge box, but they actually ran and passed (check runs 81459086082 and 81459612539, both success on the head SHA ca4474c).

this commit ended up with two Pull Request workflow runs. The deferred pr-emulator-wtf.yml posts these checks via the API, which absorbed them into the older suite (74140666250), while the merge box keys off the newer suite (74144090394)

Could you admin-merge or bypass, since a re-push would just force another ui-test environment approval for a cosmetic matching issue?

@TimoPtr
TimoPtr disabled auto-merge June 16, 2026 16:04
@TimoPtr
TimoPtr enabled auto-merge (squash) June 16, 2026 16:05
@TimoPtr
TimoPtr merged commit ecb5e8e into home-assistant:main Jun 16, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

StrictMode DiskReadViolation on initialization

3 participants