Loading tests/telephonytests/src/com/android/internal/telephony/ContextFixture.java +4 −0 Original line number Diff line number Diff line Loading @@ -54,6 +54,7 @@ import android.content.res.Configuration; import android.content.res.Resources; import android.database.Cursor; import android.database.MatrixCursor; import android.location.LocationManager; import android.net.ConnectivityManager; import android.net.Network; import android.net.Uri; Loading Loading @@ -292,6 +293,8 @@ public class ContextFixture implements TestFixture<Context> { return Context.SYSTEM_CONFIG_SERVICE; } else if (serviceClass == ActivityManager.class) { return Context.ACTIVITY_SERVICE; } else if (serviceClass == LocationManager.class) { return Context.LOCATION_SERVICE; } return super.getSystemServiceName(serviceClass); } Loading Loading @@ -628,6 +631,7 @@ public class ContextFixture implements TestFixture<Context> { mock(TelephonyRegistryManager.class); private final SystemConfigManager mSystemConfigManager = mock(SystemConfigManager.class); private final PowerWhitelistManager mPowerWhitelistManager = mock(PowerWhitelistManager.class); private final LocationManager mLocationManager = mock(LocationManager.class); private final ContentProvider mContentProvider = spy(new FakeContentProvider()); Loading tests/telephonytests/src/com/android/internal/telephony/TelephonyRegistryTest.java +11 −9 Original line number Diff line number Diff line Loading @@ -53,7 +53,6 @@ import com.android.server.TelephonyRegistry; import org.junit.After; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; Loading Loading @@ -364,7 +363,7 @@ public class TelephonyRegistryTest extends TelephonyTest { assertSecurityExceptionThrown(entry.getKey(), entry.getValue()); } // Grant permssion // Grant permission mContextFixture.addCallingOrSelfPermission(android.Manifest.permission.READ_PHONE_STATE); for (Map.Entry<Integer, String> entry : READ_PHONE_STATE_EVENTS.entrySet()) { assertSecurityExceptionNotThrown(entry.getKey(), entry.getValue()); Loading @@ -374,19 +373,22 @@ public class TelephonyRegistryTest extends TelephonyTest { /** * Test listen to events that require READ_PRECISE_PHONE_STATE permission. */ // FIXME(b/159082270) - Simply not granting location permission doesn't fix the test because // Location is soft-denied to apps that aren't in the foreground, and soft-denial currently // short-circuits the test. @Ignore("Skip due to b/159082270") @Test public void testReadPrecisePhoneStatePermission() { // Clear all permission grants for test. mContextFixture.addCallingOrSelfPermission(""); // Many of the events require LOCATION permission, but without READ_PHONE_STATE, they will // still throw exceptions. Since this test is testing READ_PRECISE_PHONE_STATE, all other // permissions should be granted up-front. mContextFixture.addCallingOrSelfPermission( android.Manifest.permission.READ_PHONE_STATE); mContextFixture.addCallingOrSelfPermission( android.Manifest.permission.ACCESS_FINE_LOCATION); for (Map.Entry<Integer, String> entry : READ_PRECISE_PHONE_STATE_EVENTS.entrySet()) { assertSecurityExceptionThrown(entry.getKey(), entry.getValue()); } // Grant permssion // Grant permission mContextFixture.addCallingOrSelfPermission( android.Manifest.permission.READ_PRECISE_PHONE_STATE); for (Map.Entry<Integer, String> entry : READ_PRECISE_PHONE_STATE_EVENTS.entrySet()) { Loading @@ -405,7 +407,7 @@ public class TelephonyRegistryTest extends TelephonyTest { assertSecurityExceptionThrown(entry.getKey(), entry.getValue()); } // Grant permssion // Grant permission mContextFixture.addCallingOrSelfPermission( android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE); for (Map.Entry<Integer, String> entry : READ_PREVILIGED_PHONE_STATE_EVENTS.entrySet()) { Loading @@ -424,7 +426,7 @@ public class TelephonyRegistryTest extends TelephonyTest { assertSecurityExceptionThrown(entry.getKey(), entry.getValue()); } // Grant permssion // Grant permission mContextFixture.addCallingOrSelfPermission( android.Manifest.permission.READ_ACTIVE_EMERGENCY_SESSION); for (Map.Entry<Integer, String> entry : READ_ACTIVE_EMERGENCY_SESSION_EVENTS.entrySet()) { Loading Loading
tests/telephonytests/src/com/android/internal/telephony/ContextFixture.java +4 −0 Original line number Diff line number Diff line Loading @@ -54,6 +54,7 @@ import android.content.res.Configuration; import android.content.res.Resources; import android.database.Cursor; import android.database.MatrixCursor; import android.location.LocationManager; import android.net.ConnectivityManager; import android.net.Network; import android.net.Uri; Loading Loading @@ -292,6 +293,8 @@ public class ContextFixture implements TestFixture<Context> { return Context.SYSTEM_CONFIG_SERVICE; } else if (serviceClass == ActivityManager.class) { return Context.ACTIVITY_SERVICE; } else if (serviceClass == LocationManager.class) { return Context.LOCATION_SERVICE; } return super.getSystemServiceName(serviceClass); } Loading Loading @@ -628,6 +631,7 @@ public class ContextFixture implements TestFixture<Context> { mock(TelephonyRegistryManager.class); private final SystemConfigManager mSystemConfigManager = mock(SystemConfigManager.class); private final PowerWhitelistManager mPowerWhitelistManager = mock(PowerWhitelistManager.class); private final LocationManager mLocationManager = mock(LocationManager.class); private final ContentProvider mContentProvider = spy(new FakeContentProvider()); Loading
tests/telephonytests/src/com/android/internal/telephony/TelephonyRegistryTest.java +11 −9 Original line number Diff line number Diff line Loading @@ -53,7 +53,6 @@ import com.android.server.TelephonyRegistry; import org.junit.After; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; Loading Loading @@ -364,7 +363,7 @@ public class TelephonyRegistryTest extends TelephonyTest { assertSecurityExceptionThrown(entry.getKey(), entry.getValue()); } // Grant permssion // Grant permission mContextFixture.addCallingOrSelfPermission(android.Manifest.permission.READ_PHONE_STATE); for (Map.Entry<Integer, String> entry : READ_PHONE_STATE_EVENTS.entrySet()) { assertSecurityExceptionNotThrown(entry.getKey(), entry.getValue()); Loading @@ -374,19 +373,22 @@ public class TelephonyRegistryTest extends TelephonyTest { /** * Test listen to events that require READ_PRECISE_PHONE_STATE permission. */ // FIXME(b/159082270) - Simply not granting location permission doesn't fix the test because // Location is soft-denied to apps that aren't in the foreground, and soft-denial currently // short-circuits the test. @Ignore("Skip due to b/159082270") @Test public void testReadPrecisePhoneStatePermission() { // Clear all permission grants for test. mContextFixture.addCallingOrSelfPermission(""); // Many of the events require LOCATION permission, but without READ_PHONE_STATE, they will // still throw exceptions. Since this test is testing READ_PRECISE_PHONE_STATE, all other // permissions should be granted up-front. mContextFixture.addCallingOrSelfPermission( android.Manifest.permission.READ_PHONE_STATE); mContextFixture.addCallingOrSelfPermission( android.Manifest.permission.ACCESS_FINE_LOCATION); for (Map.Entry<Integer, String> entry : READ_PRECISE_PHONE_STATE_EVENTS.entrySet()) { assertSecurityExceptionThrown(entry.getKey(), entry.getValue()); } // Grant permssion // Grant permission mContextFixture.addCallingOrSelfPermission( android.Manifest.permission.READ_PRECISE_PHONE_STATE); for (Map.Entry<Integer, String> entry : READ_PRECISE_PHONE_STATE_EVENTS.entrySet()) { Loading @@ -405,7 +407,7 @@ public class TelephonyRegistryTest extends TelephonyTest { assertSecurityExceptionThrown(entry.getKey(), entry.getValue()); } // Grant permssion // Grant permission mContextFixture.addCallingOrSelfPermission( android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE); for (Map.Entry<Integer, String> entry : READ_PREVILIGED_PHONE_STATE_EVENTS.entrySet()) { Loading @@ -424,7 +426,7 @@ public class TelephonyRegistryTest extends TelephonyTest { assertSecurityExceptionThrown(entry.getKey(), entry.getValue()); } // Grant permssion // Grant permission mContextFixture.addCallingOrSelfPermission( android.Manifest.permission.READ_ACTIVE_EMERGENCY_SESSION); for (Map.Entry<Integer, String> entry : READ_ACTIVE_EMERGENCY_SESSION_EVENTS.entrySet()) { Loading