4

I'd like to show the sync settings for an AccountManager / SyncAdapter account - and the account is even created by the app which tries to show it (the content authorities would also match). But how to indirectly start the UserAndAccountDashboardActivity with an Intent? The settings page equaling Settings.EXTRA_AUTHORITIES (email) even seems to be one level deeper.

This Intent works on Android OS - but on Harmony OS it shows me the WifiSettingsActivity.

protected void showSyncSettings(@NonNull String authority) {
    Intent intent = new Intent();
    intent.setAction(Settings.ACTION_SYNC_SETTINGS);
    intent.putExtra(Settings.EXTRA_AUTHORITIES, new String[] {authority});
    try {
        this.startActivity(intent);
    } catch (ActivityNotFoundException e) {
        Log.e(LOG_TAG, e.getMessage());
    }
}

This issue is ACTION_SYNC_SETTINGS - and UserAndAccountDashboardActivity is about the same:

In some cases, a matching Activity may not exist, so ensure you safeguard against this.

E/ActivityTaskManager: START {act=android.settings.SYNC_SETTINGS flg=0x10000000 hwFlg=0x10 cmp=com.android.settings/.HWSettings} result: 3

What I've tried so far, is to start the UserAndAccountDashboardActivity directly:

Intent intent = new Intent();
intent.setClassName("com.android.settings", "com.android.settings.Settings$UserAndAccountDashboardActivity");
startActivity(intent);

Which suggests, that one cannot start the UserAndAccountDashboardActivity directly:

W/ActivityTaskManager: Permission Denial: starting Intent { cmp=com.android.settings/.Settings$UserAndAccountDashboardActivity (has extras) } from ProcessRecord{e07293d 8294:com.acme.debug/u0a208} (pid=8294, uid=10208) not exported from uid 1000.

When starting it with adb shell am it doesn't do much either:

HWWGR:/ $ am start -n com.android.settings/com.android.settings.Settings -e :android:show_fragment com.android.settings.Settings$UserAndAccountDashboardActivity
Starting: Intent { cmp=com.android.settings/.Settings (has extras) }

This seems to be the main settings page, from where the user still has to scroll down 2-3 screens:

intent.setClassName("com.android.settings", "com.android.settings.HWSettings");

And I can start most other sub-pages of Settings / extends HWSettings directly:

BluetoothSettingsActivityWirelessSettingsActivityTetherSettingsActivityVpnSettingsActivityDateTimeSettingsActivityWifiSettingsActivityLocalePickerActivityUserDictionarySettingsActivitySoundSettingsActivityDisplaySettingsActivityDeviceInfoSettingsActivityManageApplicationsActivityStorageUseActivityDevelopmentSettingsActivityAccessibilitySettingsActivityCaptioningSettingsActivityLocationSettingsActivityRunningServicesActivityPowerUsageSummaryActivityCryptKeeperSettingsActivityDeviceAdminSettingsActivityDataUsageSummaryActivityAdvancedWifiSettingsActivityTextToSpeechSettingsActivityWifiDisplaySettingsActivityDreamSettingsActivityUserSettingsActivityNotificationAccessSettingsActivityTrustedCredentialsSettingsActivityPrintSettingsActivity

There's even further sub-pages, which one can directly start:

HWWGR:/ $ dumpsys package | grep -Eo "^[[:space:]]+[0-9a-f]+[[:space:]]+com.android.settings/[^[:space:]]+" | grep -oE "[^[:space:]]+$" | grep Settings\\$

This also provides some vendor-specific sub-classes, eg. the StorageDashboardActivity.


But how would the Intent have to look alike, which opens the desired UserAndAccountDashboardActivity directly or indirectly? I've also tried Intent com.android.settings/.SubSettings, but this cannot be started either:

HWWGR:/ $ am start -n com.android.settings/com.android.settings.SubSettings
Starting: Intent { cmp=com.android.settings/.SubSettings }
Security exception: Permission Denial: starting Intent { flg=0x10000000 cmp=com.android.settings/.SubSettings } from null (pid=28606, uid=2000) not exported from uid 1000
Martin Zeitler
  • 1
  • 19
  • 155
  • 216

0 Answers0