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

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

Merge "Fix InteratAcrossProfilesDetails window leak" into main

parents 1749bc27 9472fee0
Loading
Loading
Loading
Loading
+25 −6
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import static android.provider.Settings.Global.CONNECTED_APPS_ALLOWED_PACKAGES;
import static android.provider.Settings.Global.CONNECTED_APPS_DISALLOWED_PACKAGES;

import android.Manifest;
import android.annotation.Nullable;
import android.annotation.UserIdInt;
import android.app.ActionBar;
import android.app.AppOpsManager;
@@ -107,6 +108,8 @@ public class InteractAcrossProfilesDetails extends AppInfoBase
    private String mAppLabel;
    private Intent mInstallAppIntent;
    private boolean mIsPageLaunchedByApp;
    @Nullable
    private AlertDialog mDialog = null;

    @Override
    public void onCreate(Bundle savedInstanceState) {
@@ -307,6 +310,9 @@ public class InteractAcrossProfilesDetails extends AppInfoBase
    }

    private void showConsentDialog() {
        if (mDialog != null && mDialog.isShowing()) {
            mDialog.dismiss();
        }
        final View dialogView = getLayoutInflater().inflate(
                R.layout.interact_across_profiles_consent_dialog, null);

@@ -343,13 +349,14 @@ public class InteractAcrossProfilesDetails extends AppInfoBase
        }

        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        builder.setView(dialogView)
        mDialog = builder.setView(dialogView)
                .setPositiveButton(R.string.allow, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        logEvent(DevicePolicyEnums.CROSS_PROFILE_SETTINGS_PAGE_USER_CONSENTED);
                        enableInteractAcrossProfiles(true);
                        refreshUi();
                        if (mIsPageLaunchedByApp) {
                            dialog.dismiss();
                            setIntentAndFinish(/* appChanged= */ true);
                        }
                    }
@@ -361,7 +368,8 @@ public class InteractAcrossProfilesDetails extends AppInfoBase
                        refreshUi();
                    }
                })
                .create().show();
                .create();
        mDialog.show();
    }

    private boolean isInteractAcrossProfilesEnabled() {
@@ -536,7 +544,8 @@ public class InteractAcrossProfilesDetails extends AppInfoBase
        mSwitchPref.setChecked(true);
        mSwitchPref.setTitle(R.string.interact_across_profiles_switch_enabled);
        final ImageView horizontalArrowIcon =
                mHeader.findViewById(com.android.settingslib.widget.preference.layout.R.id.entity_header_swap_horiz);
                mHeader.findViewById(
                        com.android.settingslib.widget.preference.layout.R.id.entity_header_swap_horiz);
        if (horizontalArrowIcon != null) {
            horizontalArrowIcon.setImageDrawable(
                    mContext.getDrawable(
@@ -548,7 +557,8 @@ public class InteractAcrossProfilesDetails extends AppInfoBase
        mSwitchPref.setChecked(false);
        mSwitchPref.setTitle(R.string.interact_across_profiles_switch_disabled);
        final ImageView horizontalArrowIcon =
                mHeader.findViewById(com.android.settingslib.widget.preference.layout.R.id.entity_header_swap_horiz);
                mHeader.findViewById(
                        com.android.settingslib.widget.preference.layout.R.id.entity_header_swap_horiz);
        if (horizontalArrowIcon != null) {
            horizontalArrowIcon.setImageDrawable(
                    mContext.getDrawable(
@@ -556,6 +566,15 @@ public class InteractAcrossProfilesDetails extends AppInfoBase
        }
    }

    @Override
    public void onDestroy() {
        if (mDialog != null) {
            mDialog.dismiss();
        }
        mDialog = null;
        super.onDestroy();
    }

    @Override
    protected AlertDialog createDialog(int id, int errorCode) {
        return null;