Skip to content

Commit ba75e97

Browse files
jscott1989pfmaggi
authored andcommitted
No public description
PiperOrigin-RevId: 595643197
1 parent e03e9c6 commit ba75e97

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

src/main/java/com/afwsamples/testdpc/policy/PolicyManagementFragment.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -756,13 +756,7 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
756756
findPreference(SHOW_WIFI_MAC_ADDRESS_KEY).setOnPreferenceClickListener(this);
757757
mInstallNonMarketAppsPreference =
758758
(DpcSwitchPreference) findPreference(INSTALL_NONMARKET_APPS_KEY);
759-
mInstallNonMarketAppsPreference.setCustomConstraint(
760-
() ->
761-
(mUserManager.hasUserRestriction(DISALLOW_INSTALL_UNKNOWN_SOURCES)
762-
|| mUserManager.hasUserRestriction(
763-
UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES_GLOBALLY))
764-
? R.string.user_restricted
765-
: NO_CUSTOM_CONSTRAINT);
759+
mInstallNonMarketAppsPreference.setCustomConstraint(this::validateInstallNonMarketApps);
766760
mInstallNonMarketAppsPreference.setOnPreferenceChangeListener(this);
767761
findPreference(SET_USER_RESTRICTIONS_KEY).setOnPreferenceClickListener(this);
768762
mUserRestrictionsParentPreference =
@@ -4697,6 +4691,18 @@ private int validateDeviceOwnerOrDelegationNetworkLoggingBeforeS() {
46974691
return NO_CUSTOM_CONSTRAINT;
46984692
}
46994693

4694+
private int validateInstallNonMarketApps() {
4695+
if (Util.SDK_INT >= VERSION_CODES.O
4696+
&& getActivity().getApplicationInfo().targetSdkVersion >= VERSION_CODES.O) {
4697+
return R.string.deprecated_since_oreo;
4698+
}
4699+
if (mUserManager.hasUserRestriction(UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES_GLOBALLY)
4700+
|| mUserManager.hasUserRestriction(DISALLOW_INSTALL_UNKNOWN_SOURCES)) {
4701+
return R.string.user_restricted;
4702+
}
4703+
return NO_CUSTOM_CONSTRAINT;
4704+
}
4705+
47004706
interface ManageLockTaskListCallback {
47014707
void onPositiveButtonClicked(String[] lockTaskArray);
47024708
}

src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@
112112
<string name="requires_device_owner_or_delegation_security_logging">Requires device owner or delegation-security-logging</string>
113113

114114
<string name="not_for_parent_profile">Not applicable to parent profile</string>
115+
<string name="deprecated_since_oreo">Deprecated since Android Oreo</string>
115116
<string name="user_restricted">Disallowed by user restriction</string>
116117
<string name="requires_network_logs">Requires network logging to be enabled</string>
117118
<string name="requires_security_logs">Requires security logging to be enabled</string>

0 commit comments

Comments
 (0)