Merge "Don't notify about explicit personal app suspension." into rvc-dev am: e39a7b6a80 am: e68a57ee7c
Change-Id: Ic91033873e1b3aba4b13988fce40688873c64877
This commit is contained in:
@@ -441,11 +441,23 @@
|
|||||||
<!-- A toast message displayed when printing is attempted but disabled by policy. -->
|
<!-- A toast message displayed when printing is attempted but disabled by policy. -->
|
||||||
<string name="printing_disabled_by">Printing disabled by <xliff:g id="owner_app">%s</xliff:g>.</string>
|
<string name="printing_disabled_by">Printing disabled by <xliff:g id="owner_app">%s</xliff:g>.</string>
|
||||||
|
|
||||||
<!-- Content title for a notification that personal apps are suspended [CHAR LIMIT=NONE] -->
|
<!-- Notification title. This notification lets a user know that their personal apps are
|
||||||
<string name="personal_apps_suspended_notification_title">Personal apps have been suspended by an admin</string>
|
blocked due to a work policy from their IT admin, and tells them what they need to do
|
||||||
|
to unblock their apps.[CHAR LIMIT=29] -->
|
||||||
<!-- Message for a notification about personal apps suspension when work profile is off. [CHAR LIMIT=NONE] -->
|
<string name="personal_apps_suspended_title">Unblock your personal apps</string>
|
||||||
<string name="personal_apps_suspended_notification_text">Tap here to check policy compliance.</string>
|
<!-- Notification title. This notification lets a user know that their apps will be blocked
|
||||||
|
tomorrow due to a work policy from their IT admin, and tells them what they need to do to
|
||||||
|
prevent the apps from being blocked. [CHAR LIMIT=29] -->
|
||||||
|
<string name="personal_apps_suspended_tomorrow_title">Apps will be blocked tomorrow</string>
|
||||||
|
<!-- Notification text. This notification lets a user know that they need to turn on their
|
||||||
|
work profile due to a work policy from their IT admin. The number of days is at least 3.
|
||||||
|
[CHAR LIMIT=NONE] -->
|
||||||
|
<string name="personal_apps_suspended_text">Your IT admin doesn\u2019t allow your
|
||||||
|
work profile to be paused for more than <xliff:g id="days" example="3">%1$d</xliff:g>
|
||||||
|
days</string>
|
||||||
|
<!-- Title for the button that turns work profile on. To be used in a notification
|
||||||
|
[CHAR LIMIT=NONE] -->
|
||||||
|
<string name="personal_apps_suspended_turn_profile_on">Turn on work profile</string>
|
||||||
|
|
||||||
<!-- Display name for any time a piece of data refers to the owner of the phone. For example, this could be used in place of the phone's phone number. -->
|
<!-- Display name for any time a piece of data refers to the owner of the phone. For example, this could be used in place of the phone's phone number. -->
|
||||||
<string name="me">Me</string>
|
<string name="me">Me</string>
|
||||||
|
|||||||
@@ -1194,8 +1194,9 @@
|
|||||||
<java-symbol type="string" name="network_logging_notification_text" />
|
<java-symbol type="string" name="network_logging_notification_text" />
|
||||||
<java-symbol type="string" name="location_changed_notification_title" />
|
<java-symbol type="string" name="location_changed_notification_title" />
|
||||||
<java-symbol type="string" name="location_changed_notification_text" />
|
<java-symbol type="string" name="location_changed_notification_text" />
|
||||||
<java-symbol type="string" name="personal_apps_suspended_notification_title" />
|
<java-symbol type="string" name="personal_apps_suspended_title" />
|
||||||
<java-symbol type="string" name="personal_apps_suspended_notification_text" />
|
<java-symbol type="string" name="personal_apps_suspended_tomorrow_title" />
|
||||||
|
<java-symbol type="string" name="personal_apps_suspended_text" />
|
||||||
<java-symbol type="string" name="factory_reset_warning" />
|
<java-symbol type="string" name="factory_reset_warning" />
|
||||||
<java-symbol type="string" name="factory_reset_message" />
|
<java-symbol type="string" name="factory_reset_message" />
|
||||||
<java-symbol type="string" name="lockscreen_transport_play_description" />
|
<java-symbol type="string" name="lockscreen_transport_play_description" />
|
||||||
|
|||||||
@@ -15662,19 +15662,25 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
|
|||||||
if (!userData.mAppsSuspended) {
|
if (!userData.mAppsSuspended) {
|
||||||
return PERSONAL_APPS_NOT_SUSPENDED;
|
return PERSONAL_APPS_NOT_SUSPENDED;
|
||||||
} else {
|
} else {
|
||||||
int reasons = PERSONAL_APPS_NOT_SUSPENDED;
|
|
||||||
if (admin.mSuspendPersonalApps) {
|
|
||||||
reasons |= PERSONAL_APPS_SUSPENDED_EXPLICITLY;
|
|
||||||
}
|
|
||||||
final long deadline = admin.mProfileOffDeadline;
|
final long deadline = admin.mProfileOffDeadline;
|
||||||
if (deadline != 0 && System.currentTimeMillis() > deadline) {
|
return makeSuspensionReasons(admin.mSuspendPersonalApps,
|
||||||
reasons |= PERSONAL_APPS_SUSPENDED_PROFILE_TIMEOUT;
|
deadline != 0 && System.currentTimeMillis() > deadline);
|
||||||
}
|
|
||||||
return reasons;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private @PersonalAppSuspensionReason int makeSuspensionReasons(
|
||||||
|
boolean explicit, boolean timeout) {
|
||||||
|
int result = PERSONAL_APPS_NOT_SUSPENDED;
|
||||||
|
if (explicit) {
|
||||||
|
result |= PERSONAL_APPS_SUSPENDED_EXPLICITLY;
|
||||||
|
}
|
||||||
|
if (timeout) {
|
||||||
|
result |= PERSONAL_APPS_SUSPENDED_PROFILE_TIMEOUT;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPersonalAppsSuspended(ComponentName who, boolean suspended) {
|
public void setPersonalAppsSuspended(ComponentName who, boolean suspended) {
|
||||||
final int callingUserId = mInjector.userHandleGetCallingUserId();
|
final int callingUserId = mInjector.userHandleGetCallingUserId();
|
||||||
@@ -15700,7 +15706,8 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mInjector.binderWithCleanCallingIdentity(
|
mInjector.binderWithCleanCallingIdentity(
|
||||||
() -> applyPersonalAppsSuspension(callingUserId, suspended));
|
() -> applyPersonalAppsSuspension(
|
||||||
|
callingUserId, PERSONAL_APPS_SUSPENDED_EXPLICITLY));
|
||||||
|
|
||||||
DevicePolicyEventLogger
|
DevicePolicyEventLogger
|
||||||
.createEvent(DevicePolicyEnums.SET_PERSONAL_APPS_SUSPENDED)
|
.createEvent(DevicePolicyEnums.SET_PERSONAL_APPS_SUSPENDED)
|
||||||
@@ -15715,22 +15722,22 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
|
|||||||
* @param running whether the profile is currently considered running.
|
* @param running whether the profile is currently considered running.
|
||||||
*/
|
*/
|
||||||
private void updatePersonalAppSuspension(int profileUserId, boolean running) {
|
private void updatePersonalAppSuspension(int profileUserId, boolean running) {
|
||||||
final boolean shouldSuspend;
|
final int suspensionState;
|
||||||
synchronized (getLockObject()) {
|
synchronized (getLockObject()) {
|
||||||
final ActiveAdmin profileOwner = getProfileOwnerAdminLocked(profileUserId);
|
final ActiveAdmin profileOwner = getProfileOwnerAdminLocked(profileUserId);
|
||||||
if (profileOwner != null) {
|
if (profileOwner != null) {
|
||||||
final boolean deadlineReached =
|
final boolean deadlineReached =
|
||||||
updateProfileOffDeadlineLocked(profileUserId, profileOwner, running);
|
updateProfileOffDeadlineLocked(profileUserId, profileOwner, running);
|
||||||
shouldSuspend = deadlineReached || profileOwner.mSuspendPersonalApps;
|
suspensionState = makeSuspensionReasons(
|
||||||
Slog.d(LOG_TAG, String.format(
|
profileOwner.mSuspendPersonalApps, deadlineReached);
|
||||||
"Should personal use be suspended: %b; explicit: %b; timeout: %b",
|
Slog.d(LOG_TAG,
|
||||||
shouldSuspend, profileOwner.mSuspendPersonalApps, deadlineReached));
|
String.format("New personal apps suspension state: %d", suspensionState));
|
||||||
} else {
|
} else {
|
||||||
shouldSuspend = false;
|
suspensionState = PERSONAL_APPS_NOT_SUSPENDED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
applyPersonalAppsSuspension(profileUserId, shouldSuspend);
|
applyPersonalAppsSuspension(profileUserId, suspensionState);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -15785,13 +15792,15 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void applyPersonalAppsSuspension(int profileUserId, boolean shouldSuspend) {
|
private void applyPersonalAppsSuspension(
|
||||||
|
int profileUserId, @PersonalAppSuspensionReason int suspensionState) {
|
||||||
final boolean suspended = getUserData(UserHandle.USER_SYSTEM).mAppsSuspended;
|
final boolean suspended = getUserData(UserHandle.USER_SYSTEM).mAppsSuspended;
|
||||||
|
final boolean shouldSuspend = suspensionState != PERSONAL_APPS_NOT_SUSPENDED;
|
||||||
if (suspended != shouldSuspend) {
|
if (suspended != shouldSuspend) {
|
||||||
suspendPersonalAppsInternal(shouldSuspend, UserHandle.USER_SYSTEM);
|
suspendPersonalAppsInternal(shouldSuspend, UserHandle.USER_SYSTEM);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shouldSuspend) {
|
if (suspensionState == PERSONAL_APPS_SUSPENDED_PROFILE_TIMEOUT) {
|
||||||
sendPersonalAppsSuspendedNotification(profileUserId);
|
sendPersonalAppsSuspendedNotification(profileUserId);
|
||||||
} else {
|
} else {
|
||||||
clearPersonalAppsSuspendedNotification();
|
clearPersonalAppsSuspendedNotification();
|
||||||
@@ -15832,8 +15841,11 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
|
|||||||
|
|
||||||
private void sendPersonalAppsSuspendedNotification(int userId) {
|
private void sendPersonalAppsSuspendedNotification(int userId) {
|
||||||
final String profileOwnerPackageName;
|
final String profileOwnerPackageName;
|
||||||
|
final long maxTimeOffDays;
|
||||||
synchronized (getLockObject()) {
|
synchronized (getLockObject()) {
|
||||||
profileOwnerPackageName = mOwners.getProfileOwnerComponent(userId).getPackageName();
|
profileOwnerPackageName = mOwners.getProfileOwnerComponent(userId).getPackageName();
|
||||||
|
final ActiveAdmin poAdmin = getProfileOwnerAdminLocked(userId);
|
||||||
|
maxTimeOffDays = TimeUnit.MILLISECONDS.toDays(poAdmin.mProfileMaximumTimeOffMillis);
|
||||||
}
|
}
|
||||||
|
|
||||||
final Intent intent = new Intent(DevicePolicyManager.ACTION_CHECK_POLICY_COMPLIANCE);
|
final Intent intent = new Intent(DevicePolicyManager.ACTION_CHECK_POLICY_COMPLIANCE);
|
||||||
@@ -15849,9 +15861,9 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
|
|||||||
.setOngoing(true)
|
.setOngoing(true)
|
||||||
.setContentTitle(
|
.setContentTitle(
|
||||||
mContext.getString(
|
mContext.getString(
|
||||||
R.string.personal_apps_suspended_notification_title))
|
R.string.personal_apps_suspended_title))
|
||||||
.setContentText(mContext.getString(
|
.setContentText(mContext.getString(
|
||||||
R.string.personal_apps_suspended_notification_text))
|
R.string.personal_apps_suspended_text, maxTimeOffDays))
|
||||||
.setColor(mContext.getColor(R.color.system_notification_accent_color))
|
.setColor(mContext.getColor(R.color.system_notification_accent_color))
|
||||||
.setContentIntent(pendingIntent)
|
.setContentIntent(pendingIntent)
|
||||||
.build();
|
.build();
|
||||||
|
|||||||
Reference in New Issue
Block a user