Loading res/values/config.xml +3 −0 Original line number Diff line number Diff line Loading @@ -414,4 +414,7 @@ <!-- List containing the injected tile keys which are suppressed. --> <string-array name="config_suppress_injected_tile_keys" translatable="false"/> <!-- "Show work policy info" intent action. TODO(b/134391103): Replace with final SystemAPI intent when it's available. --> <string name="config_work_policy_info_intent_action" translatable="false"/> </resources> res/values/strings.xml +6 −0 Original line number Diff line number Diff line Loading @@ -11326,4 +11326,10 @@ <!-- Title for enable MMS notification channel. [CHAR LIMIT=40] --> <string name="dual_cdma_sim_warning_notification_channel_title">SIM combination</string> <!-- Title of setting on privacy settings screen that will show work policy info. [CHAR LIMIT=NONE] --> <string name="work_policy_privacy_settings">Your work policy info</string> <!-- Summary for Enterprise Privacy settings, explaining what the user can expect to find under it [CHAR LIMIT=NONE]--> <string name="work_policy_privacy_settings_summary">Settings managed by your IT admin</string> </resources> res/xml/privacy_dashboard_settings.xml +9 −1 Original line number Diff line number Diff line Loading @@ -29,6 +29,14 @@ android:title="@string/summary_placeholder" settings:controller="com.android.settings.privacy.PermissionBarChartPreferenceController"/> <!-- Work Policy info --> <Preference android:key="work_policy_info" android:title="@string/work_policy_privacy_settings" android:summary="@string/work_policy_privacy_settings_summary" settings:allowDividerAbove="true" settings:controller="com.android.settings.privacy.WorkPolicyInfoPreferenceController"/> <!-- Accessibility usage --> <Preference android:key="privacy_accessibility_usage" Loading src/com/android/settings/enterprise/EnterprisePrivacyFeatureProvider.java +13 −0 Original line number Diff line number Diff line Loading @@ -124,4 +124,17 @@ public interface EnterprisePrivacyFeatureProvider { * profile (if any). */ int getNumberOfActiveDeviceAdminsForCurrentUserAndManagedProfile(); /** * Returns {@code true} if it is possilbe to resolve an Intent to launch the "Your work policy * info" page provided by the active Device Owner or Profile Owner app if it exists, {@code * false} otherwise. */ boolean hasWorkPolicyInfo(); /** * Launches the Device Owner or Profile Owner's activity that displays the "Your work policy * info" page. Returns {@code true} if the activity has indeed been launched. */ boolean showWorkPolicyInfo(); } src/com/android/settings/enterprise/EnterprisePrivacyFeatureProviderImpl.java +90 −13 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.pm.UserInfo; import android.content.res.Resources; import android.net.ConnectivityManager; Loading Loading @@ -61,19 +62,7 @@ public class EnterprisePrivacyFeatureProviderImpl implements EnterprisePrivacyFe @Override public boolean hasDeviceOwner() { if (!mPm.hasSystemFeature(PackageManager.FEATURE_DEVICE_ADMIN)) { return false; } return mDpm.getDeviceOwnerComponentOnAnyUser() != null; } private int getManagedProfileUserId() { for (final UserInfo userInfo : mUm.getProfiles(MY_USER_ID)) { if (userInfo.isManagedProfile()) { return userInfo.id; } } return UserHandle.USER_NULL; return getDeviceOwnerComponent() != null; } @Override Loading Loading @@ -234,6 +223,94 @@ public class EnterprisePrivacyFeatureProviderImpl implements EnterprisePrivacyFe return activeAdmins; } @Override public boolean hasWorkPolicyInfo() { return (getWorkPolicyInfoIntentDO() != null) || (getWorkPolicyInfoIntentPO() != null); } @Override public boolean showWorkPolicyInfo() { Intent intent = getWorkPolicyInfoIntentDO(); if (intent != null) { mContext.startActivity(intent); return true; } intent = getWorkPolicyInfoIntentPO(); final UserInfo userInfo = getManagedProfileUserInfo(); if (intent != null && userInfo != null) { mContext.startActivityAsUser(intent, userInfo.getUserHandle()); return true; } return false; } private ComponentName getDeviceOwnerComponent() { if (!mPm.hasSystemFeature(PackageManager.FEATURE_DEVICE_ADMIN)) { return null; } return mDpm.getDeviceOwnerComponentOnAnyUser(); } private UserInfo getManagedProfileUserInfo() { for (final UserInfo userInfo : mUm.getProfiles(MY_USER_ID)) { if (userInfo.isManagedProfile()) { return userInfo; } } return null; } private int getManagedProfileUserId() { final UserInfo userInfo = getManagedProfileUserInfo(); if (userInfo != null) { return userInfo.id; } return UserHandle.USER_NULL; } private Intent getWorkPolicyInfoIntentDO() { final ComponentName ownerComponent = getDeviceOwnerComponent(); if (ownerComponent == null) { return null; } // Only search for the required action in the Device Owner's package final Intent intent = new Intent(mResources.getString(R.string.config_work_policy_info_intent_action)) .setPackage(ownerComponent.getPackageName()); final List<ResolveInfo> activities = mPm.queryIntentActivities(intent, 0); if (activities.size() != 0) { return intent; } return null; } private Intent getWorkPolicyInfoIntentPO() { final int userId = getManagedProfileUserId(); if (userId == UserHandle.USER_NULL) { return null; } final ComponentName ownerComponent = mDpm.getProfileOwnerAsUser(userId); if (ownerComponent == null) { return null; } // Only search for the required action in the Profile Owner's package final Intent intent = new Intent(mResources.getString(R.string.config_work_policy_info_intent_action)) .setPackage(ownerComponent.getPackageName()); final List<ResolveInfo> activities = mPm.queryIntentActivitiesAsUser(intent, 0, userId); if (activities.size() != 0) { return intent; } return null; } protected static class EnterprisePrivacySpan extends ClickableSpan { private final Context mContext; Loading Loading
res/values/config.xml +3 −0 Original line number Diff line number Diff line Loading @@ -414,4 +414,7 @@ <!-- List containing the injected tile keys which are suppressed. --> <string-array name="config_suppress_injected_tile_keys" translatable="false"/> <!-- "Show work policy info" intent action. TODO(b/134391103): Replace with final SystemAPI intent when it's available. --> <string name="config_work_policy_info_intent_action" translatable="false"/> </resources>
res/values/strings.xml +6 −0 Original line number Diff line number Diff line Loading @@ -11326,4 +11326,10 @@ <!-- Title for enable MMS notification channel. [CHAR LIMIT=40] --> <string name="dual_cdma_sim_warning_notification_channel_title">SIM combination</string> <!-- Title of setting on privacy settings screen that will show work policy info. [CHAR LIMIT=NONE] --> <string name="work_policy_privacy_settings">Your work policy info</string> <!-- Summary for Enterprise Privacy settings, explaining what the user can expect to find under it [CHAR LIMIT=NONE]--> <string name="work_policy_privacy_settings_summary">Settings managed by your IT admin</string> </resources>
res/xml/privacy_dashboard_settings.xml +9 −1 Original line number Diff line number Diff line Loading @@ -29,6 +29,14 @@ android:title="@string/summary_placeholder" settings:controller="com.android.settings.privacy.PermissionBarChartPreferenceController"/> <!-- Work Policy info --> <Preference android:key="work_policy_info" android:title="@string/work_policy_privacy_settings" android:summary="@string/work_policy_privacy_settings_summary" settings:allowDividerAbove="true" settings:controller="com.android.settings.privacy.WorkPolicyInfoPreferenceController"/> <!-- Accessibility usage --> <Preference android:key="privacy_accessibility_usage" Loading
src/com/android/settings/enterprise/EnterprisePrivacyFeatureProvider.java +13 −0 Original line number Diff line number Diff line Loading @@ -124,4 +124,17 @@ public interface EnterprisePrivacyFeatureProvider { * profile (if any). */ int getNumberOfActiveDeviceAdminsForCurrentUserAndManagedProfile(); /** * Returns {@code true} if it is possilbe to resolve an Intent to launch the "Your work policy * info" page provided by the active Device Owner or Profile Owner app if it exists, {@code * false} otherwise. */ boolean hasWorkPolicyInfo(); /** * Launches the Device Owner or Profile Owner's activity that displays the "Your work policy * info" page. Returns {@code true} if the activity has indeed been launched. */ boolean showWorkPolicyInfo(); }
src/com/android/settings/enterprise/EnterprisePrivacyFeatureProviderImpl.java +90 −13 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.pm.UserInfo; import android.content.res.Resources; import android.net.ConnectivityManager; Loading Loading @@ -61,19 +62,7 @@ public class EnterprisePrivacyFeatureProviderImpl implements EnterprisePrivacyFe @Override public boolean hasDeviceOwner() { if (!mPm.hasSystemFeature(PackageManager.FEATURE_DEVICE_ADMIN)) { return false; } return mDpm.getDeviceOwnerComponentOnAnyUser() != null; } private int getManagedProfileUserId() { for (final UserInfo userInfo : mUm.getProfiles(MY_USER_ID)) { if (userInfo.isManagedProfile()) { return userInfo.id; } } return UserHandle.USER_NULL; return getDeviceOwnerComponent() != null; } @Override Loading Loading @@ -234,6 +223,94 @@ public class EnterprisePrivacyFeatureProviderImpl implements EnterprisePrivacyFe return activeAdmins; } @Override public boolean hasWorkPolicyInfo() { return (getWorkPolicyInfoIntentDO() != null) || (getWorkPolicyInfoIntentPO() != null); } @Override public boolean showWorkPolicyInfo() { Intent intent = getWorkPolicyInfoIntentDO(); if (intent != null) { mContext.startActivity(intent); return true; } intent = getWorkPolicyInfoIntentPO(); final UserInfo userInfo = getManagedProfileUserInfo(); if (intent != null && userInfo != null) { mContext.startActivityAsUser(intent, userInfo.getUserHandle()); return true; } return false; } private ComponentName getDeviceOwnerComponent() { if (!mPm.hasSystemFeature(PackageManager.FEATURE_DEVICE_ADMIN)) { return null; } return mDpm.getDeviceOwnerComponentOnAnyUser(); } private UserInfo getManagedProfileUserInfo() { for (final UserInfo userInfo : mUm.getProfiles(MY_USER_ID)) { if (userInfo.isManagedProfile()) { return userInfo; } } return null; } private int getManagedProfileUserId() { final UserInfo userInfo = getManagedProfileUserInfo(); if (userInfo != null) { return userInfo.id; } return UserHandle.USER_NULL; } private Intent getWorkPolicyInfoIntentDO() { final ComponentName ownerComponent = getDeviceOwnerComponent(); if (ownerComponent == null) { return null; } // Only search for the required action in the Device Owner's package final Intent intent = new Intent(mResources.getString(R.string.config_work_policy_info_intent_action)) .setPackage(ownerComponent.getPackageName()); final List<ResolveInfo> activities = mPm.queryIntentActivities(intent, 0); if (activities.size() != 0) { return intent; } return null; } private Intent getWorkPolicyInfoIntentPO() { final int userId = getManagedProfileUserId(); if (userId == UserHandle.USER_NULL) { return null; } final ComponentName ownerComponent = mDpm.getProfileOwnerAsUser(userId); if (ownerComponent == null) { return null; } // Only search for the required action in the Profile Owner's package final Intent intent = new Intent(mResources.getString(R.string.config_work_policy_info_intent_action)) .setPackage(ownerComponent.getPackageName()); final List<ResolveInfo> activities = mPm.queryIntentActivitiesAsUser(intent, 0, userId); if (activities.size() != 0) { return intent; } return null; } protected static class EnterprisePrivacySpan extends ClickableSpan { private final Context mContext; Loading