Loading src/com/android/server/telecom/TelecomServiceImpl.java +28 −0 Original line number Diff line number Diff line Loading @@ -89,6 +89,7 @@ import com.android.server.telecom.voip.VoipCallTransactionResult; import java.io.FileDescriptor; import java.io.PrintWriter; import java.lang.reflect.Method; import java.util.HashSet; import java.util.List; import java.util.Objects; Loading Loading @@ -1968,6 +1969,11 @@ public class TelecomServiceImpl { pw.increaseIndent(); Analytics.dump(pw); pw.decreaseIndent(); pw.println("Flag Configurations: "); pw.increaseIndent(); reflectAndPrintFlagConfigs(pw); pw.decreaseIndent(); } if (isTimeLineView) { Log.dumpEventsTimeline(pw); Loading @@ -1976,6 +1982,28 @@ public class TelecomServiceImpl { } } /** * Print all feature flag configurations that Telecom is using for debugging purposes. */ private void reflectAndPrintFlagConfigs(IndentingPrintWriter pw) { try { // Look away, a forbidden technique (reflection) is being used to allow us to get // all flag configs without having to add them manually to this method. Method[] methods = FeatureFlags.class.getMethods(); if (methods.length == 0) { pw.println("NONE"); return; } for (Method m : methods) { pw.println(m.getName() + "-> " + m.invoke(mFeatureFlags)); } } catch (Exception e) { pw.println("[ERROR]"); } } /** * @see android.telecom.TelecomManager#createManageBlockedNumbersIntent */ Loading tests/src/com/android/server/telecom/tests/TelecomServiceImplTest.java +24 −0 Original line number Diff line number Diff line Loading @@ -77,6 +77,7 @@ import org.mockito.ArgumentCaptor; import org.mockito.ArgumentMatcher; import org.mockito.Mock; import java.lang.reflect.Method; import java.util.Collection; import java.util.List; import java.util.concurrent.Executor; Loading @@ -87,6 +88,7 @@ import static android.Manifest.permission.REGISTER_SIM_SUBSCRIPTION; import static android.Manifest.permission.WRITE_SECURE_SETTINGS; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertThrows; import static org.junit.Assert.assertTrue; Loading Loading @@ -1706,6 +1708,28 @@ public class TelecomServiceImplTest extends TelecomTestCase { verify(mContext, never()).sendBroadcastAsUser(any(Intent.class), any(UserHandle.class)); } /** * FeatureFlags is autogenerated code, so there could be a situation where something changes * outside of Telecom control that breaks reflection. This test attempts to ensure that changes * to auto-generated FeatureFlags code that breaks reflection are caught early. */ @SmallTest @Test public void testFlagConfigReflectionWorks() { try { Method[] methods = FeatureFlags.class.getMethods(); for (Method m : methods) { // test getting the name and invoking the flag code String name = m.getName(); Object val = m.invoke(mFeatureFlags); assertNotNull(name); assertNotNull(val); } } catch (Exception e) { fail("Reflection failed for FeatureFlags with error: " + e); } } @SmallTest @Test public void testIsVoicemailNumber() throws Exception { Loading Loading
src/com/android/server/telecom/TelecomServiceImpl.java +28 −0 Original line number Diff line number Diff line Loading @@ -89,6 +89,7 @@ import com.android.server.telecom.voip.VoipCallTransactionResult; import java.io.FileDescriptor; import java.io.PrintWriter; import java.lang.reflect.Method; import java.util.HashSet; import java.util.List; import java.util.Objects; Loading Loading @@ -1968,6 +1969,11 @@ public class TelecomServiceImpl { pw.increaseIndent(); Analytics.dump(pw); pw.decreaseIndent(); pw.println("Flag Configurations: "); pw.increaseIndent(); reflectAndPrintFlagConfigs(pw); pw.decreaseIndent(); } if (isTimeLineView) { Log.dumpEventsTimeline(pw); Loading @@ -1976,6 +1982,28 @@ public class TelecomServiceImpl { } } /** * Print all feature flag configurations that Telecom is using for debugging purposes. */ private void reflectAndPrintFlagConfigs(IndentingPrintWriter pw) { try { // Look away, a forbidden technique (reflection) is being used to allow us to get // all flag configs without having to add them manually to this method. Method[] methods = FeatureFlags.class.getMethods(); if (methods.length == 0) { pw.println("NONE"); return; } for (Method m : methods) { pw.println(m.getName() + "-> " + m.invoke(mFeatureFlags)); } } catch (Exception e) { pw.println("[ERROR]"); } } /** * @see android.telecom.TelecomManager#createManageBlockedNumbersIntent */ Loading
tests/src/com/android/server/telecom/tests/TelecomServiceImplTest.java +24 −0 Original line number Diff line number Diff line Loading @@ -77,6 +77,7 @@ import org.mockito.ArgumentCaptor; import org.mockito.ArgumentMatcher; import org.mockito.Mock; import java.lang.reflect.Method; import java.util.Collection; import java.util.List; import java.util.concurrent.Executor; Loading @@ -87,6 +88,7 @@ import static android.Manifest.permission.REGISTER_SIM_SUBSCRIPTION; import static android.Manifest.permission.WRITE_SECURE_SETTINGS; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertThrows; import static org.junit.Assert.assertTrue; Loading Loading @@ -1706,6 +1708,28 @@ public class TelecomServiceImplTest extends TelecomTestCase { verify(mContext, never()).sendBroadcastAsUser(any(Intent.class), any(UserHandle.class)); } /** * FeatureFlags is autogenerated code, so there could be a situation where something changes * outside of Telecom control that breaks reflection. This test attempts to ensure that changes * to auto-generated FeatureFlags code that breaks reflection are caught early. */ @SmallTest @Test public void testFlagConfigReflectionWorks() { try { Method[] methods = FeatureFlags.class.getMethods(); for (Method m : methods) { // test getting the name and invoking the flag code String name = m.getName(); Object val = m.invoke(mFeatureFlags); assertNotNull(name); assertNotNull(val); } } catch (Exception e) { fail("Reflection failed for FeatureFlags with error: " + e); } } @SmallTest @Test public void testIsVoicemailNumber() throws Exception { Loading