Peter Visontay | 859206c | 2018-01-03 15:43:19 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2018 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 | */ |
Svet Ganov | 8455ba2 | 2019-01-02 13:05:56 -0800 | [diff] [blame] | 16 | package com.android.server.appop; |
Peter Visontay | 859206c | 2018-01-03 15:43:19 +0000 | [diff] [blame] | 17 | |
Amith Yamasani | 23d4cd7 | 2019-04-10 17:57:00 -0700 | [diff] [blame] | 18 | import static android.app.ActivityManager.PROCESS_STATE_FOREGROUND_SERVICE; |
Philip P. Moltmann | 4aacd71 | 2020-01-03 12:32:20 -0800 | [diff] [blame] | 19 | import static android.app.AppOpsManager.FILTER_BY_PACKAGE_NAME; |
| 20 | import static android.app.AppOpsManager.FILTER_BY_UID; |
Peter Visontay | 859206c | 2018-01-03 15:43:19 +0000 | [diff] [blame] | 21 | import static android.app.AppOpsManager.MODE_ALLOWED; |
| 22 | import static android.app.AppOpsManager.MODE_ERRORED; |
Amith Yamasani | 23d4cd7 | 2019-04-10 17:57:00 -0700 | [diff] [blame] | 23 | import static android.app.AppOpsManager.MODE_FOREGROUND; |
Peter Visontay | 7671236 | 2018-04-19 22:04:14 +0100 | [diff] [blame] | 24 | import static android.app.AppOpsManager.OP_COARSE_LOCATION; |
Philip P. Moltmann | 49bd9e1 | 2019-11-26 15:18:16 -0800 | [diff] [blame] | 25 | import static android.app.AppOpsManager.OP_FLAGS_ALL; |
Peter Visontay | 859206c | 2018-01-03 15:43:19 +0000 | [diff] [blame] | 26 | import static android.app.AppOpsManager.OP_READ_SMS; |
Peter Visontay | 7671236 | 2018-04-19 22:04:14 +0100 | [diff] [blame] | 27 | import static android.app.AppOpsManager.OP_WIFI_SCAN; |
Peter Visontay | 859206c | 2018-01-03 15:43:19 +0000 | [diff] [blame] | 28 | import static android.app.AppOpsManager.OP_WRITE_SMS; |
| 29 | |
Philip P. Moltmann | 6b4f3d5 | 2019-05-08 15:14:09 -0700 | [diff] [blame] | 30 | import static com.android.dx.mockito.inline.extended.ExtendedMockito.doNothing; |
| 31 | import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn; |
| 32 | import static com.android.dx.mockito.inline.extended.ExtendedMockito.mock; |
| 33 | import static com.android.dx.mockito.inline.extended.ExtendedMockito.mockitoSession; |
| 34 | import static com.android.dx.mockito.inline.extended.ExtendedMockito.spy; |
| 35 | import static com.android.dx.mockito.inline.extended.ExtendedMockito.when; |
| 36 | |
Peter Visontay | 859206c | 2018-01-03 15:43:19 +0000 | [diff] [blame] | 37 | import static com.google.common.truth.Truth.assertThat; |
| 38 | import static com.google.common.truth.Truth.assertWithMessage; |
| 39 | |
Svet Ganov | 4764107 | 2019-06-06 12:57:12 -0700 | [diff] [blame] | 40 | import static org.mockito.ArgumentMatchers.any; |
Philip P. Moltmann | 6b4f3d5 | 2019-05-08 15:14:09 -0700 | [diff] [blame] | 41 | import static org.mockito.ArgumentMatchers.anyInt; |
| 42 | import static org.mockito.ArgumentMatchers.anyString; |
| 43 | import static org.mockito.ArgumentMatchers.eq; |
| 44 | import static org.mockito.ArgumentMatchers.nullable; |
| 45 | |
Amith Yamasani | 23d4cd7 | 2019-04-10 17:57:00 -0700 | [diff] [blame] | 46 | import android.app.ActivityManager; |
Winson | 470b15b | 2019-05-07 16:29:59 -0700 | [diff] [blame] | 47 | import android.app.AppOpsManager; |
Peter Visontay | 859206c | 2018-01-03 15:43:19 +0000 | [diff] [blame] | 48 | import android.app.AppOpsManager.OpEntry; |
| 49 | import android.app.AppOpsManager.PackageOps; |
Svet Ganov | 4764107 | 2019-06-06 12:57:12 -0700 | [diff] [blame] | 50 | import android.content.ContentResolver; |
Peter Visontay | 859206c | 2018-01-03 15:43:19 +0000 | [diff] [blame] | 51 | import android.content.Context; |
Philip P. Moltmann | 6b4f3d5 | 2019-05-08 15:14:09 -0700 | [diff] [blame] | 52 | import android.content.pm.PackageManagerInternal; |
Peter Visontay | 859206c | 2018-01-03 15:43:19 +0000 | [diff] [blame] | 53 | import android.os.Handler; |
| 54 | import android.os.HandlerThread; |
| 55 | import android.os.Process; |
Winson | 470b15b | 2019-05-07 16:29:59 -0700 | [diff] [blame] | 56 | import android.os.RemoteCallback; |
Svet Ganov | 4764107 | 2019-06-06 12:57:12 -0700 | [diff] [blame] | 57 | import android.provider.Settings; |
Brett Chabot | a26eda9 | 2018-07-23 13:08:30 -0700 | [diff] [blame] | 58 | |
| 59 | import androidx.test.InstrumentationRegistry; |
| 60 | import androidx.test.filters.SmallTest; |
| 61 | import androidx.test.runner.AndroidJUnit4; |
Peter Visontay | 859206c | 2018-01-03 15:43:19 +0000 | [diff] [blame] | 62 | |
Philip P. Moltmann | 6b4f3d5 | 2019-05-08 15:14:09 -0700 | [diff] [blame] | 63 | import com.android.dx.mockito.inline.extended.StaticMockitoSession; |
| 64 | import com.android.server.LocalServices; |
Winson | 33eacc6 | 2020-01-24 12:02:58 -0800 | [diff] [blame] | 65 | import com.android.server.pm.parsing.pkg.AndroidPackage; |
Amith Yamasani | 23d4cd7 | 2019-04-10 17:57:00 -0700 | [diff] [blame] | 66 | |
Philip P. Moltmann | 6b4f3d5 | 2019-05-08 15:14:09 -0700 | [diff] [blame] | 67 | import org.junit.After; |
Peter Visontay | 859206c | 2018-01-03 15:43:19 +0000 | [diff] [blame] | 68 | import org.junit.Before; |
| 69 | import org.junit.Test; |
| 70 | import org.junit.runner.RunWith; |
Philip P. Moltmann | 6b4f3d5 | 2019-05-08 15:14:09 -0700 | [diff] [blame] | 71 | import org.mockito.quality.Strictness; |
Peter Visontay | 859206c | 2018-01-03 15:43:19 +0000 | [diff] [blame] | 72 | |
| 73 | import java.io.File; |
Philip P. Moltmann | 9046d82 | 2019-12-13 15:59:49 -0800 | [diff] [blame] | 74 | import java.util.Collections; |
Peter Visontay | 859206c | 2018-01-03 15:43:19 +0000 | [diff] [blame] | 75 | import java.util.List; |
Winson | 470b15b | 2019-05-07 16:29:59 -0700 | [diff] [blame] | 76 | import java.util.concurrent.CountDownLatch; |
| 77 | import java.util.concurrent.TimeUnit; |
| 78 | import java.util.concurrent.atomic.AtomicReference; |
Peter Visontay | 859206c | 2018-01-03 15:43:19 +0000 | [diff] [blame] | 79 | |
| 80 | /** |
| 81 | * Unit tests for AppOpsService. Covers functionality that is difficult to test using CTS tests |
| 82 | * or for which we can write more detailed unit tests than CTS tests (because the internal APIs are |
| 83 | * more finegrained data than the public ones). |
| 84 | */ |
| 85 | @SmallTest |
| 86 | @RunWith(AndroidJUnit4.class) |
| 87 | public class AppOpsServiceTest { |
| 88 | |
| 89 | private static final String TAG = AppOpsServiceTest.class.getSimpleName(); |
| 90 | // State will be persisted into this XML file. |
| 91 | private static final String APP_OPS_FILENAME = "appops-service-test.xml"; |
| 92 | |
Philip P. Moltmann | 6b4f3d5 | 2019-05-08 15:14:09 -0700 | [diff] [blame] | 93 | private static final Context sContext = InstrumentationRegistry.getTargetContext(); |
| 94 | private static final String sMyPackageName = sContext.getOpPackageName(); |
| 95 | |
Peter Visontay | 859206c | 2018-01-03 15:43:19 +0000 | [diff] [blame] | 96 | private File mAppOpsFile; |
Peter Visontay | 859206c | 2018-01-03 15:43:19 +0000 | [diff] [blame] | 97 | private Handler mHandler; |
| 98 | private AppOpsService mAppOpsService; |
Peter Visontay | 859206c | 2018-01-03 15:43:19 +0000 | [diff] [blame] | 99 | private int mMyUid; |
| 100 | private long mTestStartMillis; |
Philip P. Moltmann | 6b4f3d5 | 2019-05-08 15:14:09 -0700 | [diff] [blame] | 101 | private StaticMockitoSession mMockingSession; |
| 102 | |
Philip P. Moltmann | 6b4f3d5 | 2019-05-08 15:14:09 -0700 | [diff] [blame] | 103 | private void setupAppOpsService() { |
Philip P. Moltmann | fe2fc3a | 2020-02-05 16:59:39 -0800 | [diff] [blame] | 104 | mAppOpsService = new AppOpsService(mAppOpsFile, mHandler, spy(sContext)); |
Svet Ganov | 4764107 | 2019-06-06 12:57:12 -0700 | [diff] [blame] | 105 | mAppOpsService.mHistoricalRegistry.systemReady(sContext.getContentResolver()); |
Philip P. Moltmann | 6b4f3d5 | 2019-05-08 15:14:09 -0700 | [diff] [blame] | 106 | |
| 107 | // Always approve all permission checks |
| 108 | doNothing().when(mAppOpsService.mContext).enforcePermission(anyString(), anyInt(), |
| 109 | anyInt(), nullable(String.class)); |
| 110 | } |
Peter Visontay | 859206c | 2018-01-03 15:43:19 +0000 | [diff] [blame] | 111 | |
| 112 | @Before |
| 113 | public void setUp() { |
Philip P. Moltmann | 6b4f3d5 | 2019-05-08 15:14:09 -0700 | [diff] [blame] | 114 | mAppOpsFile = new File(sContext.getFilesDir(), APP_OPS_FILENAME); |
Peter Visontay | 859206c | 2018-01-03 15:43:19 +0000 | [diff] [blame] | 115 | if (mAppOpsFile.exists()) { |
| 116 | // Start with a clean state (persisted into XML). |
| 117 | mAppOpsFile.delete(); |
| 118 | } |
| 119 | |
| 120 | HandlerThread handlerThread = new HandlerThread(TAG); |
| 121 | handlerThread.start(); |
| 122 | mHandler = new Handler(handlerThread.getLooper()); |
Peter Visontay | 859206c | 2018-01-03 15:43:19 +0000 | [diff] [blame] | 123 | mMyUid = Process.myUid(); |
| 124 | |
Svet Ganov | 4764107 | 2019-06-06 12:57:12 -0700 | [diff] [blame] | 125 | initializeStaticMocks(); |
| 126 | |
Philip P. Moltmann | 6b4f3d5 | 2019-05-08 15:14:09 -0700 | [diff] [blame] | 127 | setupAppOpsService(); |
Svet Ganov | 4764107 | 2019-06-06 12:57:12 -0700 | [diff] [blame] | 128 | |
Peter Visontay | 859206c | 2018-01-03 15:43:19 +0000 | [diff] [blame] | 129 | mTestStartMillis = System.currentTimeMillis(); |
| 130 | } |
| 131 | |
Philip P. Moltmann | 6b4f3d5 | 2019-05-08 15:14:09 -0700 | [diff] [blame] | 132 | @After |
| 133 | public void resetStaticMocks() { |
| 134 | mMockingSession.finishMocking(); |
| 135 | } |
| 136 | |
Svet Ganov | 4764107 | 2019-06-06 12:57:12 -0700 | [diff] [blame] | 137 | private void initializeStaticMocks() { |
| 138 | mMockingSession = mockitoSession() |
| 139 | .strictness(Strictness.LENIENT) |
| 140 | .spyStatic(LocalServices.class) |
| 141 | .spyStatic(Settings.Global.class) |
| 142 | .startMocking(); |
| 143 | |
Philip P. Moltmann | 9046d82 | 2019-12-13 15:59:49 -0800 | [diff] [blame] | 144 | // Mock LocalServices.getService(PackageManagerInternal.class).getPackage dependency |
Svet Ganov | 4764107 | 2019-06-06 12:57:12 -0700 | [diff] [blame] | 145 | // needed by AppOpsService |
| 146 | PackageManagerInternal mockPackageManagerInternal = mock(PackageManagerInternal.class); |
Philip P. Moltmann | 9046d82 | 2019-12-13 15:59:49 -0800 | [diff] [blame] | 147 | AndroidPackage mockMyPkg = mock(AndroidPackage.class); |
| 148 | when(mockMyPkg.isPrivileged()).thenReturn(false); |
| 149 | when(mockMyPkg.getUid()).thenReturn(mMyUid); |
Philip P. Moltmann | 12ac3f4 | 2020-03-05 15:01:29 -0800 | [diff] [blame] | 150 | when(mockMyPkg.getAttributions()).thenReturn(Collections.emptyList()); |
Philip P. Moltmann | 9046d82 | 2019-12-13 15:59:49 -0800 | [diff] [blame] | 151 | |
| 152 | when(mockPackageManagerInternal.getPackage(sMyPackageName)).thenReturn(mockMyPkg); |
Svet Ganov | 4764107 | 2019-06-06 12:57:12 -0700 | [diff] [blame] | 153 | doReturn(mockPackageManagerInternal).when( |
| 154 | () -> LocalServices.getService(PackageManagerInternal.class)); |
| 155 | |
| 156 | // Mock behavior to use specific Settings.Global.APPOP_HISTORY_PARAMETERS |
| 157 | doReturn(null).when(() -> Settings.Global.getString(any(ContentResolver.class), |
| 158 | eq(Settings.Global.APPOP_HISTORY_PARAMETERS))); |
| 159 | } |
| 160 | |
Peter Visontay | 859206c | 2018-01-03 15:43:19 +0000 | [diff] [blame] | 161 | @Test |
| 162 | public void testGetOpsForPackage_noOpsLogged() { |
| 163 | assertThat(getLoggedOps()).isNull(); |
| 164 | } |
| 165 | |
| 166 | @Test |
| 167 | public void testNoteOperationAndGetOpsForPackage() { |
Philip P. Moltmann | 6b4f3d5 | 2019-05-08 15:14:09 -0700 | [diff] [blame] | 168 | mAppOpsService.setMode(OP_READ_SMS, mMyUid, sMyPackageName, MODE_ALLOWED); |
| 169 | mAppOpsService.setMode(OP_WRITE_SMS, mMyUid, sMyPackageName, MODE_ERRORED); |
Peter Visontay | 859206c | 2018-01-03 15:43:19 +0000 | [diff] [blame] | 170 | |
| 171 | // Note an op that's allowed. |
Philip P. Moltmann | da554e4 | 2019-12-20 11:21:02 -0800 | [diff] [blame] | 172 | mAppOpsService.noteOperation(OP_READ_SMS, mMyUid, sMyPackageName, null, false, null); |
Peter Visontay | 859206c | 2018-01-03 15:43:19 +0000 | [diff] [blame] | 173 | List<PackageOps> loggedOps = getLoggedOps(); |
| 174 | assertContainsOp(loggedOps, OP_READ_SMS, mTestStartMillis, -1, MODE_ALLOWED); |
| 175 | |
| 176 | // Note another op that's not allowed. |
Philip P. Moltmann | da554e4 | 2019-12-20 11:21:02 -0800 | [diff] [blame] | 177 | mAppOpsService.noteOperation(OP_WRITE_SMS, mMyUid, sMyPackageName, null, false, null); |
Peter Visontay | 859206c | 2018-01-03 15:43:19 +0000 | [diff] [blame] | 178 | loggedOps = getLoggedOps(); |
| 179 | assertContainsOp(loggedOps, OP_READ_SMS, mTestStartMillis, -1, MODE_ALLOWED); |
| 180 | assertContainsOp(loggedOps, OP_WRITE_SMS, -1, mTestStartMillis, MODE_ERRORED); |
| 181 | } |
| 182 | |
Peter Visontay | 7671236 | 2018-04-19 22:04:14 +0100 | [diff] [blame] | 183 | /** |
| 184 | * Tests the scenario where an operation's permission is controlled by another operation. |
| 185 | * For example the results of a WIFI_SCAN can be used to infer the location of a user, so the |
| 186 | * ACCESS_COARSE_LOCATION op is used to check whether WIFI_SCAN is allowed. |
| 187 | */ |
| 188 | @Test |
| 189 | public void testNoteOperationAndGetOpsForPackage_controlledByDifferentOp() { |
| 190 | // This op controls WIFI_SCAN |
Philip P. Moltmann | 6b4f3d5 | 2019-05-08 15:14:09 -0700 | [diff] [blame] | 191 | mAppOpsService.setMode(OP_COARSE_LOCATION, mMyUid, sMyPackageName, MODE_ALLOWED); |
Peter Visontay | 7671236 | 2018-04-19 22:04:14 +0100 | [diff] [blame] | 192 | |
Philip P. Moltmann | da554e4 | 2019-12-20 11:21:02 -0800 | [diff] [blame] | 193 | assertThat(mAppOpsService.noteOperation(OP_WIFI_SCAN, mMyUid, sMyPackageName, null, false, |
| 194 | null)).isEqualTo(MODE_ALLOWED); |
Peter Visontay | 7671236 | 2018-04-19 22:04:14 +0100 | [diff] [blame] | 195 | |
| 196 | assertContainsOp(getLoggedOps(), OP_WIFI_SCAN, mTestStartMillis, -1, |
| 197 | MODE_ALLOWED /* default for WIFI_SCAN; this is not changed or used in this test */); |
| 198 | |
| 199 | // Now set COARSE_LOCATION to ERRORED -> this will make WIFI_SCAN disabled as well. |
Philip P. Moltmann | 6b4f3d5 | 2019-05-08 15:14:09 -0700 | [diff] [blame] | 200 | mAppOpsService.setMode(OP_COARSE_LOCATION, mMyUid, sMyPackageName, MODE_ERRORED); |
Philip P. Moltmann | da554e4 | 2019-12-20 11:21:02 -0800 | [diff] [blame] | 201 | assertThat(mAppOpsService.noteOperation(OP_WIFI_SCAN, mMyUid, sMyPackageName, null, false, |
| 202 | null)).isEqualTo(MODE_ERRORED); |
Peter Visontay | 7671236 | 2018-04-19 22:04:14 +0100 | [diff] [blame] | 203 | |
| 204 | assertContainsOp(getLoggedOps(), OP_WIFI_SCAN, mTestStartMillis, mTestStartMillis, |
| 205 | MODE_ALLOWED /* default for WIFI_SCAN; this is not changed or used in this test */); |
| 206 | } |
| 207 | |
Peter Visontay | 859206c | 2018-01-03 15:43:19 +0000 | [diff] [blame] | 208 | // Tests the dumping and restoring of the in-memory state to/from XML. |
| 209 | @Test |
| 210 | public void testStatePersistence() { |
Philip P. Moltmann | 6b4f3d5 | 2019-05-08 15:14:09 -0700 | [diff] [blame] | 211 | mAppOpsService.setMode(OP_READ_SMS, mMyUid, sMyPackageName, MODE_ALLOWED); |
| 212 | mAppOpsService.setMode(OP_WRITE_SMS, mMyUid, sMyPackageName, MODE_ERRORED); |
Philip P. Moltmann | da554e4 | 2019-12-20 11:21:02 -0800 | [diff] [blame] | 213 | mAppOpsService.noteOperation(OP_READ_SMS, mMyUid, sMyPackageName, null, false, null); |
| 214 | mAppOpsService.noteOperation(OP_WRITE_SMS, mMyUid, sMyPackageName, null, false, null); |
Peter Visontay | 859206c | 2018-01-03 15:43:19 +0000 | [diff] [blame] | 215 | mAppOpsService.writeState(); |
| 216 | |
| 217 | // Create a new app ops service, and initialize its state from XML. |
Philip P. Moltmann | 6b4f3d5 | 2019-05-08 15:14:09 -0700 | [diff] [blame] | 218 | setupAppOpsService(); |
Peter Visontay | 859206c | 2018-01-03 15:43:19 +0000 | [diff] [blame] | 219 | mAppOpsService.readState(); |
| 220 | |
| 221 | // Query the state of the 2nd service. |
| 222 | List<PackageOps> loggedOps = getLoggedOps(); |
| 223 | assertContainsOp(loggedOps, OP_READ_SMS, mTestStartMillis, -1, MODE_ALLOWED); |
| 224 | assertContainsOp(loggedOps, OP_WRITE_SMS, -1, mTestStartMillis, MODE_ERRORED); |
| 225 | } |
| 226 | |
| 227 | // Tests that ops are persisted during shutdown. |
| 228 | @Test |
| 229 | public void testShutdown() { |
Philip P. Moltmann | 6b4f3d5 | 2019-05-08 15:14:09 -0700 | [diff] [blame] | 230 | mAppOpsService.setMode(OP_READ_SMS, mMyUid, sMyPackageName, MODE_ALLOWED); |
Philip P. Moltmann | da554e4 | 2019-12-20 11:21:02 -0800 | [diff] [blame] | 231 | mAppOpsService.noteOperation(OP_READ_SMS, mMyUid, sMyPackageName, null, false, null); |
Peter Visontay | 859206c | 2018-01-03 15:43:19 +0000 | [diff] [blame] | 232 | mAppOpsService.shutdown(); |
| 233 | |
| 234 | // Create a new app ops service, and initialize its state from XML. |
Philip P. Moltmann | 6b4f3d5 | 2019-05-08 15:14:09 -0700 | [diff] [blame] | 235 | setupAppOpsService(); |
Peter Visontay | 859206c | 2018-01-03 15:43:19 +0000 | [diff] [blame] | 236 | mAppOpsService.readState(); |
| 237 | |
| 238 | // Query the state of the 2nd service. |
| 239 | List<PackageOps> loggedOps = getLoggedOps(); |
| 240 | assertContainsOp(loggedOps, OP_READ_SMS, mTestStartMillis, -1, MODE_ALLOWED); |
| 241 | } |
| 242 | |
| 243 | @Test |
| 244 | public void testGetOpsForPackage() { |
Philip P. Moltmann | 6b4f3d5 | 2019-05-08 15:14:09 -0700 | [diff] [blame] | 245 | mAppOpsService.setMode(OP_READ_SMS, mMyUid, sMyPackageName, MODE_ALLOWED); |
Philip P. Moltmann | da554e4 | 2019-12-20 11:21:02 -0800 | [diff] [blame] | 246 | mAppOpsService.noteOperation(OP_READ_SMS, mMyUid, sMyPackageName, null, false, null); |
Peter Visontay | 859206c | 2018-01-03 15:43:19 +0000 | [diff] [blame] | 247 | |
| 248 | // Query all ops |
| 249 | List<PackageOps> loggedOps = mAppOpsService.getOpsForPackage( |
Philip P. Moltmann | 6b4f3d5 | 2019-05-08 15:14:09 -0700 | [diff] [blame] | 250 | mMyUid, sMyPackageName, null /* all ops */); |
Peter Visontay | 859206c | 2018-01-03 15:43:19 +0000 | [diff] [blame] | 251 | assertContainsOp(loggedOps, OP_READ_SMS, mTestStartMillis, -1, MODE_ALLOWED); |
| 252 | |
| 253 | // Query specific ops |
| 254 | loggedOps = mAppOpsService.getOpsForPackage( |
Philip P. Moltmann | 6b4f3d5 | 2019-05-08 15:14:09 -0700 | [diff] [blame] | 255 | mMyUid, sMyPackageName, new int[]{OP_READ_SMS, OP_WRITE_SMS}); |
Peter Visontay | 859206c | 2018-01-03 15:43:19 +0000 | [diff] [blame] | 256 | assertContainsOp(loggedOps, OP_READ_SMS, mTestStartMillis, -1, MODE_ALLOWED); |
| 257 | |
| 258 | // Query unknown UID |
Philip P. Moltmann | 6b4f3d5 | 2019-05-08 15:14:09 -0700 | [diff] [blame] | 259 | loggedOps = mAppOpsService.getOpsForPackage(mMyUid + 1, sMyPackageName, null /* all ops */); |
Peter Visontay | 859206c | 2018-01-03 15:43:19 +0000 | [diff] [blame] | 260 | assertThat(loggedOps).isNull(); |
| 261 | |
| 262 | // Query unknown package name |
| 263 | loggedOps = mAppOpsService.getOpsForPackage(mMyUid, "fake.package", null /* all ops */); |
| 264 | assertThat(loggedOps).isNull(); |
| 265 | |
| 266 | // Query op code that's not been logged |
Philip P. Moltmann | 6b4f3d5 | 2019-05-08 15:14:09 -0700 | [diff] [blame] | 267 | loggedOps = mAppOpsService.getOpsForPackage(mMyUid, sMyPackageName, |
Peter Visontay | 859206c | 2018-01-03 15:43:19 +0000 | [diff] [blame] | 268 | new int[]{OP_WRITE_SMS}); |
| 269 | assertThat(loggedOps).isNull(); |
| 270 | } |
| 271 | |
| 272 | @Test |
| 273 | public void testPackageRemoved() { |
Philip P. Moltmann | 6b4f3d5 | 2019-05-08 15:14:09 -0700 | [diff] [blame] | 274 | mAppOpsService.setMode(OP_READ_SMS, mMyUid, sMyPackageName, MODE_ALLOWED); |
Philip P. Moltmann | da554e4 | 2019-12-20 11:21:02 -0800 | [diff] [blame] | 275 | mAppOpsService.noteOperation(OP_READ_SMS, mMyUid, sMyPackageName, null, false, null); |
Peter Visontay | 859206c | 2018-01-03 15:43:19 +0000 | [diff] [blame] | 276 | |
| 277 | List<PackageOps> loggedOps = getLoggedOps(); |
| 278 | assertContainsOp(loggedOps, OP_READ_SMS, mTestStartMillis, -1, MODE_ALLOWED); |
| 279 | |
Philip P. Moltmann | 6b4f3d5 | 2019-05-08 15:14:09 -0700 | [diff] [blame] | 280 | mAppOpsService.packageRemoved(mMyUid, sMyPackageName); |
Peter Visontay | 859206c | 2018-01-03 15:43:19 +0000 | [diff] [blame] | 281 | assertThat(getLoggedOps()).isNull(); |
| 282 | } |
| 283 | |
Philip P. Moltmann | 0027a67 | 2019-06-29 03:36:19 +0000 | [diff] [blame] | 284 | |
Nate Myren | 697650b | 2020-01-23 13:25:06 -0800 | [diff] [blame] | 285 | /* |
| 286 | TODO ntmyren: re enable when we have time to rewrite test. |
Winson | 470b15b | 2019-05-07 16:29:59 -0700 | [diff] [blame] | 287 | @Test |
| 288 | public void testPackageRemovedHistoricalOps() throws InterruptedException { |
| 289 | mAppOpsService.setMode(OP_READ_SMS, mMyUid, sMyPackageName, MODE_ALLOWED); |
Philip P. Moltmann | da554e4 | 2019-12-20 11:21:02 -0800 | [diff] [blame] | 290 | mAppOpsService.noteOperation(OP_READ_SMS, mMyUid, sMyPackageName, null, false, null); |
Winson | 470b15b | 2019-05-07 16:29:59 -0700 | [diff] [blame] | 291 | |
| 292 | AppOpsManager.HistoricalOps historicalOps = new AppOpsManager.HistoricalOps(0, 15000); |
Philip P. Moltmann | 4aacd71 | 2020-01-03 12:32:20 -0800 | [diff] [blame] | 293 | historicalOps.increaseAccessCount(OP_READ_SMS, mMyUid, sMyPackageName, null, |
Winson | 470b15b | 2019-05-07 16:29:59 -0700 | [diff] [blame] | 294 | AppOpsManager.UID_STATE_PERSISTENT, 0, 1); |
| 295 | |
| 296 | mAppOpsService.addHistoricalOps(historicalOps); |
| 297 | |
| 298 | AtomicReference<AppOpsManager.HistoricalOps> resultOpsRef = new AtomicReference<>(); |
| 299 | AtomicReference<CountDownLatch> latchRef = new AtomicReference<>(new CountDownLatch(1)); |
| 300 | RemoteCallback callback = new RemoteCallback(result -> { |
| 301 | resultOpsRef.set(result.getParcelable(AppOpsManager.KEY_HISTORICAL_OPS)); |
| 302 | latchRef.get().countDown(); |
| 303 | }); |
| 304 | |
| 305 | // First, do a fetch to ensure it's written |
Philip P. Moltmann | 4aacd71 | 2020-01-03 12:32:20 -0800 | [diff] [blame] | 306 | mAppOpsService.getHistoricalOps(mMyUid, sMyPackageName, null, null, |
| 307 | FILTER_BY_UID | FILTER_BY_PACKAGE_NAME, 0, Long.MAX_VALUE, 0, callback); |
Winson | 470b15b | 2019-05-07 16:29:59 -0700 | [diff] [blame] | 308 | |
| 309 | latchRef.get().await(5, TimeUnit.SECONDS); |
| 310 | assertThat(latchRef.get().getCount()).isEqualTo(0); |
| 311 | assertThat(resultOpsRef.get().isEmpty()).isFalse(); |
| 312 | |
| 313 | // Then, check it's deleted on removal |
| 314 | mAppOpsService.packageRemoved(mMyUid, sMyPackageName); |
| 315 | |
| 316 | latchRef.set(new CountDownLatch(1)); |
| 317 | |
Philip P. Moltmann | 4aacd71 | 2020-01-03 12:32:20 -0800 | [diff] [blame] | 318 | mAppOpsService.getHistoricalOps(mMyUid, sMyPackageName, null, null, |
| 319 | FILTER_BY_UID | FILTER_BY_PACKAGE_NAME, 0, Long.MAX_VALUE, 0, callback); |
Winson | 470b15b | 2019-05-07 16:29:59 -0700 | [diff] [blame] | 320 | |
| 321 | latchRef.get().await(5, TimeUnit.SECONDS); |
| 322 | assertThat(latchRef.get().getCount()).isEqualTo(0); |
| 323 | assertThat(resultOpsRef.get().isEmpty()).isTrue(); |
| 324 | } |
Nate Myren | 697650b | 2020-01-23 13:25:06 -0800 | [diff] [blame] | 325 | */ |
Winson | 470b15b | 2019-05-07 16:29:59 -0700 | [diff] [blame] | 326 | |
Peter Visontay | 859206c | 2018-01-03 15:43:19 +0000 | [diff] [blame] | 327 | @Test |
| 328 | public void testUidRemoved() { |
Philip P. Moltmann | 6b4f3d5 | 2019-05-08 15:14:09 -0700 | [diff] [blame] | 329 | mAppOpsService.setMode(OP_READ_SMS, mMyUid, sMyPackageName, MODE_ALLOWED); |
Philip P. Moltmann | da554e4 | 2019-12-20 11:21:02 -0800 | [diff] [blame] | 330 | mAppOpsService.noteOperation(OP_READ_SMS, mMyUid, sMyPackageName, null, false, null); |
Peter Visontay | 859206c | 2018-01-03 15:43:19 +0000 | [diff] [blame] | 331 | |
| 332 | List<PackageOps> loggedOps = getLoggedOps(); |
| 333 | assertContainsOp(loggedOps, OP_READ_SMS, mTestStartMillis, -1, MODE_ALLOWED); |
| 334 | |
| 335 | mAppOpsService.uidRemoved(mMyUid); |
| 336 | assertThat(getLoggedOps()).isNull(); |
| 337 | } |
| 338 | |
Amith Yamasani | 23d4cd7 | 2019-04-10 17:57:00 -0700 | [diff] [blame] | 339 | private void setupProcStateTests() { |
| 340 | // For the location proc state tests |
Philip P. Moltmann | 6b4f3d5 | 2019-05-08 15:14:09 -0700 | [diff] [blame] | 341 | mAppOpsService.setMode(OP_COARSE_LOCATION, mMyUid, sMyPackageName, MODE_FOREGROUND); |
Amith Yamasani | 23d4cd7 | 2019-04-10 17:57:00 -0700 | [diff] [blame] | 342 | mAppOpsService.mConstants.FG_SERVICE_STATE_SETTLE_TIME = 0; |
| 343 | mAppOpsService.mConstants.TOP_STATE_SETTLE_TIME = 0; |
| 344 | mAppOpsService.mConstants.BG_STATE_SETTLE_TIME = 0; |
| 345 | } |
| 346 | |
| 347 | @Test |
| 348 | public void testUidProcStateChange_cachedToTopToCached() throws Exception { |
| 349 | setupProcStateTests(); |
| 350 | |
Hui Yu | 2696932 | 2019-08-21 14:56:35 -0700 | [diff] [blame] | 351 | mAppOpsService.updateUidProcState(mMyUid, ActivityManager.PROCESS_STATE_CACHED_EMPTY, |
| 352 | ActivityManager.PROCESS_CAPABILITY_NONE); |
Philip P. Moltmann | da554e4 | 2019-12-20 11:21:02 -0800 | [diff] [blame] | 353 | assertThat(mAppOpsService.noteOperation(OP_COARSE_LOCATION, mMyUid, sMyPackageName, null, |
| 354 | false, null)).isNotEqualTo(MODE_ALLOWED); |
Amith Yamasani | 23d4cd7 | 2019-04-10 17:57:00 -0700 | [diff] [blame] | 355 | |
Hui Yu | 2696932 | 2019-08-21 14:56:35 -0700 | [diff] [blame] | 356 | mAppOpsService.updateUidProcState(mMyUid, ActivityManager.PROCESS_STATE_TOP, |
| 357 | ActivityManager.PROCESS_CAPABILITY_FOREGROUND_LOCATION); |
Philip P. Moltmann | da554e4 | 2019-12-20 11:21:02 -0800 | [diff] [blame] | 358 | assertThat(mAppOpsService.noteOperation(OP_COARSE_LOCATION, mMyUid, sMyPackageName, null, |
| 359 | false, null)).isEqualTo(MODE_ALLOWED); |
Amith Yamasani | 23d4cd7 | 2019-04-10 17:57:00 -0700 | [diff] [blame] | 360 | |
Hui Yu | 2696932 | 2019-08-21 14:56:35 -0700 | [diff] [blame] | 361 | mAppOpsService.updateUidProcState(mMyUid, ActivityManager.PROCESS_STATE_CACHED_EMPTY, |
| 362 | ActivityManager.PROCESS_CAPABILITY_NONE); |
Amith Yamasani | 23d4cd7 | 2019-04-10 17:57:00 -0700 | [diff] [blame] | 363 | // Second time to make sure that settle time is overcome |
| 364 | Thread.sleep(50); |
Hui Yu | 2696932 | 2019-08-21 14:56:35 -0700 | [diff] [blame] | 365 | mAppOpsService.updateUidProcState(mMyUid, ActivityManager.PROCESS_STATE_CACHED_EMPTY, |
| 366 | ActivityManager.PROCESS_CAPABILITY_NONE); |
Philip P. Moltmann | da554e4 | 2019-12-20 11:21:02 -0800 | [diff] [blame] | 367 | assertThat(mAppOpsService.noteOperation(OP_COARSE_LOCATION, mMyUid, sMyPackageName, null, |
| 368 | false, null)).isNotEqualTo(MODE_ALLOWED); |
Amith Yamasani | 23d4cd7 | 2019-04-10 17:57:00 -0700 | [diff] [blame] | 369 | } |
| 370 | |
| 371 | @Test |
Svet Ganov | 4764107 | 2019-06-06 12:57:12 -0700 | [diff] [blame] | 372 | public void testUidProcStateChange_cachedToFgs() { |
Amith Yamasani | 23d4cd7 | 2019-04-10 17:57:00 -0700 | [diff] [blame] | 373 | setupProcStateTests(); |
Hui Yu | 2696932 | 2019-08-21 14:56:35 -0700 | [diff] [blame] | 374 | mAppOpsService.updateUidProcState(mMyUid, ActivityManager.PROCESS_STATE_CACHED_EMPTY, |
| 375 | ActivityManager.PROCESS_CAPABILITY_NONE); |
Philip P. Moltmann | da554e4 | 2019-12-20 11:21:02 -0800 | [diff] [blame] | 376 | assertThat(mAppOpsService.noteOperation(OP_COARSE_LOCATION, mMyUid, sMyPackageName, null, |
| 377 | false, null)).isNotEqualTo(MODE_ALLOWED); |
Amith Yamasani | 23d4cd7 | 2019-04-10 17:57:00 -0700 | [diff] [blame] | 378 | |
Hui Yu | 2696932 | 2019-08-21 14:56:35 -0700 | [diff] [blame] | 379 | mAppOpsService.updateUidProcState(mMyUid, PROCESS_STATE_FOREGROUND_SERVICE, |
| 380 | ActivityManager.PROCESS_CAPABILITY_NONE); |
Philip P. Moltmann | da554e4 | 2019-12-20 11:21:02 -0800 | [diff] [blame] | 381 | assertThat(mAppOpsService.noteOperation(OP_COARSE_LOCATION, mMyUid, sMyPackageName, null, |
| 382 | false, null)).isNotEqualTo(MODE_ALLOWED); |
Amith Yamasani | 23d4cd7 | 2019-04-10 17:57:00 -0700 | [diff] [blame] | 383 | } |
| 384 | |
| 385 | @Test |
Svet Ganov | 4764107 | 2019-06-06 12:57:12 -0700 | [diff] [blame] | 386 | public void testUidProcStateChange_cachedToFgsLocation() { |
Amith Yamasani | 23d4cd7 | 2019-04-10 17:57:00 -0700 | [diff] [blame] | 387 | setupProcStateTests(); |
| 388 | |
Hui Yu | 2696932 | 2019-08-21 14:56:35 -0700 | [diff] [blame] | 389 | mAppOpsService.updateUidProcState(mMyUid, ActivityManager.PROCESS_STATE_CACHED_EMPTY, |
| 390 | ActivityManager.PROCESS_CAPABILITY_NONE); |
Philip P. Moltmann | da554e4 | 2019-12-20 11:21:02 -0800 | [diff] [blame] | 391 | assertThat(mAppOpsService.noteOperation(OP_COARSE_LOCATION, mMyUid, sMyPackageName, null, |
| 392 | false, null)).isNotEqualTo(MODE_ALLOWED); |
Amith Yamasani | 23d4cd7 | 2019-04-10 17:57:00 -0700 | [diff] [blame] | 393 | |
Hui Yu | 2696932 | 2019-08-21 14:56:35 -0700 | [diff] [blame] | 394 | mAppOpsService.updateUidProcState(mMyUid, PROCESS_STATE_FOREGROUND_SERVICE, |
| 395 | ActivityManager.PROCESS_CAPABILITY_FOREGROUND_LOCATION); |
Philip P. Moltmann | da554e4 | 2019-12-20 11:21:02 -0800 | [diff] [blame] | 396 | assertThat(mAppOpsService.noteOperation(OP_COARSE_LOCATION, mMyUid, sMyPackageName, null, |
| 397 | false, null)).isEqualTo(MODE_ALLOWED); |
Amith Yamasani | 23d4cd7 | 2019-04-10 17:57:00 -0700 | [diff] [blame] | 398 | } |
| 399 | |
| 400 | @Test |
| 401 | public void testUidProcStateChange_topToFgs() throws Exception { |
| 402 | setupProcStateTests(); |
| 403 | |
Hui Yu | 2696932 | 2019-08-21 14:56:35 -0700 | [diff] [blame] | 404 | mAppOpsService.updateUidProcState(mMyUid, ActivityManager.PROCESS_STATE_CACHED_EMPTY, |
| 405 | ActivityManager.PROCESS_CAPABILITY_NONE); |
Philip P. Moltmann | da554e4 | 2019-12-20 11:21:02 -0800 | [diff] [blame] | 406 | assertThat(mAppOpsService.noteOperation(OP_COARSE_LOCATION, mMyUid, sMyPackageName, null, |
| 407 | false, null)).isNotEqualTo(MODE_ALLOWED); |
Amith Yamasani | 23d4cd7 | 2019-04-10 17:57:00 -0700 | [diff] [blame] | 408 | |
Hui Yu | 2696932 | 2019-08-21 14:56:35 -0700 | [diff] [blame] | 409 | mAppOpsService.updateUidProcState(mMyUid, ActivityManager.PROCESS_STATE_TOP, |
| 410 | ActivityManager.PROCESS_CAPABILITY_FOREGROUND_LOCATION); |
Philip P. Moltmann | da554e4 | 2019-12-20 11:21:02 -0800 | [diff] [blame] | 411 | assertThat(mAppOpsService.noteOperation(OP_COARSE_LOCATION, mMyUid, sMyPackageName, null, |
| 412 | false, null)).isEqualTo(MODE_ALLOWED); |
Amith Yamasani | 23d4cd7 | 2019-04-10 17:57:00 -0700 | [diff] [blame] | 413 | |
Hui Yu | 2696932 | 2019-08-21 14:56:35 -0700 | [diff] [blame] | 414 | mAppOpsService.updateUidProcState(mMyUid, PROCESS_STATE_FOREGROUND_SERVICE, |
| 415 | ActivityManager.PROCESS_CAPABILITY_NONE); |
Amith Yamasani | 23d4cd7 | 2019-04-10 17:57:00 -0700 | [diff] [blame] | 416 | // Second time to make sure that settle time is overcome |
| 417 | Thread.sleep(50); |
Hui Yu | 2696932 | 2019-08-21 14:56:35 -0700 | [diff] [blame] | 418 | mAppOpsService.updateUidProcState(mMyUid, PROCESS_STATE_FOREGROUND_SERVICE, |
| 419 | ActivityManager.PROCESS_CAPABILITY_NONE); |
Philip P. Moltmann | da554e4 | 2019-12-20 11:21:02 -0800 | [diff] [blame] | 420 | assertThat(mAppOpsService.noteOperation(OP_COARSE_LOCATION, mMyUid, sMyPackageName, null, |
| 421 | false, null)).isNotEqualTo(MODE_ALLOWED); |
Amith Yamasani | 23d4cd7 | 2019-04-10 17:57:00 -0700 | [diff] [blame] | 422 | } |
| 423 | |
| 424 | @Test |
| 425 | public void testUidProcStateChange_topToFgsLocationToFgs() throws Exception { |
| 426 | setupProcStateTests(); |
| 427 | |
Hui Yu | 2696932 | 2019-08-21 14:56:35 -0700 | [diff] [blame] | 428 | mAppOpsService.updateUidProcState(mMyUid, ActivityManager.PROCESS_STATE_CACHED_EMPTY, |
| 429 | ActivityManager.PROCESS_CAPABILITY_NONE); |
Philip P. Moltmann | da554e4 | 2019-12-20 11:21:02 -0800 | [diff] [blame] | 430 | assertThat(mAppOpsService.noteOperation(OP_COARSE_LOCATION, mMyUid, sMyPackageName, null, |
| 431 | false, null)).isNotEqualTo(MODE_ALLOWED); |
Amith Yamasani | 23d4cd7 | 2019-04-10 17:57:00 -0700 | [diff] [blame] | 432 | |
Hui Yu | 2696932 | 2019-08-21 14:56:35 -0700 | [diff] [blame] | 433 | mAppOpsService.updateUidProcState(mMyUid, ActivityManager.PROCESS_STATE_TOP, |
| 434 | ActivityManager.PROCESS_CAPABILITY_FOREGROUND_LOCATION); |
Philip P. Moltmann | da554e4 | 2019-12-20 11:21:02 -0800 | [diff] [blame] | 435 | assertThat(mAppOpsService.noteOperation(OP_COARSE_LOCATION, mMyUid, sMyPackageName, null, |
| 436 | false, null)).isEqualTo(MODE_ALLOWED); |
Amith Yamasani | 23d4cd7 | 2019-04-10 17:57:00 -0700 | [diff] [blame] | 437 | |
Hui Yu | 2696932 | 2019-08-21 14:56:35 -0700 | [diff] [blame] | 438 | mAppOpsService.updateUidProcState(mMyUid, PROCESS_STATE_FOREGROUND_SERVICE, |
| 439 | ActivityManager.PROCESS_CAPABILITY_FOREGROUND_LOCATION); |
Amith Yamasani | 23d4cd7 | 2019-04-10 17:57:00 -0700 | [diff] [blame] | 440 | // Second time to make sure that settle time is overcome |
| 441 | Thread.sleep(50); |
Hui Yu | 2696932 | 2019-08-21 14:56:35 -0700 | [diff] [blame] | 442 | mAppOpsService.updateUidProcState(mMyUid, PROCESS_STATE_FOREGROUND_SERVICE, |
| 443 | ActivityManager.PROCESS_CAPABILITY_FOREGROUND_LOCATION); |
Philip P. Moltmann | da554e4 | 2019-12-20 11:21:02 -0800 | [diff] [blame] | 444 | assertThat(mAppOpsService.noteOperation(OP_COARSE_LOCATION, mMyUid, sMyPackageName, null, |
| 445 | false, null)).isEqualTo(MODE_ALLOWED); |
Amith Yamasani | 23d4cd7 | 2019-04-10 17:57:00 -0700 | [diff] [blame] | 446 | |
Hui Yu | 2696932 | 2019-08-21 14:56:35 -0700 | [diff] [blame] | 447 | mAppOpsService.updateUidProcState(mMyUid, PROCESS_STATE_FOREGROUND_SERVICE, |
| 448 | ActivityManager.PROCESS_CAPABILITY_NONE); |
Amith Yamasani | 23d4cd7 | 2019-04-10 17:57:00 -0700 | [diff] [blame] | 449 | // Second time to make sure that settle time is overcome |
| 450 | Thread.sleep(50); |
Hui Yu | 2696932 | 2019-08-21 14:56:35 -0700 | [diff] [blame] | 451 | mAppOpsService.updateUidProcState(mMyUid, PROCESS_STATE_FOREGROUND_SERVICE, |
| 452 | ActivityManager.PROCESS_CAPABILITY_NONE); |
Philip P. Moltmann | da554e4 | 2019-12-20 11:21:02 -0800 | [diff] [blame] | 453 | assertThat(mAppOpsService.noteOperation(OP_COARSE_LOCATION, mMyUid, sMyPackageName, null, |
| 454 | false, null)).isNotEqualTo(MODE_ALLOWED); |
Amith Yamasani | 23d4cd7 | 2019-04-10 17:57:00 -0700 | [diff] [blame] | 455 | } |
| 456 | |
Peter Visontay | 859206c | 2018-01-03 15:43:19 +0000 | [diff] [blame] | 457 | private List<PackageOps> getLoggedOps() { |
Philip P. Moltmann | 6b4f3d5 | 2019-05-08 15:14:09 -0700 | [diff] [blame] | 458 | return mAppOpsService.getOpsForPackage(mMyUid, sMyPackageName, null /* all ops */); |
Peter Visontay | 859206c | 2018-01-03 15:43:19 +0000 | [diff] [blame] | 459 | } |
| 460 | |
| 461 | private void assertContainsOp(List<PackageOps> loggedOps, int opCode, long minMillis, |
| 462 | long minRejectMillis, int mode) { |
| 463 | |
| 464 | boolean opLogged = false; |
| 465 | for (PackageOps pkgOps : loggedOps) { |
| 466 | assertWithMessage("Unexpected UID").that(mMyUid).isEqualTo(pkgOps.getUid()); |
Philip P. Moltmann | 6b4f3d5 | 2019-05-08 15:14:09 -0700 | [diff] [blame] | 467 | assertWithMessage("Unexpected package name").that(sMyPackageName).isEqualTo( |
Peter Visontay | 859206c | 2018-01-03 15:43:19 +0000 | [diff] [blame] | 468 | pkgOps.getPackageName()); |
| 469 | |
| 470 | for (OpEntry opEntry : pkgOps.getOps()) { |
| 471 | if (opCode != opEntry.getOp()) { |
| 472 | continue; |
| 473 | } |
| 474 | opLogged = true; |
| 475 | |
| 476 | assertWithMessage("Unexpected mode").that(mode).isEqualTo(opEntry.getMode()); |
| 477 | if (minMillis > 0) { |
| 478 | assertWithMessage("Unexpected timestamp") |
Philip P. Moltmann | 49bd9e1 | 2019-11-26 15:18:16 -0800 | [diff] [blame] | 479 | .that(opEntry.getLastAccessTime(OP_FLAGS_ALL)).isAtLeast(minMillis); |
Peter Visontay | 859206c | 2018-01-03 15:43:19 +0000 | [diff] [blame] | 480 | } |
| 481 | if (minRejectMillis > 0) { |
Philip P. Moltmann | 49bd9e1 | 2019-11-26 15:18:16 -0800 | [diff] [blame] | 482 | assertWithMessage("Unexpected rejection timestamp").that( |
| 483 | opEntry.getLastRejectTime(OP_FLAGS_ALL)).isAtLeast(minRejectMillis); |
Peter Visontay | 859206c | 2018-01-03 15:43:19 +0000 | [diff] [blame] | 484 | } |
| 485 | } |
| 486 | } |
| 487 | assertWithMessage("Op was not logged").that(opLogged).isTrue(); |
| 488 | } |
| 489 | } |