Close Settings page when cross-profile appop is granted

Fixes: 156365481
Test: manual
Change-Id: I9250ef5db0c40a42a25a2dedf84a47d1b1da11f1
This commit is contained in:
Alex Kershaw
2020-05-16 20:30:26 +01:00
parent 7f15836d47
commit d3fa045e35

View File

@@ -120,18 +120,10 @@ public class InteractAcrossProfilesDetails extends AppInfoBase
if (!mCrossProfileApps.canConfigureInteractAcrossProfiles(mPackageName)) { if (!mCrossProfileApps.canConfigureInteractAcrossProfiles(mPackageName)) {
logNonConfigurableAppMetrics(); logNonConfigurableAppMetrics();
} }
Bundle bundle = getIntent().getBundleExtra(EXTRA_SHOW_FRAGMENT_ARGS); if (launchedByApp()) {
if (bundle == null) {
logEvent(DevicePolicyEnums.CROSS_PROFILE_SETTINGS_PAGE_LAUNCHED_FROM_SETTINGS);
return;
}
Intent intent = (Intent) bundle.get(INTENT_KEY);
if (intent == null) {
logEvent(DevicePolicyEnums.CROSS_PROFILE_SETTINGS_PAGE_LAUNCHED_FROM_SETTINGS);
return;
}
if (ACTION_MANAGE_CROSS_PROFILE_ACCESS.equals(intent.getAction())) {
logEvent(DevicePolicyEnums.CROSS_PROFILE_SETTINGS_PAGE_LAUNCHED_FROM_APP); logEvent(DevicePolicyEnums.CROSS_PROFILE_SETTINGS_PAGE_LAUNCHED_FROM_APP);
} else {
logEvent(DevicePolicyEnums.CROSS_PROFILE_SETTINGS_PAGE_LAUNCHED_FROM_SETTINGS);
} }
} }
@@ -275,6 +267,9 @@ public class InteractAcrossProfilesDetails extends AppInfoBase
logEvent(DevicePolicyEnums.CROSS_PROFILE_SETTINGS_PAGE_USER_CONSENTED); logEvent(DevicePolicyEnums.CROSS_PROFILE_SETTINGS_PAGE_USER_CONSENTED);
enableInteractAcrossProfiles(true); enableInteractAcrossProfiles(true);
refreshUi(); refreshUi();
if (launchedByApp()) {
setIntentAndFinish(/* appChanged= */ true);
}
} }
}) })
.setNegativeButton(R.string.deny, new DialogInterface.OnClickListener() { .setNegativeButton(R.string.deny, new DialogInterface.OnClickListener() {
@@ -469,4 +464,16 @@ public class InteractAcrossProfilesDetails extends AppInfoBase
public int getMetricsCategory() { public int getMetricsCategory() {
return SettingsEnums.INTERACT_ACROSS_PROFILES; return SettingsEnums.INTERACT_ACROSS_PROFILES;
} }
private boolean launchedByApp() {
final Bundle bundle = getIntent().getBundleExtra(EXTRA_SHOW_FRAGMENT_ARGS);
if (bundle == null) {
return false;
}
final Intent intent = (Intent) bundle.get(INTENT_KEY);
if (intent == null) {
return false;
}
return ACTION_MANAGE_CROSS_PROFILE_ACCESS.equals(intent.getAction());
}
} }