Repository navigation
Conversation
…ding over onboarding (fixes GrapheneOS#299)
RankoR
self-requested a review
November 24, 2026 00:03
RankoR
suggested changes
Nov 24, 2026
| onClose: () -> Unit = { exitProcess(0) }, | ||
| ) { | ||
| val context = LocalContext.current | ||
| val userManager = remember(context) { context.getSystemService(UserManager::class.java) } |
Member
There was a problem hiding this comment.
Obtaining and calling UserManager should not be done from a Composable. It belongs to the ViewModel or delegate
Contributor
Author
There was a problem hiding this comment.
Moved it to DeviceOwnerSmsBlockViewModel, which reads DISALLOW_SMS through a new SmsRestrictionChecker in the data layer. The composable only collects the state and calls the ViewModel on resume.
…del through a data layer SmsRestrictionChecker instead of calling UserManager from the composable
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #299
The block shown when the device owner sets
DISALLOW_SMSis now a ComposeAlertDialog(DeviceOwnerSmsBlock) instead of the frameworkAlertDialoginBugleActivityUtil.DeviceOwnerSmsBlockViewModelchecks the restriction through a newSmsRestrictionCheckeron each resume, and the dialog hides again once the restriction is lifted. OK still exits the app, and back or tapping outside doesn't dismiss it.It's placed once in
AppNavGraph, forMainActivityandConversationActivity, and once in a newBugleComponentActivity.setAppContent, whichShareIntentActivity,WidgetPickConversationActivityandDebugMmsConfigActivitynow use instead ofsetContent { AppTheme { … } }.SettingsActivityandRemoteInputEntrypointActivityfinish inonCreate, so they never showed it.BugleActivityUtil.onActivityResumekeeps only theDataModelandFactoryresume calls.Behavior change: the dialog is also shown over onboarding. Before,
AppResumeEffectskipped the check while onboarding was shown, and onboarding requires the SMS role, so a user without SMS had to grant the permissions and make Messaging the default SMS app before being told it isn't allowed.Theme.Composeis unchanged; it no longer styles any dialog.DeviceOwnerSmsBlockTestcovers showing, hiding, re-checking on resume and closing, through the ViewModel and checker. Unit tests, the coverage gate,ktlintCheckand:app:detektDebugpass. Checked on a Pixel 8 in a secondary user without SMS, over the settings screen, the share screen and onboarding. Rechecked after the ViewModel change: shown on resume, after rotation, over the share screen and over onboarding; OK exits; hidden once SMS is allowed again.