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

Commit 5c39238a authored by Alex Johnston's avatar Alex Johnston Committed by Android (Google) Code Review
Browse files

Merge "Prevent location for the work profile from being enabled"

parents a2666574 1867db33
Loading
Loading
Loading
Loading
+9 −8
Original line number Diff line number Diff line
@@ -67,21 +67,22 @@ public class LocationForWorkPreferenceController extends LocationBasePreferenceC
        final RestrictedLockUtils.EnforcedAdmin admin =
                mLocationEnabler.getShareLocationEnforcedAdmin(
                        Utils.getManagedProfile(mUserManager).getIdentifier());
        final boolean isRestrictedByBase = mLocationEnabler.isManagedProfileRestrictedByBase();
        if (!isRestrictedByBase && admin != null) {
        if (admin != null) {
            mPreference.setDisabledByAdmin(admin);
            mPreference.setChecked(false);
        } else {
            final boolean enabled = mLocationEnabler.isEnabled(mode);
            mPreference.setEnabled(enabled);
            int summaryResId;

            int summaryResId = R.string.switch_off_text;
            if (!enabled) {
            final boolean isRestrictedByBase =
                    mLocationEnabler.isManagedProfileRestrictedByBase();
            if (isRestrictedByBase || !enabled) {
                mPreference.setChecked(false);
                summaryResId = enabled ? R.string.switch_off_text
                        : R.string.location_app_permission_summary_location_off;
            } else {
                mPreference.setChecked(!isRestrictedByBase);
                summaryResId = (isRestrictedByBase ?
                        R.string.switch_off_text : R.string.switch_on_text);
                mPreference.setChecked(true);
                summaryResId = R.string.switch_on_text;
            }
            mPreference.setSummary(summaryResId);
        }