Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2481def5 authored by Brad Ebinger's avatar Brad Ebinger
Browse files

Add Telecom flag configs to the telecom dumpsys

Adds the telecom flag configurations to the telecom dumpsys
so that we have the flag states available in the bugreport for
debugging.

Bug: 298087926
Test: adb shell dumpsys telecom; atest TelecomUnitTests:TelecomServiceImplTest
Change-Id: Ib2e486f57dbd6dbeb4d96dfa257da9fe4b22f565
parent 821faa54
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
@@ -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;
@@ -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);
@@ -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
         */
+24 −0
Original line number Diff line number Diff line
@@ -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;
@@ -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;
@@ -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 {