Skip getCellLocation if we don't have telephony
Test: atest LocationPolicyTest
Fix: 160264045
Change-Id: I4f2be57405f8b5ea1a988f9c32731625708d484e
diff --git a/hostsidetests/appsecurity/test-apps/LocationPolicyApp/src/android/appsecurity/cts/locationpolicy/LocationPolicyTest.java b/hostsidetests/appsecurity/test-apps/LocationPolicyApp/src/android/appsecurity/cts/locationpolicy/LocationPolicyTest.java
index 74ce0c5..a91948b 100644
--- a/hostsidetests/appsecurity/test-apps/LocationPolicyApp/src/android/appsecurity/cts/locationpolicy/LocationPolicyTest.java
+++ b/hostsidetests/appsecurity/test-apps/LocationPolicyApp/src/android/appsecurity/cts/locationpolicy/LocationPolicyTest.java
@@ -49,14 +49,16 @@
PackageManager.PERMISSION_GRANTED,
pm.checkPermission(Manifest.permission.ACCESS_COARSE_LOCATION,
mContext.getPackageName()));
- TelephonyManager tele = mContext.getSystemService(TelephonyManager.class);
- try {
- tele.getCellLocation();
- fail(
- "ACCESS_FINE_LOCATION and ACCESS_COARSE_LOCATION Permissions not granted. Should have"
- + " received a security exception when invoking getCellLocation().");
- } catch (SecurityException ignore) {
- // That's what we want!
+ if (pm.hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) {
+ TelephonyManager tele = mContext.getSystemService(TelephonyManager.class);
+ try {
+ tele.getCellLocation();
+ fail(
+ "ACCESS_FINE_LOCATION and ACCESS_COARSE_LOCATION Permissions not granted. Should"
+ + " have received a security exception when invoking getCellLocation().");
+ } catch (SecurityException ignore) {
+ // That's what we want!
+ }
}
}
}