Fix 4 broken work profile tests
Commit 2953f31b61
skipped
RunSettingsRoboTests. The tests started failing because
WorkSoundPreferenceController calls UserManager.isUserUnlocked(int) now
which is not implemented in robolectric.
Fixed by adding a wrapper method to AudioHelper.
Fix: 34819603
Test: make RunSettingsRoboTests
Change-Id: Ia79cc4def9442706752f7e7b9a895ffa8150fd9d
This commit is contained in:
@@ -42,6 +42,10 @@ public class AudioHelper {
|
||||
return Utils.getManagedProfileId(um, UserHandle.myUserId());
|
||||
}
|
||||
|
||||
public boolean isUserUnlocked(UserManager um, @UserIdInt int userId) {
|
||||
return um.isUserUnlocked(userId);
|
||||
}
|
||||
|
||||
public Context createPackageContextAsUser(@UserIdInt int profileId) {
|
||||
return Utils.createPackageContextAsUser(mContext, profileId);
|
||||
}
|
||||
|
@@ -160,8 +160,8 @@ public class WorkSoundPreferenceController extends PreferenceController implemen
|
||||
}
|
||||
|
||||
private CharSequence updateRingtoneName(Context context, int type) {
|
||||
if (context == null || !UserManager.get(context).isUserUnlocked(context.getUserId())) {
|
||||
return context.getString(R.string.managed_profile_not_available_label);
|
||||
if (context == null || !mHelper.isUserUnlocked(mUserManager, context.getUserId())) {
|
||||
return mContext.getString(R.string.managed_profile_not_available_label);
|
||||
}
|
||||
Uri ringtoneUri = RingtoneManager.getActualDefaultRingtoneUri(context, type);
|
||||
return Ringtone.getTitle(context, ringtoneUri, false /* followSettingsUri */,
|
||||
|
Reference in New Issue
Block a user