Rubin Xu | 0cbc19e | 2016-12-09 14:00:21 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License |
| 15 | */ |
| 16 | |
Andrew Scull | 507d11c | 2017-05-03 17:19:01 +0100 | [diff] [blame] | 17 | package com.android.server.locksettings; |
Rubin Xu | 0cbc19e | 2016-12-09 14:00:21 +0000 | [diff] [blame] | 18 | |
| 19 | import static org.mockito.Matchers.any; |
Rubin Xu | 7b7424b | 2017-03-31 18:03:20 +0100 | [diff] [blame] | 20 | import static org.mockito.Matchers.anyBoolean; |
Rubin Xu | 0cbc19e | 2016-12-09 14:00:21 +0000 | [diff] [blame] | 21 | import static org.mockito.Matchers.anyInt; |
| 22 | import static org.mockito.Matchers.eq; |
Rubin Xu | b31be1b | 2017-06-16 17:08:21 +0100 | [diff] [blame] | 23 | import static org.mockito.Mockito.doAnswer; |
Rubin Xu | 0cbc19e | 2016-12-09 14:00:21 +0000 | [diff] [blame] | 24 | import static org.mockito.Mockito.mock; |
Rubin Xu | 0cbc19e | 2016-12-09 14:00:21 +0000 | [diff] [blame] | 25 | import static org.mockito.Mockito.when; |
| 26 | |
| 27 | import android.app.IActivityManager; |
Andrew Scull | f49794b | 2018-04-13 12:01:25 +0100 | [diff] [blame] | 28 | import android.app.KeyguardManager; |
Rubin Xu | 0cbc19e | 2016-12-09 14:00:21 +0000 | [diff] [blame] | 29 | import android.app.NotificationManager; |
Rubin Xu | 8b30ec3 | 2017-03-05 00:47:09 +0000 | [diff] [blame] | 30 | import android.app.admin.DevicePolicyManager; |
Andrew Scull | 1416bd0 | 2018-01-05 18:33:58 +0000 | [diff] [blame] | 31 | import android.app.admin.DevicePolicyManagerInternal; |
Rubin Xu | 16c823e | 2017-06-27 14:44:58 +0100 | [diff] [blame] | 32 | import android.app.trust.TrustManager; |
Rubin Xu | 8b30ec3 | 2017-03-05 00:47:09 +0000 | [diff] [blame] | 33 | import android.content.ComponentName; |
Rubin Xu | 0cbc19e | 2016-12-09 14:00:21 +0000 | [diff] [blame] | 34 | import android.content.pm.UserInfo; |
Andrew Scull | e6527c1 | 2018-01-05 18:33:58 +0000 | [diff] [blame] | 35 | import android.hardware.authsecret.V1_0.IAuthSecret; |
Rubin Xu | 0cbc19e | 2016-12-09 14:00:21 +0000 | [diff] [blame] | 36 | import android.os.FileUtils; |
Rubin Xu | 0cbc19e | 2016-12-09 14:00:21 +0000 | [diff] [blame] | 37 | import android.os.IProgressListener; |
Rubin Xu | b31be1b | 2017-06-16 17:08:21 +0100 | [diff] [blame] | 38 | import android.os.RemoteException; |
Rubin Xu | 0cbc19e | 2016-12-09 14:00:21 +0000 | [diff] [blame] | 39 | import android.os.UserManager; |
Rubin Xu | b31be1b | 2017-06-16 17:08:21 +0100 | [diff] [blame] | 40 | import android.os.storage.IStorageManager; |
Lenka Trochtova | 66c492a | 2018-12-06 11:29:21 +0100 | [diff] [blame] | 41 | import android.os.storage.StorageManager; |
Rubin Xu | 0cbc19e | 2016-12-09 14:00:21 +0000 | [diff] [blame] | 42 | import android.security.KeyStore; |
Rubin Xu | 0cbc19e | 2016-12-09 14:00:21 +0000 | [diff] [blame] | 43 | import android.test.AndroidTestCase; |
| 44 | |
Rubin Xu | 16c823e | 2017-06-27 14:44:58 +0100 | [diff] [blame] | 45 | import com.android.internal.widget.ILockSettings; |
Rubin Xu | 0cbc19e | 2016-12-09 14:00:21 +0000 | [diff] [blame] | 46 | import com.android.internal.widget.LockPatternUtils; |
Rubin Xu | fcd49f9 | 2017-08-24 18:21:52 +0100 | [diff] [blame] | 47 | import com.android.internal.widget.LockSettingsInternal; |
Andrew Scull | 1416bd0 | 2018-01-05 18:33:58 +0000 | [diff] [blame] | 48 | import com.android.server.LocalServices; |
Annie Meng | 086ddc8 | 2019-03-29 17:43:35 +0000 | [diff] [blame] | 49 | import com.android.server.locksettings.recoverablekeystore.RecoverableKeyStoreManager; |
Lenka Trochtova | 66c492a | 2018-12-06 11:29:21 +0100 | [diff] [blame] | 50 | import com.android.server.wm.WindowManagerInternal; |
Rubin Xu | 0cbc19e | 2016-12-09 14:00:21 +0000 | [diff] [blame] | 51 | |
| 52 | import org.mockito.invocation.InvocationOnMock; |
| 53 | import org.mockito.stubbing.Answer; |
| 54 | |
| 55 | import java.io.File; |
Andrew Scull | 8e87af5 | 2017-03-03 15:38:48 +0000 | [diff] [blame] | 56 | import java.util.ArrayList; |
Charles He | dec0540 | 2017-04-21 13:45:34 +0100 | [diff] [blame] | 57 | import java.util.Arrays; |
Rubin Xu | 0cbc19e | 2016-12-09 14:00:21 +0000 | [diff] [blame] | 58 | |
| 59 | |
Pavel Grafov | 57f1b66 | 2019-03-27 14:55:38 +0000 | [diff] [blame] | 60 | public abstract class BaseLockSettingsServiceTests extends AndroidTestCase { |
Rubin Xu | 0cbc19e | 2016-12-09 14:00:21 +0000 | [diff] [blame] | 61 | protected static final int PRIMARY_USER_ID = 0; |
| 62 | protected static final int MANAGED_PROFILE_USER_ID = 12; |
Andrew Scull | 8e87af5 | 2017-03-03 15:38:48 +0000 | [diff] [blame] | 63 | protected static final int TURNED_OFF_PROFILE_USER_ID = 17; |
Rubin Xu | 0cbc19e | 2016-12-09 14:00:21 +0000 | [diff] [blame] | 64 | protected static final int SECONDARY_USER_ID = 20; |
| 65 | |
| 66 | private static final UserInfo PRIMARY_USER_INFO = new UserInfo(PRIMARY_USER_ID, null, null, |
| 67 | UserInfo.FLAG_INITIALIZED | UserInfo.FLAG_ADMIN | UserInfo.FLAG_PRIMARY); |
Rubin Xu | 0cbc19e | 2016-12-09 14:00:21 +0000 | [diff] [blame] | 68 | private static final UserInfo SECONDARY_USER_INFO = new UserInfo(SECONDARY_USER_ID, null, null, |
| 69 | UserInfo.FLAG_INITIALIZED); |
| 70 | |
Andrew Scull | 8e87af5 | 2017-03-03 15:38:48 +0000 | [diff] [blame] | 71 | private ArrayList<UserInfo> mPrimaryUserProfiles = new ArrayList<>(); |
| 72 | |
Rubin Xu | 0cbc19e | 2016-12-09 14:00:21 +0000 | [diff] [blame] | 73 | LockSettingsService mService; |
Rubin Xu | fcd49f9 | 2017-08-24 18:21:52 +0100 | [diff] [blame] | 74 | LockSettingsInternal mLocalService; |
Rubin Xu | 0cbc19e | 2016-12-09 14:00:21 +0000 | [diff] [blame] | 75 | |
| 76 | MockLockSettingsContext mContext; |
| 77 | LockSettingsStorageTestable mStorage; |
| 78 | |
| 79 | LockPatternUtils mLockPatternUtils; |
Rubin Xu | 16c823e | 2017-06-27 14:44:58 +0100 | [diff] [blame] | 80 | FakeGateKeeperService mGateKeeperService; |
Rubin Xu | 0cbc19e | 2016-12-09 14:00:21 +0000 | [diff] [blame] | 81 | NotificationManager mNotificationManager; |
| 82 | UserManager mUserManager; |
Rubin Xu | b31be1b | 2017-06-16 17:08:21 +0100 | [diff] [blame] | 83 | FakeStorageManager mStorageManager; |
Rubin Xu | 0cbc19e | 2016-12-09 14:00:21 +0000 | [diff] [blame] | 84 | IActivityManager mActivityManager; |
Rubin Xu | 8b30ec3 | 2017-03-05 00:47:09 +0000 | [diff] [blame] | 85 | DevicePolicyManager mDevicePolicyManager; |
Andrew Scull | 1416bd0 | 2018-01-05 18:33:58 +0000 | [diff] [blame] | 86 | DevicePolicyManagerInternal mDevicePolicyManagerInternal; |
Rubin Xu | 0cbc19e | 2016-12-09 14:00:21 +0000 | [diff] [blame] | 87 | KeyStore mKeyStore; |
Rubin Xu | 7b7424b | 2017-03-31 18:03:20 +0100 | [diff] [blame] | 88 | MockSyntheticPasswordManager mSpManager; |
Andrew Scull | e6527c1 | 2018-01-05 18:33:58 +0000 | [diff] [blame] | 89 | IAuthSecret mAuthSecretService; |
Lenka Trochtova | 66c492a | 2018-12-06 11:29:21 +0100 | [diff] [blame] | 90 | WindowManagerInternal mMockWindowManager; |
David Anderson | 6ebc25b | 2019-02-12 16:25:56 -0800 | [diff] [blame] | 91 | FakeGsiService mGsiService; |
David Anderson | 28dea68 | 2019-02-20 13:37:51 -0800 | [diff] [blame] | 92 | PasswordSlotManagerTestable mPasswordSlotManager; |
Annie Meng | 086ddc8 | 2019-03-29 17:43:35 +0000 | [diff] [blame] | 93 | RecoverableKeyStoreManager mRecoverableKeyStoreManager; |
Lenka Trochtova | 66c492a | 2018-12-06 11:29:21 +0100 | [diff] [blame] | 94 | protected boolean mHasSecureLockScreen; |
Rubin Xu | 0cbc19e | 2016-12-09 14:00:21 +0000 | [diff] [blame] | 95 | |
| 96 | @Override |
| 97 | protected void setUp() throws Exception { |
| 98 | super.setUp(); |
| 99 | |
Rubin Xu | 16c823e | 2017-06-27 14:44:58 +0100 | [diff] [blame] | 100 | mGateKeeperService = new FakeGateKeeperService(); |
Rubin Xu | 0cbc19e | 2016-12-09 14:00:21 +0000 | [diff] [blame] | 101 | mNotificationManager = mock(NotificationManager.class); |
| 102 | mUserManager = mock(UserManager.class); |
Rubin Xu | b31be1b | 2017-06-16 17:08:21 +0100 | [diff] [blame] | 103 | mStorageManager = new FakeStorageManager(); |
Rubin Xu | 0cbc19e | 2016-12-09 14:00:21 +0000 | [diff] [blame] | 104 | mActivityManager = mock(IActivityManager.class); |
Rubin Xu | 8b30ec3 | 2017-03-05 00:47:09 +0000 | [diff] [blame] | 105 | mDevicePolicyManager = mock(DevicePolicyManager.class); |
Andrew Scull | 1416bd0 | 2018-01-05 18:33:58 +0000 | [diff] [blame] | 106 | mDevicePolicyManagerInternal = mock(DevicePolicyManagerInternal.class); |
Lenka Trochtova | 66c492a | 2018-12-06 11:29:21 +0100 | [diff] [blame] | 107 | mMockWindowManager = mock(WindowManagerInternal.class); |
David Anderson | 6ebc25b | 2019-02-12 16:25:56 -0800 | [diff] [blame] | 108 | mGsiService = new FakeGsiService(); |
David Anderson | 28dea68 | 2019-02-20 13:37:51 -0800 | [diff] [blame] | 109 | mPasswordSlotManager = new PasswordSlotManagerTestable(); |
Annie Meng | 086ddc8 | 2019-03-29 17:43:35 +0000 | [diff] [blame] | 110 | mRecoverableKeyStoreManager = mock(RecoverableKeyStoreManager.class); |
Andrew Scull | 1416bd0 | 2018-01-05 18:33:58 +0000 | [diff] [blame] | 111 | |
Rubin Xu | fcd49f9 | 2017-08-24 18:21:52 +0100 | [diff] [blame] | 112 | LocalServices.removeServiceForTest(LockSettingsInternal.class); |
Andrew Scull | 1416bd0 | 2018-01-05 18:33:58 +0000 | [diff] [blame] | 113 | LocalServices.removeServiceForTest(DevicePolicyManagerInternal.class); |
Lenka Trochtova | 66c492a | 2018-12-06 11:29:21 +0100 | [diff] [blame] | 114 | LocalServices.removeServiceForTest(WindowManagerInternal.class); |
Andrew Scull | 1416bd0 | 2018-01-05 18:33:58 +0000 | [diff] [blame] | 115 | LocalServices.addService(DevicePolicyManagerInternal.class, mDevicePolicyManagerInternal); |
Lenka Trochtova | 66c492a | 2018-12-06 11:29:21 +0100 | [diff] [blame] | 116 | LocalServices.addService(WindowManagerInternal.class, mMockWindowManager); |
Rubin Xu | 7b7424b | 2017-03-31 18:03:20 +0100 | [diff] [blame] | 117 | |
Rubin Xu | 8b30ec3 | 2017-03-05 00:47:09 +0000 | [diff] [blame] | 118 | mContext = new MockLockSettingsContext(getContext(), mUserManager, mNotificationManager, |
Andrew Scull | f49794b | 2018-04-13 12:01:25 +0100 | [diff] [blame] | 119 | mDevicePolicyManager, mock(StorageManager.class), mock(TrustManager.class), |
| 120 | mock(KeyguardManager.class)); |
Rubin Xu | 0cbc19e | 2016-12-09 14:00:21 +0000 | [diff] [blame] | 121 | mStorage = new LockSettingsStorageTestable(mContext, |
| 122 | new File(getContext().getFilesDir(), "locksettings")); |
| 123 | File storageDir = mStorage.mStorageDir; |
| 124 | if (storageDir.exists()) { |
| 125 | FileUtils.deleteContents(storageDir); |
| 126 | } else { |
| 127 | storageDir.mkdirs(); |
| 128 | } |
| 129 | |
Lenka Trochtova | 66c492a | 2018-12-06 11:29:21 +0100 | [diff] [blame] | 130 | mHasSecureLockScreen = true; |
Rubin Xu | 16c823e | 2017-06-27 14:44:58 +0100 | [diff] [blame] | 131 | mLockPatternUtils = new LockPatternUtils(mContext) { |
| 132 | @Override |
| 133 | public ILockSettings getLockSettings() { |
| 134 | return mService; |
| 135 | } |
Lenka Trochtova | 66c492a | 2018-12-06 11:29:21 +0100 | [diff] [blame] | 136 | |
| 137 | @Override |
| 138 | public boolean hasSecureLockScreen() { |
| 139 | return mHasSecureLockScreen; |
| 140 | } |
Rubin Xu | 16c823e | 2017-06-27 14:44:58 +0100 | [diff] [blame] | 141 | }; |
Adrian Roos | 2adc263 | 2017-09-05 17:01:42 +0200 | [diff] [blame] | 142 | mSpManager = new MockSyntheticPasswordManager(mContext, mStorage, mGateKeeperService, |
David Anderson | 28dea68 | 2019-02-20 13:37:51 -0800 | [diff] [blame] | 143 | mUserManager, mPasswordSlotManager); |
Andrew Scull | e6527c1 | 2018-01-05 18:33:58 +0000 | [diff] [blame] | 144 | mAuthSecretService = mock(IAuthSecret.class); |
Rubin Xu | b31be1b | 2017-06-16 17:08:21 +0100 | [diff] [blame] | 145 | mService = new LockSettingsServiceTestable(mContext, mLockPatternUtils, mStorage, |
| 146 | mGateKeeperService, mKeyStore, setUpStorageManagerMock(), mActivityManager, |
Annie Meng | 086ddc8 | 2019-03-29 17:43:35 +0000 | [diff] [blame] | 147 | mSpManager, mAuthSecretService, mGsiService, mRecoverableKeyStoreManager); |
Rubin Xu | 0cbc19e | 2016-12-09 14:00:21 +0000 | [diff] [blame] | 148 | when(mUserManager.getUserInfo(eq(PRIMARY_USER_ID))).thenReturn(PRIMARY_USER_INFO); |
Andrew Scull | 8e87af5 | 2017-03-03 15:38:48 +0000 | [diff] [blame] | 149 | mPrimaryUserProfiles.add(PRIMARY_USER_INFO); |
| 150 | installChildProfile(MANAGED_PROFILE_USER_ID); |
Charles He | dec0540 | 2017-04-21 13:45:34 +0100 | [diff] [blame] | 151 | installAndTurnOffChildProfile(TURNED_OFF_PROFILE_USER_ID); |
Annie Meng | 086ddc8 | 2019-03-29 17:43:35 +0000 | [diff] [blame] | 152 | for (UserInfo profile : mPrimaryUserProfiles) { |
| 153 | when(mUserManager.getProfiles(eq(profile.id))).thenReturn(mPrimaryUserProfiles); |
| 154 | } |
Rubin Xu | 0cbc19e | 2016-12-09 14:00:21 +0000 | [diff] [blame] | 155 | when(mUserManager.getUserInfo(eq(SECONDARY_USER_ID))).thenReturn(SECONDARY_USER_INFO); |
| 156 | |
Andrew Scull | e6527c1 | 2018-01-05 18:33:58 +0000 | [diff] [blame] | 157 | final ArrayList<UserInfo> allUsers = new ArrayList<>(mPrimaryUserProfiles); |
| 158 | allUsers.add(SECONDARY_USER_INFO); |
| 159 | when(mUserManager.getUsers(anyBoolean())).thenReturn(allUsers); |
| 160 | |
Rubin Xu | 0cbc19e | 2016-12-09 14:00:21 +0000 | [diff] [blame] | 161 | when(mActivityManager.unlockUser(anyInt(), any(), any(), any())).thenAnswer( |
| 162 | new Answer<Boolean>() { |
| 163 | @Override |
| 164 | public Boolean answer(InvocationOnMock invocation) throws Throwable { |
| 165 | Object[] args = invocation.getArguments(); |
| 166 | mStorageManager.unlockUser((int)args[0], (byte[])args[2], |
| 167 | (IProgressListener) args[3]); |
| 168 | return true; |
| 169 | } |
| 170 | }); |
| 171 | |
Rubin Xu | 8b30ec3 | 2017-03-05 00:47:09 +0000 | [diff] [blame] | 172 | // Adding a fake Device Owner app which will enable escrow token support in LSS. |
| 173 | when(mDevicePolicyManager.getDeviceOwnerComponentOnAnyUser()).thenReturn( |
| 174 | new ComponentName("com.dummy.package", ".FakeDeviceOwner")); |
Rubin Xu | fcd49f9 | 2017-08-24 18:21:52 +0100 | [diff] [blame] | 175 | mLocalService = LocalServices.getService(LockSettingsInternal.class); |
Rubin Xu | 0cbc19e | 2016-12-09 14:00:21 +0000 | [diff] [blame] | 176 | } |
| 177 | |
Andrew Scull | 8e87af5 | 2017-03-03 15:38:48 +0000 | [diff] [blame] | 178 | private UserInfo installChildProfile(int profileId) { |
| 179 | final UserInfo userInfo = new UserInfo( |
| 180 | profileId, null, null, UserInfo.FLAG_INITIALIZED | UserInfo.FLAG_MANAGED_PROFILE); |
Annie Meng | 086ddc8 | 2019-03-29 17:43:35 +0000 | [diff] [blame] | 181 | userInfo.profileGroupId = PRIMARY_USER_ID; |
Andrew Scull | 8e87af5 | 2017-03-03 15:38:48 +0000 | [diff] [blame] | 182 | mPrimaryUserProfiles.add(userInfo); |
| 183 | when(mUserManager.getUserInfo(eq(profileId))).thenReturn(userInfo); |
| 184 | when(mUserManager.getProfileParent(eq(profileId))).thenReturn(PRIMARY_USER_INFO); |
Charles He | dec0540 | 2017-04-21 13:45:34 +0100 | [diff] [blame] | 185 | when(mUserManager.isUserRunning(eq(profileId))).thenReturn(true); |
| 186 | when(mUserManager.isUserUnlocked(eq(profileId))).thenReturn(true); |
Andrew Scull | 8e87af5 | 2017-03-03 15:38:48 +0000 | [diff] [blame] | 187 | return userInfo; |
| 188 | } |
| 189 | |
Charles He | dec0540 | 2017-04-21 13:45:34 +0100 | [diff] [blame] | 190 | private UserInfo installAndTurnOffChildProfile(int profileId) { |
Andrew Scull | 8e87af5 | 2017-03-03 15:38:48 +0000 | [diff] [blame] | 191 | final UserInfo userInfo = installChildProfile(profileId); |
| 192 | userInfo.flags |= UserInfo.FLAG_QUIET_MODE; |
Charles He | dec0540 | 2017-04-21 13:45:34 +0100 | [diff] [blame] | 193 | when(mUserManager.isUserRunning(eq(profileId))).thenReturn(false); |
| 194 | when(mUserManager.isUserUnlocked(eq(profileId))).thenReturn(false); |
Andrew Scull | 8e87af5 | 2017-03-03 15:38:48 +0000 | [diff] [blame] | 195 | return userInfo; |
| 196 | } |
| 197 | |
Rubin Xu | b31be1b | 2017-06-16 17:08:21 +0100 | [diff] [blame] | 198 | private IStorageManager setUpStorageManagerMock() throws RemoteException { |
| 199 | final IStorageManager sm = mock(IStorageManager.class); |
| 200 | |
| 201 | doAnswer(new Answer<Void>() { |
| 202 | @Override |
| 203 | public Void answer(InvocationOnMock invocation) throws Throwable { |
| 204 | Object[] args = invocation.getArguments(); |
| 205 | mStorageManager.addUserKeyAuth((int) args[0] /* userId */, |
| 206 | (int) args[1] /* serialNumber */, |
| 207 | (byte[]) args[2] /* token */, |
| 208 | (byte[]) args[3] /* secret */); |
| 209 | return null; |
| 210 | } |
| 211 | }).when(sm).addUserKeyAuth(anyInt(), anyInt(), any(), any()); |
| 212 | |
| 213 | doAnswer( |
| 214 | new Answer<Void>() { |
| 215 | @Override |
| 216 | public Void answer(InvocationOnMock invocation) throws Throwable { |
| 217 | Object[] args = invocation.getArguments(); |
| 218 | mStorageManager.fixateNewestUserKeyAuth((int) args[0] /* userId */); |
| 219 | return null; |
| 220 | } |
| 221 | }).when(sm).fixateNewestUserKeyAuth(anyInt()); |
| 222 | return sm; |
| 223 | } |
| 224 | |
Rubin Xu | 0cbc19e | 2016-12-09 14:00:21 +0000 | [diff] [blame] | 225 | @Override |
| 226 | protected void tearDown() throws Exception { |
| 227 | super.tearDown(); |
| 228 | mStorage.closeDatabase(); |
| 229 | File db = getContext().getDatabasePath("locksettings.db"); |
| 230 | assertTrue(!db.exists() || db.delete()); |
| 231 | |
| 232 | File storageDir = mStorage.mStorageDir; |
| 233 | assertTrue(FileUtils.deleteContents(storageDir)); |
David Anderson | 28dea68 | 2019-02-20 13:37:51 -0800 | [diff] [blame] | 234 | |
| 235 | mPasswordSlotManager.cleanup(); |
Rubin Xu | 0cbc19e | 2016-12-09 14:00:21 +0000 | [diff] [blame] | 236 | } |
Rubin Xu | 3bf722a | 2016-12-15 16:07:38 +0000 | [diff] [blame] | 237 | |
Rubin Xu | 340e5ba | 2019-05-14 16:10:03 +0100 | [diff] [blame] | 238 | protected void flushHandlerTasks() { |
| 239 | mService.mHandler.runWithScissors(() -> { }, 0 /*now*/); // Flush runnables on handler |
| 240 | } |
| 241 | |
Andrew Scull | 7f4ff4c | 2018-01-05 18:33:58 +0000 | [diff] [blame] | 242 | protected void assertNotEquals(long expected, long actual) { |
| 243 | assertTrue(expected != actual); |
| 244 | } |
| 245 | |
Rubin Xu | 3bf722a | 2016-12-15 16:07:38 +0000 | [diff] [blame] | 246 | protected static void assertArrayEquals(byte[] expected, byte[] actual) { |
| 247 | assertTrue(Arrays.equals(expected, actual)); |
| 248 | } |
| 249 | |
Andrew Scull | 7f4ff4c | 2018-01-05 18:33:58 +0000 | [diff] [blame] | 250 | protected static void assertArrayNotEquals(byte[] expected, byte[] actual) { |
Rubin Xu | 3bf722a | 2016-12-15 16:07:38 +0000 | [diff] [blame] | 251 | assertFalse(Arrays.equals(expected, actual)); |
| 252 | } |
Rubin Xu | 0cbc19e | 2016-12-09 14:00:21 +0000 | [diff] [blame] | 253 | } |