Skip to content

Conversation

@bazl-E
Copy link
Contributor

@bazl-E bazl-E commented Oct 5, 2025

This pull request brings major improvements to the logic for opening Phone Account Settings on Android devices, making the process far more robust and compatible across a wide range of manufacturers and system configurations.

The update introduces:

Manufacturer- and brand-specific handling

Smarter fallback mechanisms

More flexible intent resolution

Together, these changes ensure users are seamlessly directed to the correct settings screen, regardless of their device brand or OS customization.

As part of one of our primary projects, my team and I have been actively using this package — it has been incredibly helpful and reliable. During our integration, we conducted extensive testing across multiple devices and confirmed full compatibility:

✅ SAMSUNG
✅ GOOGLE PIXEL
✅ MOTOROLA
✅ ONEPLUS
✅ NOTHING
✅ OPPO
✅ VIVO
✅ REALME
✅ iQOO
✅ XIAOMI / REDMI
✅ POCO

This update has been thoroughly validated and works great across all the above models.

@cybex-dev
Copy link
Owner

Hey @bazl-E, great PR and many thanks! If you can resolve merge conflicts I'll merge asap.

@cybex-dev cybex-dev requested a review from Copilot October 29, 2025 19:47
Copy link

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 refactors the openPhoneAccountSettings method in TelecomManagerExtension.kt to provide more robust handling of phone account settings navigation across different Android device manufacturers. The changes extract the manufacturer-specific logic into dedicated helper functions and implement a fallback mechanism to ensure users can access settings even if primary intents fail.

  • Replaced hardcoded manufacturer checks with a more extensible manufacturer-specific intent system
  • Implemented a cascading fallback mechanism with multiple intent candidates
  • Added support for OPPO and Realme devices with manufacturer-specific settings intents

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +167 to +171
val packagedDefaultAppsIntent = Intent(Settings.ACTION_MANAGE_DEFAULT_APPS_SETTINGS).apply {
`package` = "com.android.settings"
}

return explicitIntents + packagedDefaultAppsIntent
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

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

Setting an explicit package name on an Intent may cause it to fail on devices where the settings app has a different package name (e.g., OEM-customized ROMs). Consider adding a version check or fallback mechanism since Settings.ACTION_MANAGE_DEFAULT_APPS_SETTINGS is only available on API 24+ (Android N) and this intent is used without a version guard here.

Suggested change
val packagedDefaultAppsIntent = Intent(Settings.ACTION_MANAGE_DEFAULT_APPS_SETTINGS).apply {
`package` = "com.android.settings"
}
return explicitIntents + packagedDefaultAppsIntent
val packagedDefaultAppsIntent: Intent? =
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
// Try to resolve the intent with explicit package, fallback to generic if not resolvable
val intent = Intent(Settings.ACTION_MANAGE_DEFAULT_APPS_SETTINGS)
val pm = activity.packageManager
intent.`package` = "com.android.settings"
val resolved = pm.resolveActivity(intent, 0)
if (resolved != null) {
intent
} else {
// Remove explicit package, try generic intent
Intent(Settings.ACTION_MANAGE_DEFAULT_APPS_SETTINGS)
}
} else {
null
}
return if (packagedDefaultAppsIntent != null) {
explicitIntents + packagedDefaultAppsIntent
} else {
explicitIntents
}

Copilot uses AI. Check for mistakes.
}

private fun resolveSystemComponent(packageManager: PackageManager, intent: Intent): ComponentName? {
val matches = packageManager.queryIntentActivities(intent, 0)
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

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

The flags parameter should use PackageManager.MATCH_DEFAULT_ONLY or appropriate flags instead of 0 to ensure only activities that can handle the intent are returned. Using 0 may return activities that aren't actually launchable, leading to potential failures.

Suggested change
val matches = packageManager.queryIntentActivities(intent, 0)
val matches = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY)

Copilot uses AI. Check for mistakes.
}

val components = listOf(
ComponentName("com.android.settings", "com.android.settings.Settings\$DefaultAppSettingsActivity"),
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

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

The escaped dollar sign \$ in the class name string should be a regular dollar sign $ for proper ComponentName resolution. The backslash escaping is unnecessary in Kotlin strings and may cause the ComponentName lookup to fail.

Suggested change
ComponentName("com.android.settings", "com.android.settings.Settings\$DefaultAppSettingsActivity"),
ComponentName("com.android.settings", "com.android.settings.Settings$DefaultAppSettingsActivity"),

Copilot uses AI. Check for mistakes.
@cybex-dev cybex-dev merged commit a509daf into cybex-dev:master Oct 29, 2025
8 checks passed
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.

2 participants