Merge "add a check if the app store link intent can be opened in the profile." into main
This commit is contained in:
@@ -83,6 +83,7 @@ public class AppStoreUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Convenience method that looks up the installerPackageName for you. */
|
/** Convenience method that looks up the installerPackageName for you. */
|
||||||
|
@Nullable
|
||||||
public static Intent getAppStoreLink(Context context, String packageName) {
|
public static Intent getAppStoreLink(Context context, String packageName) {
|
||||||
String installerPackageName = getInstallerPackageName(context, packageName);
|
String installerPackageName = getInstallerPackageName(context, packageName);
|
||||||
return getAppStoreLink(context, installerPackageName, packageName);
|
return getAppStoreLink(context, installerPackageName, packageName);
|
||||||
|
@@ -384,20 +384,21 @@ public class InteractAcrossProfilesDetails extends AppInfoBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void handleInstallBannerClick() {
|
private void handleInstallBannerClick() {
|
||||||
if (mInstallAppIntent == null) {
|
if (mInstallAppIntent != null
|
||||||
logEvent(
|
&& !mInstalledInWork
|
||||||
DevicePolicyEnums.CROSS_PROFILE_SETTINGS_PAGE_INSTALL_BANNER_NO_INTENT_CLICKED);
|
&& isInstallableInProfile(mInstallAppIntent, mWorkProfile)) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!mInstalledInWork) {
|
|
||||||
logEvent(DevicePolicyEnums.CROSS_PROFILE_SETTINGS_PAGE_INSTALL_BANNER_CLICKED);
|
logEvent(DevicePolicyEnums.CROSS_PROFILE_SETTINGS_PAGE_INSTALL_BANNER_CLICKED);
|
||||||
mContext.startActivityAsUser(mInstallAppIntent, mWorkProfile);
|
mContext.startActivityAsUser(mInstallAppIntent, mWorkProfile);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!mInstalledInPersonal) {
|
if (mInstallAppIntent != null
|
||||||
|
&& !mInstalledInPersonal
|
||||||
|
&& isInstallableInProfile(mInstallAppIntent, mPersonalProfile)) {
|
||||||
logEvent(DevicePolicyEnums.CROSS_PROFILE_SETTINGS_PAGE_INSTALL_BANNER_CLICKED);
|
logEvent(DevicePolicyEnums.CROSS_PROFILE_SETTINGS_PAGE_INSTALL_BANNER_CLICKED);
|
||||||
mContext.startActivityAsUser(mInstallAppIntent, mPersonalProfile);
|
mContext.startActivityAsUser(mInstallAppIntent, mPersonalProfile);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
logEvent(DevicePolicyEnums.CROSS_PROFILE_SETTINGS_PAGE_INSTALL_BANNER_NO_INTENT_CLICKED);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -447,7 +448,8 @@ public class InteractAcrossProfilesDetails extends AppInfoBase
|
|||||||
R.string.interact_across_profiles_install_personal_app_title,
|
R.string.interact_across_profiles_install_personal_app_title,
|
||||||
mAppLabel),
|
mAppLabel),
|
||||||
mAppLabel));
|
mAppLabel));
|
||||||
if (mInstallAppIntent != null) {
|
if (mInstallAppIntent != null
|
||||||
|
&& isInstallableInProfile(mInstallAppIntent, mPersonalProfile)) {
|
||||||
mInstallBanner.setSummary(
|
mInstallBanner.setSummary(
|
||||||
R.string.interact_across_profiles_install_app_summary);
|
R.string.interact_across_profiles_install_app_summary);
|
||||||
}
|
}
|
||||||
@@ -461,7 +463,8 @@ public class InteractAcrossProfilesDetails extends AppInfoBase
|
|||||||
R.string.interact_across_profiles_install_work_app_title,
|
R.string.interact_across_profiles_install_work_app_title,
|
||||||
mAppLabel),
|
mAppLabel),
|
||||||
mAppLabel));
|
mAppLabel));
|
||||||
if (mInstallAppIntent != null) {
|
if (mInstallAppIntent != null
|
||||||
|
&& isInstallableInProfile(mInstallAppIntent, mWorkProfile)) {
|
||||||
mInstallBanner.setSummary(
|
mInstallBanner.setSummary(
|
||||||
R.string.interact_across_profiles_install_app_summary);
|
R.string.interact_across_profiles_install_app_summary);
|
||||||
}
|
}
|
||||||
@@ -488,6 +491,12 @@ public class InteractAcrossProfilesDetails extends AppInfoBase
|
|||||||
return info != null;
|
return info != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isInstallableInProfile(Intent intent, UserHandle profile) {
|
||||||
|
return !mContext.getPackageManager()
|
||||||
|
.queryIntentActivitiesAsUser(intent, /* flags= */ 0, profile)
|
||||||
|
.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
private void refreshUiForConfigurableApps() {
|
private void refreshUiForConfigurableApps() {
|
||||||
mInstallBanner.setVisible(false);
|
mInstallBanner.setVisible(false);
|
||||||
mSwitchPref.setEnabled(true);
|
mSwitchPref.setEnabled(true);
|
||||||
|
Reference in New Issue
Block a user