Merge changes Ibc9d5374,I28a14ab9 into tm-qpr-dev
* changes: Fix parental control dialog Fix NPE in QSSecurityFooterUtils
This commit is contained in:
committed by
Android (Google) Code Review
commit
b81944dee2
@@ -247,7 +247,7 @@ public class QSSecurityFooterUtils implements DialogInterface.OnClickListener {
|
|||||||
|
|
||||||
Icon icon;
|
Icon icon;
|
||||||
ContentDescription contentDescription = null;
|
ContentDescription contentDescription = null;
|
||||||
if (isParentalControlsEnabled) {
|
if (isParentalControlsEnabled && securityModel.getDeviceAdminIcon() != null) {
|
||||||
icon = new Icon.Loaded(securityModel.getDeviceAdminIcon(), contentDescription);
|
icon = new Icon.Loaded(securityModel.getDeviceAdminIcon(), contentDescription);
|
||||||
} else if (vpnName != null || vpnNameWorkProfile != null) {
|
} else if (vpnName != null || vpnNameWorkProfile != null) {
|
||||||
if (securityModel.isVpnBranded()) {
|
if (securityModel.isVpnBranded()) {
|
||||||
@@ -476,7 +476,7 @@ public class QSSecurityFooterUtils implements DialogInterface.OnClickListener {
|
|||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
View createDialogView(Context quickSettingsContext) {
|
View createDialogView(Context quickSettingsContext) {
|
||||||
if (mSecurityController.isParentalControlsEnabled()) {
|
if (mSecurityController.isParentalControlsEnabled()) {
|
||||||
return createParentalControlsDialogView();
|
return createParentalControlsDialogView(quickSettingsContext);
|
||||||
}
|
}
|
||||||
return createOrganizationDialogView(quickSettingsContext);
|
return createOrganizationDialogView(quickSettingsContext);
|
||||||
}
|
}
|
||||||
@@ -579,8 +579,8 @@ public class QSSecurityFooterUtils implements DialogInterface.OnClickListener {
|
|||||||
return dialogView;
|
return dialogView;
|
||||||
}
|
}
|
||||||
|
|
||||||
private View createParentalControlsDialogView() {
|
private View createParentalControlsDialogView(Context quickSettingsContext) {
|
||||||
View dialogView = LayoutInflater.from(mContext)
|
View dialogView = LayoutInflater.from(quickSettingsContext)
|
||||||
.inflate(R.layout.quick_settings_footer_dialog_parental_controls, null, false);
|
.inflate(R.layout.quick_settings_footer_dialog_parental_controls, null, false);
|
||||||
|
|
||||||
DeviceAdminInfo info = mSecurityController.getDeviceAdminInfo();
|
DeviceAdminInfo info = mSecurityController.getDeviceAdminInfo();
|
||||||
|
|||||||
@@ -703,28 +703,32 @@ public class QSSecurityFooterTest extends SysuiTestCase {
|
|||||||
public void testParentalControls() {
|
public void testParentalControls() {
|
||||||
// Make sure the security footer is visible, so that the images are updated.
|
// Make sure the security footer is visible, so that the images are updated.
|
||||||
when(mSecurityController.isProfileOwnerOfOrganizationOwnedDevice()).thenReturn(true);
|
when(mSecurityController.isProfileOwnerOfOrganizationOwnedDevice()).thenReturn(true);
|
||||||
|
|
||||||
when(mSecurityController.isParentalControlsEnabled()).thenReturn(true);
|
when(mSecurityController.isParentalControlsEnabled()).thenReturn(true);
|
||||||
|
|
||||||
|
// We use the default icon when there is no admin icon.
|
||||||
|
when(mSecurityController.getIcon(any())).thenReturn(null);
|
||||||
|
mFooter.refreshState();
|
||||||
|
TestableLooper.get(this).processAllMessages();
|
||||||
|
assertEquals(mContext.getString(R.string.quick_settings_disclosure_parental_controls),
|
||||||
|
mFooterText.getText());
|
||||||
|
assertEquals(DEFAULT_ICON_ID, mPrimaryFooterIcon.getLastImageResource());
|
||||||
|
|
||||||
Drawable testDrawable = new VectorDrawable();
|
Drawable testDrawable = new VectorDrawable();
|
||||||
when(mSecurityController.getIcon(any())).thenReturn(testDrawable);
|
when(mSecurityController.getIcon(any())).thenReturn(testDrawable);
|
||||||
assertNotNull(mSecurityController.getIcon(null));
|
assertNotNull(mSecurityController.getIcon(null));
|
||||||
|
|
||||||
mFooter.refreshState();
|
mFooter.refreshState();
|
||||||
|
|
||||||
TestableLooper.get(this).processAllMessages();
|
TestableLooper.get(this).processAllMessages();
|
||||||
|
|
||||||
assertEquals(mContext.getString(R.string.quick_settings_disclosure_parental_controls),
|
assertEquals(mContext.getString(R.string.quick_settings_disclosure_parental_controls),
|
||||||
mFooterText.getText());
|
mFooterText.getText());
|
||||||
assertEquals(View.VISIBLE, mPrimaryFooterIcon.getVisibility());
|
assertEquals(View.VISIBLE, mPrimaryFooterIcon.getVisibility());
|
||||||
|
|
||||||
assertEquals(testDrawable, mPrimaryFooterIcon.getDrawable());
|
assertEquals(testDrawable, mPrimaryFooterIcon.getDrawable());
|
||||||
|
|
||||||
// Ensure the primary icon is back to default after parental controls are gone
|
// Ensure the primary icon is back to default after parental controls are gone
|
||||||
when(mSecurityController.isParentalControlsEnabled()).thenReturn(false);
|
when(mSecurityController.isParentalControlsEnabled()).thenReturn(false);
|
||||||
mFooter.refreshState();
|
mFooter.refreshState();
|
||||||
TestableLooper.get(this).processAllMessages();
|
TestableLooper.get(this).processAllMessages();
|
||||||
|
|
||||||
assertEquals(DEFAULT_ICON_ID, mPrimaryFooterIcon.getLastImageResource());
|
assertEquals(DEFAULT_ICON_ID, mPrimaryFooterIcon.getLastImageResource());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user