[BACKPORT] Add Location Tests for SDK28 PSL

-Test that SDK28 apps are validated for COARSE
 location for PhoneStateListener#LISTEN_CELL_INFO
-Test that SDK28 apps are validated for COARSE
 location for PhoneStateListener#LISTEN_CELL_LOCATION_
-Test that SDK28 apps receive full ServiceState

Bug: 158484422
Test: cts - atest TelephonyLocationTests
Merged-In: I66d3ddc4ad503639e9d13e875336cb2a44a700e6
Change-Id: I66d3ddc4ad503639e9d13e875336cb2a44a700e6
(cherry picked from commit 6e6c4298dd1dec84a95b28fc0be861d0f03fac54)
diff --git a/tests/tests/telephony/current/src/android/telephony/cts/TelephonyLocationTests.java b/tests/tests/telephony/current/src/android/telephony/cts/TelephonyLocationTests.java
index 7b522f7..f5e5b7a 100644
--- a/tests/tests/telephony/current/src/android/telephony/cts/TelephonyLocationTests.java
+++ b/tests/tests/telephony/current/src/android/telephony/cts/TelephonyLocationTests.java
@@ -1,5 +1,7 @@
 package android.telephony.cts;
 
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
@@ -131,6 +133,28 @@
     }
 
     @Test
+    public void testSdk28ServiceStateListeningWithoutPermissions() {
+        if (!mShouldTest) return;
+
+        withRevokedPermission(LOCATION_ACCESS_APP_SDK28_PACKAGE, () -> {
+                    ServiceState ss = (ServiceState) performLocationAccessCommand(
+                            CtsLocationAccessService.COMMAND_GET_SERVICE_STATE_FROM_LISTENER);
+                    assertNotNull(ss);
+                    assertNotEquals(ss, ss.createLocationInfoSanitizedCopy(false));
+
+                    withRevokedPermission(LOCATION_ACCESS_APP_SDK28_PACKAGE, () -> {
+                                ServiceState ss1 = (ServiceState) performLocationAccessCommand(
+                                        CtsLocationAccessService
+                                                .COMMAND_GET_SERVICE_STATE_FROM_LISTENER);
+                                assertNotNull(ss1);
+                                assertNotEquals(ss1, ss1.createLocationInfoSanitizedCopy(true));
+                            },
+                            Manifest.permission.ACCESS_COARSE_LOCATION);
+                },
+                Manifest.permission.ACCESS_FINE_LOCATION);
+    }
+
+    @Test
     public void testRegistryPermissionsForCellLocation() {
         if (!mShouldTest) return;
 
@@ -150,6 +174,18 @@
     }
 
     @Test
+    public void testSdk28RegistryPermissionsForCellLocation() {
+        if (!mShouldTest) return;
+
+        withRevokedPermission(LOCATION_ACCESS_APP_SDK28_PACKAGE, () -> {
+                    CellLocation cellLocation = (CellLocation) performLocationAccessCommand(
+                            CtsLocationAccessService.COMMAND_LISTEN_CELL_LOCATION);
+                    assertNull(cellLocation);
+                },
+                Manifest.permission.ACCESS_COARSE_LOCATION);
+    }
+
+    @Test
     public void testRegistryPermissionsForCellInfo() {
         if (!mShouldTest) return;
 
@@ -169,6 +205,18 @@
     }
 
     @Test
+    public void testSdk28RegistryPermissionsForCellInfo() {
+        if (!mShouldTest) return;
+
+        withRevokedPermission(LOCATION_ACCESS_APP_SDK28_PACKAGE, () -> {
+                    List<CellInfo> cis = (List<CellInfo>) performLocationAccessCommand(
+                            CtsLocationAccessService.COMMAND_LISTEN_CELL_INFO);
+                    assertTrue(cis == null || cis.isEmpty());
+                },
+                Manifest.permission.ACCESS_COARSE_LOCATION);
+    }
+
+    @Test
     public void testSdk28CellLocation() {
         if (!mShouldTest) return;