Skip proximity related LocationManagerTests on secondary users.

These tests cannot run on secondary users because requestGeoFence is limited to SYSTEM_USER.

bug: 124498601
Test: On a prod PI phone from primary and secondary user:
cts-tradefed run cts-dev -a arm64-v8a -m CtsLocationTestCases -t android.location.cts.LocationManagerTest
Change-Id: I1f053f0c940b89f517b16908be2274680e4da237
Merged-In: I1f053f0c940b89f517b16908be2274680e4da237
diff --git a/tests/tests/location/src/android/location/cts/LocationManagerTest.java b/tests/tests/location/src/android/location/cts/LocationManagerTest.java
index d58ebb6..0366158 100644
--- a/tests/tests/location/src/android/location/cts/LocationManagerTest.java
+++ b/tests/tests/location/src/android/location/cts/LocationManagerTest.java
@@ -38,9 +38,11 @@
 import android.os.HandlerThread;
 import android.os.Looper;
 import android.os.SystemClock;
+import android.os.UserManager;
 import android.platform.test.annotations.AppModeFull;
 import android.provider.Settings;
 import android.test.UiThreadTest;
+import android.util.Log;
 
 import java.util.List;
 
@@ -52,6 +54,9 @@
  * android.permission.ACCESS_LOCATION_EXTRA_COMMANDS to send extra commands to GPS provider
  */
 public class LocationManagerTest extends BaseMockLocationTest {
+
+    private static final String TAG = "LocationManagerTest";
+
     private static final long TEST_TIME_OUT = 5000;
 
     private static final String TEST_MOCK_PROVIDER_NAME = "test_provider";
@@ -1096,6 +1101,10 @@
      * Tests basic proximity alert when entering proximity
      */
     public void testEnterProximity() throws Exception {
+        if (!isSystemUser()) {
+            Log.i(TAG, "Skipping test on secondary user");
+            return;
+        }
         // need to mock the fused location provider for proximity tests
         mockFusedLocation();
 
@@ -1108,6 +1117,10 @@
      * Tests proximity alert when entering proximity, with no expiration
      */
     public void testEnterProximity_noexpire() throws Exception {
+        if (!isSystemUser()) {
+            Log.i(TAG, "Skipping test on secondary user");
+            return;
+        }
         // need to mock the fused location provider for proximity tests
         mockFusedLocation();
 
@@ -1120,6 +1133,10 @@
      * Tests basic proximity alert when exiting proximity
      */
     public void testExitProximity() throws Exception {
+        if (!isSystemUser()) {
+            Log.i(TAG, "Skipping test on secondary user");
+            return;
+        }
         // need to mock the fused location provider for proximity tests
         mockFusedLocation();
 
@@ -1139,6 +1156,10 @@
      * Tests basic proximity alert when initially within proximity
      */
     public void testInitiallyWithinProximity() throws Exception {
+        if (!isSystemUser()) {
+            Log.i(TAG, "Skipping test on secondary user");
+            return;
+        }
         // need to mock the fused location provider for proximity tests
         mockFusedLocation();
 
@@ -1525,4 +1546,9 @@
             }
         }
     }
+
+    private boolean isSystemUser() {
+        UserManager userManager = mContext.getSystemService(UserManager.class);
+        return userManager.isSystemUser();
+    }
 }