Policy transparency dialog should be shown when SwitchBar is restricted.

After ag/3818911, touch event of Switchbar is delegated to the switch.
When the SwithBar is disabled by admin, switch is GONE and restricted icon
is VISIBLE instead. We should let touch event be delegaed to restricted
icon and show policy transparency dialog when it's clicked in this case.

Cherry-picked from ag/3924516.

Bug: 77898233
Bug: 70206452
Test: Manually via setting disallow_share_location in TestDPC.

Change-Id: Ifa4fa6ebbe7986277f5cd0951a399ea2377a39f9
This commit is contained in:
yuemingw
2018-05-01 18:38:10 +01:00
committed by Yueming Wang
parent 07ec1d47df
commit 69fa9e0d49
2 changed files with 36 additions and 2 deletions

View File

@@ -26,6 +26,7 @@ import android.widget.TextView;
import com.android.settings.R;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -82,4 +83,16 @@ public class SwitchBarTest {
assertThat(((TextView) mBar.findViewById(R.id.switch_text)).getText())
.isEqualTo(mContext.getString(onText));
}
@Test
public void disabledByAdmin_shouldDelegateToRestrictedIcon() {
mBar.setDisabledByAdmin(new EnforcedAdmin());
assertThat(mBar.getDelegatingView().getId()).isEqualTo(R.id.restricted_icon);
}
@Test
public void notDisabledByAdmin_shouldDelegateToSwitch() {
mBar.setDisabledByAdmin(null);
assertThat(mBar.getDelegatingView().getId()).isEqualTo(R.id.switch_widget);
}
}