Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e0f43bbc authored by Oli Thompson's avatar Oli Thompson Committed by Android (Google) Code Review
Browse files

Merge "add a check if the app store link intent can be opened in the profile." into main

parents fb52d691 77f8e503
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -83,6 +83,7 @@ public class AppStoreUtil {
    }

    /** Convenience method that looks up the installerPackageName for you. */
    @Nullable
    public static Intent getAppStoreLink(Context context, String packageName) {
      String installerPackageName = getInstallerPackageName(context, packageName);
      return getAppStoreLink(context, installerPackageName, packageName);
+18 −9
Original line number Diff line number Diff line
@@ -384,20 +384,21 @@ public class InteractAcrossProfilesDetails extends AppInfoBase
    }

    private void handleInstallBannerClick() {
        if (mInstallAppIntent == null) {
            logEvent(
                    DevicePolicyEnums.CROSS_PROFILE_SETTINGS_PAGE_INSTALL_BANNER_NO_INTENT_CLICKED);
            return;
        }
        if (!mInstalledInWork) {
        if (mInstallAppIntent != null
                && !mInstalledInWork
                && isInstallableInProfile(mInstallAppIntent, mWorkProfile)) {
            logEvent(DevicePolicyEnums.CROSS_PROFILE_SETTINGS_PAGE_INSTALL_BANNER_CLICKED);
            mContext.startActivityAsUser(mInstallAppIntent, mWorkProfile);
            return;
        }
        if (!mInstalledInPersonal) {
        if (mInstallAppIntent != null
                && !mInstalledInPersonal
                && isInstallableInProfile(mInstallAppIntent, mPersonalProfile)) {
            logEvent(DevicePolicyEnums.CROSS_PROFILE_SETTINGS_PAGE_INSTALL_BANNER_CLICKED);
            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,
                                    mAppLabel),
                            mAppLabel));
            if (mInstallAppIntent != null) {
            if (mInstallAppIntent != null
                    && isInstallableInProfile(mInstallAppIntent, mPersonalProfile)) {
                mInstallBanner.setSummary(
                        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,
                                    mAppLabel),
                            mAppLabel));
            if (mInstallAppIntent != null) {
            if (mInstallAppIntent != null
                    && isInstallableInProfile(mInstallAppIntent, mWorkProfile)) {
                mInstallBanner.setSummary(
                        R.string.interact_across_profiles_install_app_summary);
            }
@@ -488,6 +491,12 @@ public class InteractAcrossProfilesDetails extends AppInfoBase
        return info != null;
    }

    private boolean isInstallableInProfile(Intent intent, UserHandle profile) {
        return !mContext.getPackageManager()
                .queryIntentActivitiesAsUser(intent, /* flags= */ 0, profile)
                .isEmpty();
    }

    private void refreshUiForConfigurableApps() {
        mInstallBanner.setVisible(false);
        mSwitchPref.setEnabled(true);