Skip to content
This repository was archived by the owner on Apr 13, 2026. It is now read-only.

feat: throw a pop-up asking user to enable WRITE_SECURE_SETTINGS permission#13

Merged
pixincreate merged 5 commits intomainfrom
feat/popup
May 3, 2025
Merged

feat: throw a pop-up asking user to enable WRITE_SECURE_SETTINGS permission#13
pixincreate merged 5 commits intomainfrom
feat/popup

Conversation

@pixincreate
Copy link
Copy Markdown
Owner

@pixincreate pixincreate commented May 2, 2025

Inspired from 6f3b26e

Initial thought that I had was to throw a pop-up in home screen after user starts the Shizuku service. Now that I think about it, this approach is more cleaner as the pop-up is restricted to the feature that is added:

image

ref: https://developer.android.com/reference/android/Manifest.permission#WRITE_SECURE_SETTINGS

@pixincreate pixincreate self-assigned this May 2, 2025
Copilot AI review requested due to automatic review settings May 2, 2025 18:15
@pixincreate pixincreate added the enhancement New feature or request label May 2, 2025
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a new feature that prompts the user with a pop-up to enable the WRITE_SECURE_SETTINGS permission when needed. Key changes include:

  • Adding auto-grant logic and a user dialog for the WRITE_SECURE_SETTINGS permission in the SettingsFragment.
  • Refactoring secure permission checks to use a helper method, hasSecureSettingsPermission().
  • Introducing a new shared preference constant, PENDING_SECURE_SETTINGS_GRANT, in ShizukuSettings.java to manage the permission grant status.

Reviewed Changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.

File Description
manager/src/main/java/moe/shizuku/manager/settings/SettingsFragment.kt Added logic for checking and auto-granting WRITE_SECURE_SETTINGS with appropriate dialogs and refactored boot component toggling
manager/src/main/java/moe/shizuku/manager/ShizukuSettings.java Added a new preference key for pending secure settings grant tracking
Files not reviewed (1)
  • manager/src/main/res/values/strings.xml: Language not supported

Comment thread manager/src/main/java/moe/shizuku/manager/settings/SettingsFragment.kt Outdated
@pixincreate pixincreate requested a review from Copilot May 2, 2025 18:22
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a feature to automatically prompt the user to grant the sensitive WRITE_SECURE_SETTINGS permission through a pop-up when required, streamlining the user experience and handling permission conflicts.

  • Introduces a dialog for automatic permission granting with Shizuku.
  • Updates boot component toggling logic to handle mutual exclusivity between boot options.
  • Adds an ADB instructions dialog for manual permission granting fallback.

Reviewed Changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.

File Description
manager/src/main/java/moe/shizuku/manager/settings/SettingsFragment.kt Implements permission check, auto-grant logic via Shizuku, and related dialogs.
manager/src/main/java/moe/shizuku/manager/ShizukuSettings.java Adds a constant for pending secure settings grant.
Files not reviewed (1)
  • manager/src/main/res/values/strings.xml: Language not supported
Comments suppressed due to low confidence (1)

manager/src/main/java/moe/shizuku/manager/settings/SettingsFragment.kt:122

  • [nitpick] The auto-granting permission logic is duplicated in both onPreferenceChangeListener and onResume. Consider extracting this logic into a shared helper method to reduce duplication and enhance maintainability.
val pendingGrant = ShizukuSettings.getPreferences().getBoolean(PENDING_SECURE_SETTINGS_GRANT, false)

Comment thread manager/src/main/java/moe/shizuku/manager/settings/SettingsFragment.kt Outdated
@pixincreate pixincreate requested a review from Copilot May 3, 2025 16:22
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a pop-up prompt to request the WRITE_SECURE_SETTINGS permission and automates parts of the permission grant process via Shizuku.

  • Added methods to check, request, and auto-grant the WRITE_SECURE_SETTINGS permission in SettingsFragment.kt.
  • Updated the Settings UI to disable conflicting options when the permission is granted or denied.
  • Added a new constant in ShizukuSettings.java to track pending secure settings grants.

Reviewed Changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.

File Description
manager/src/main/java/moe/shizuku/manager/settings/SettingsFragment.kt Updated with permission checks, a pop-up dialog, and auto-grant logic for WRITE_SECURE_SETTINGS.
manager/src/main/java/moe/shizuku/manager/ShizukuSettings.java Added constant for pending secure settings grant.
Files not reviewed (1)
  • manager/src/main/res/values/strings.xml: Language not supported

Comment thread manager/src/main/java/moe/shizuku/manager/settings/SettingsFragment.kt Outdated
@pixincreate pixincreate requested a review from Copilot May 3, 2025 17:16
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a new pop-up UI flow to prompt users to enable the WRITE_SECURE_SETTINGS permission and refactors how the boot component is managed.

  • Consolidates boot component logic by switching to a dedicated bootComponentName field.
  • Implements methods to auto-grant the WRITE_SECURE_SETTINGS permission and to display informative dialogs.
  • Adds a new shared preference constant for tracking the pending secure settings grant.

Reviewed Changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.

File Description
manager/src/main/java/moe/shizuku/manager/settings/SettingsFragment.kt Refactors boot component handling and implements the secure settings permission prompt.
manager/src/main/java/moe/shizuku/manager/ShizukuSettings.java Introduces a new constant (PENDING_SECURE_SETTINGS_GRANT) to support the new feature.
Files not reviewed (1)
  • manager/src/main/res/values/strings.xml: Language not supported
Comments suppressed due to low confidence (1)

manager/src/main/java/moe/shizuku/manager/settings/SettingsFragment.kt:505

  • Parsing the user ID from UserHandle's toString output is brittle and may break if the output format changes. Consider using a more robust API for retrieving the user ID if available.
val userId = try { userHandle.toString().substringAfter("{").substringBefore("}").toInt() } catch (e: Exception) {

Comment thread manager/src/main/java/moe/shizuku/manager/settings/SettingsFragment.kt Outdated
@pixincreate pixincreate requested a review from Copilot May 3, 2025 17:20
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a new pop-up to prompt users to enable the WRITE_SECURE_SETTINGS permission, improving the permission-grant flow for the wireless boot feature.

  • Replaces the local component name with a globally initialized bootComponentName to better manage boot component toggling.
  • Implements permission checking and auto-granting via Shizuku, along with a detailed Material dialog explaining the risks and instructions for manual granting.
  • Adds utility methods to verify and grant secure settings permissions and updates the settings flag accordingly in ShizukuSettings.java.

Reviewed Changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.

File Description
manager/src/main/java/moe/shizuku/manager/settings/SettingsFragment.kt Implements the permission dialog, auto-grant logic, and component toggling adjustments.
manager/src/main/java/moe/shizuku/manager/ShizukuSettings.java Adds a new constant flag to manage pending permission grants.
Files not reviewed (1)
  • manager/src/main/res/values/strings.xml: Language not supported
Comments suppressed due to low confidence (1)

manager/src/main/java/moe/shizuku/manager/settings/SettingsFragment.kt:503

  • [nitpick] Extracting the user ID from the UserHandle's string representation is brittle; consider using an official API if available to obtain the user ID directly.
val userId = try { userHandle.toString().substringAfter("{").substringBefore("}").toInt() } catch (e: Exception) { ... }

@pixincreate pixincreate changed the title feat: throw a pop-up asking user to enable WRITE_SECURE_SETTINGS permission feat: throw a pop-up asking user to enable WRITE_SECURE_SETTINGS permission May 3, 2025
@pixincreate pixincreate merged commit 59e483e into main May 3, 2025
1 check passed
@pixincreate pixincreate deleted the feat/popup branch May 3, 2025 17:21
pixincreate added a commit that referenced this pull request May 4, 2025
pixincreate added a commit that referenced this pull request May 4, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants