Skip to content

Show the SMS block set by the device owner in a Compose dialog, including over onboarding - #586

Open
mmlado wants to merge 2 commits into
GrapheneOS:mainfrom
mmlado:device-owner-block-dialog
Open

mmlado wants to merge 2 commits into
GrapheneOS:mainfrom
mmlado:device-owner-block-dialog

Conversation

@mmlado

@mmlado mmlado commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #299

The block shown when the device owner sets DISALLOW_SMS is now a Compose AlertDialog (DeviceOwnerSmsBlock) instead of the framework AlertDialog in BugleActivityUtil. DeviceOwnerSmsBlockViewModel checks the restriction through a new SmsRestrictionChecker on 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, for MainActivity and ConversationActivity, and once in a new BugleComponentActivity.setAppContent, which ShareIntentActivity, WidgetPickConversationActivity and DebugMmsConfigActivity now use instead of setContent { AppTheme { … } }. SettingsActivity and RemoteInputEntrypointActivity finish in onCreate, so they never showed it. BugleActivityUtil.onActivityResume keeps only the DataModel and Factory resume calls.

Behavior change: the dialog is also shown over onboarding. Before, AppResumeEffect skipped 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.Compose is unchanged; it no longer styles any dialog.

DeviceOwnerSmsBlockTest covers showing, hiding, re-checking on resume and closing, through the ViewModel and checker. Unit tests, the coverage gate, ktlintCheck and :app:detektDebug pass. 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.

messaging-299-before-after messaging-299-onboarding-after

@RankoR
RankoR self-requested a review November 24, 2026 00:03
onClose: () -> Unit = { exitProcess(0) },
) {
val context = LocalContext.current
val userManager = remember(context) { context.getSystemService(UserManager::class.java) }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Obtaining and calling UserManager should not be done from a Composable. It belongs to the ViewModel or delegate

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate Device-owner block dialog to Compose

2 participants