Merge "Merge "Avoid triggering support dialog in non-current user." into nyc-dev am: 5548733eb5 am: 8ebc6e80b8" into nyc-mr1-dev-plus-aosp
This commit is contained in:
committed by
Android (Google) Code Review
commit
c56c32172e
@@ -616,11 +616,12 @@ public class RestrictedLockUtils {
|
|||||||
*/
|
*/
|
||||||
public static void sendShowAdminSupportDetailsIntent(Context context, EnforcedAdmin admin) {
|
public static void sendShowAdminSupportDetailsIntent(Context context, EnforcedAdmin admin) {
|
||||||
final Intent intent = getShowAdminSupportDetailsIntent(context, admin);
|
final Intent intent = getShowAdminSupportDetailsIntent(context, admin);
|
||||||
int adminUserId = UserHandle.myUserId();
|
int targetUserId = UserHandle.myUserId();
|
||||||
if (admin.userId != UserHandle.USER_NULL) {
|
if (admin != null && admin.userId != UserHandle.USER_NULL
|
||||||
adminUserId = admin.userId;
|
&& isCurrentUserOrProfile(context, admin.userId)) {
|
||||||
|
targetUserId = admin.userId;
|
||||||
}
|
}
|
||||||
context.startActivityAsUser(intent, new UserHandle(adminUserId));
|
context.startActivityAsUser(intent, new UserHandle(targetUserId));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Intent getShowAdminSupportDetailsIntent(Context context, EnforcedAdmin admin) {
|
public static Intent getShowAdminSupportDetailsIntent(Context context, EnforcedAdmin admin) {
|
||||||
@@ -638,6 +639,28 @@ public class RestrictedLockUtils {
|
|||||||
return intent;
|
return intent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isCurrentUserOrProfile(Context context, int userId) {
|
||||||
|
UserManager um = UserManager.get(context);
|
||||||
|
for (UserInfo userInfo : um.getProfiles(UserHandle.myUserId())) {
|
||||||
|
if (userInfo.id == userId) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isAdminInCurrentUserOrProfile(Context context, ComponentName admin) {
|
||||||
|
DevicePolicyManager dpm = (DevicePolicyManager) context.getSystemService(
|
||||||
|
Context.DEVICE_POLICY_SERVICE);
|
||||||
|
UserManager um = UserManager.get(context);
|
||||||
|
for (UserInfo userInfo : um.getProfiles(UserHandle.myUserId())) {
|
||||||
|
if (dpm.isAdminActiveAsUser(admin, userInfo.id)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public static void setTextViewPadlock(Context context,
|
public static void setTextViewPadlock(Context context,
|
||||||
TextView textView, boolean showPadlock) {
|
TextView textView, boolean showPadlock) {
|
||||||
final SpannableStringBuilder sb = new SpannableStringBuilder(textView.getText());
|
final SpannableStringBuilder sb = new SpannableStringBuilder(textView.getText());
|
||||||
|
|||||||
Reference in New Issue
Block a user