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

Commit f214d1f8 authored by Pranav Madapurmath's avatar Pranav Madapurmath
Browse files

Formalize TelephonyManager EmergencyCallDiagnostic

Formalize the TelephonyManager#EmergencyCallDiagnosticParams API as part
of the Telecom modularization. This is only used by Telecom so
promote the existing functionality into a proper API.

Bug: 308472794
Bug: 311773409
Test: atest TelephonyManagerTest
Change-Id: I53c2f1e1d095cf6ab92cb8b551e67905dde525a3
parent fc04788c
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -14749,6 +14749,7 @@ package android.telephony {
    method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public boolean matchesCurrentSimOperator(@NonNull String, int, @Nullable String);
    method public boolean needsOtaServiceProvisioning();
    method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void notifyOtaEmergencyNumberDbInstalled();
    method @FlaggedApi("com.android.server.telecom.flags.telecom_resolve_hidden_dependencies") @RequiresPermission(android.Manifest.permission.DUMP) public void persistEmergencyCallDiagnosticData(@NonNull String, @NonNull android.telephony.TelephonyManager.EmergencyCallDiagnosticParams);
    method @RequiresPermission(android.Manifest.permission.REBOOT) public int prepareForUnattendedReboot();
    method @Deprecated @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean rebootRadio();
    method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public void registerCarrierPrivilegesCallback(int, @NonNull java.util.concurrent.Executor, @NonNull android.telephony.TelephonyManager.CarrierPrivilegesCallback);
@@ -14926,6 +14927,21 @@ package android.telephony {
    method public default void onCarrierServiceChanged(@Nullable String, int);
  }
  @FlaggedApi("com.android.server.telecom.flags.telecom_resolve_hidden_dependencies") public static final class TelephonyManager.EmergencyCallDiagnosticParams {
    method public long getLogcatCollectionStartTimeMillis();
    method public boolean isLogcatCollectionEnabled();
    method public boolean isTelecomDumpSysCollectionEnabled();
    method public boolean isTelephonyDumpSysCollectionEnabled();
  }
  public static final class TelephonyManager.EmergencyCallDiagnosticParams.Builder {
    ctor public TelephonyManager.EmergencyCallDiagnosticParams.Builder();
    method @NonNull public android.telephony.TelephonyManager.EmergencyCallDiagnosticParams build();
    method @NonNull public android.telephony.TelephonyManager.EmergencyCallDiagnosticParams.Builder setLogcatCollectionStartTimeMillis(long);
    method @NonNull public android.telephony.TelephonyManager.EmergencyCallDiagnosticParams.Builder setTelecomDumpSysCollectionEnabled(boolean);
    method @NonNull public android.telephony.TelephonyManager.EmergencyCallDiagnosticParams.Builder setTelephonyDumpSysCollectionEnabled(boolean);
  }
  public static class TelephonyManager.ModemActivityInfoException extends java.lang.Exception {
    ctor public TelephonyManager.ModemActivityInfoException(int);
    method public int getErrorCode();
+71 −27
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import static com.android.internal.util.Preconditions.checkNotNull;
import android.Manifest;
import android.annotation.BytesLong;
import android.annotation.CallbackExecutor;
import android.annotation.CurrentTimeMillisLong;
import android.annotation.FlaggedApi;
import android.annotation.IntDef;
import android.annotation.LongDef;
@@ -18706,51 +18707,93 @@ public class TelephonyManager {
     * call diagnostic data
     * @hide
     */
    public static class EmergencyCallDiagnosticParams {
    @SystemApi
    @FlaggedApi(com.android.server.telecom.flags.Flags.FLAG_TELECOM_RESOLVE_HIDDEN_DEPENDENCIES)
    public static final class EmergencyCallDiagnosticParams {
        public static final class Builder {
            private boolean mCollectTelecomDumpSys;
            private boolean mCollectTelephonyDumpsys;
            // If this is set to a value other than -1L, then the logcat collection is enabled.
            // Logcat lines with this time or greater are collected how much is collected is
            // dependent on internal implementation. Time represented as milliseconds since boot.
            private long mLogcatStartTimeMillis = sUnsetLogcatStartTime;
            /**
             * Allows enabling of telecom dumpsys collection.
             * @param collectTelecomDumpsys Determines whether telecom dumpsys should be collected.
             * @return Builder instance corresponding to the configured call diagnostic params.
             */
            public @NonNull Builder setTelecomDumpSysCollectionEnabled(
                    boolean collectTelecomDumpsys) {
                mCollectTelecomDumpSys = collectTelecomDumpsys;
                return this;
            }
            /**
             * Allows enabling of telephony dumpsys collection.
             * @param collectTelephonyDumpsys Determines if telephony dumpsys should be collected.
             * @return Builder instance corresponding to the configured call diagnostic params.
             */
            public @NonNull Builder setTelephonyDumpSysCollectionEnabled(
                    boolean collectTelephonyDumpsys) {
                mCollectTelephonyDumpsys = collectTelephonyDumpsys;
                return this;
            }
            /**
             * Allows enabling of logcat (system,radio) collection.
             * @param startTimeMillis Enables logcat collection as of the indicated timestamp.
             * @return Builder instance corresponding to the configured call diagnostic params.
             */
            public @NonNull Builder setLogcatCollectionStartTimeMillis(
                    @CurrentTimeMillisLong long startTimeMillis) {
                mLogcatStartTimeMillis = startTimeMillis;
                return this;
            }
            /**
             * Build the EmergencyCallDiagnosticParams from the provided Builder config.
             * @return {@link EmergencyCallDiagnosticParams} instance from provided builder.
             */
            public @NonNull EmergencyCallDiagnosticParams build() {
                return new EmergencyCallDiagnosticParams(mCollectTelecomDumpSys,
                        mCollectTelephonyDumpsys, mLogcatStartTimeMillis);
            }
        }
        private boolean mCollectTelecomDumpSys;
        private boolean mCollectTelephonyDumpsys;
        private boolean mCollectLogcat;
        //logcat lines with this time or greater are collected
        //how much is collected is dependent on internal implementation.
        //Time represented as milliseconds since January 1, 1970 UTC
        private long mLogcatStartTimeMillis;
        private static long sUnsetLogcatStartTime = -1L;
        public boolean isTelecomDumpSysCollectionEnabled() {
            return mCollectTelecomDumpSys;
        private EmergencyCallDiagnosticParams(boolean collectTelecomDumpSys,
                boolean collectTelephonyDumpsys, long logcatStartTimeMillis) {
            mCollectTelecomDumpSys = collectTelecomDumpSys;
            mCollectTelephonyDumpsys = collectTelephonyDumpsys;
            mLogcatStartTimeMillis = logcatStartTimeMillis;
            mCollectLogcat = logcatStartTimeMillis != sUnsetLogcatStartTime;
        }
        public void setTelecomDumpSysCollection(boolean collectTelecomDumpSys) {
            mCollectTelecomDumpSys = collectTelecomDumpSys;
        public boolean isTelecomDumpSysCollectionEnabled() {
            return mCollectTelecomDumpSys;
        }
        public boolean isTelephonyDumpSysCollectionEnabled() {
            return mCollectTelephonyDumpsys;
        }
        public void setTelephonyDumpSysCollection(boolean collectTelephonyDumpsys) {
            mCollectTelephonyDumpsys = collectTelephonyDumpsys;
        }
        public boolean isLogcatCollectionEnabled() {
            return mCollectLogcat;
        }
        public long getLogcatStartTime()
        public long getLogcatCollectionStartTimeMillis()
        {
            return mLogcatStartTimeMillis;
        }
        public void setLogcatCollection(boolean collectLogcat, long startTimeMillis) {
            mCollectLogcat = collectLogcat;
            if(mCollectLogcat)
            {
                mLogcatStartTimeMillis = startTimeMillis;
            }
        }
        @Override
        public String toString() {
            return "EmergencyCallDiagnosticParams{" +
@@ -18766,11 +18809,12 @@ public class TelephonyManager {
     * Request telephony to persist state for debugging emergency call failures.
     *
     * @param dropboxTag Tag to use when persisting data to dropbox service.
     *
     * @see params Parameters controlling what is collected
     * @param params Parameters controlling what is collected.
     *
     * @hide
     */
    @SystemApi
    @FlaggedApi(com.android.server.telecom.flags.Flags.FLAG_TELECOM_RESOLVE_HIDDEN_DEPENDENCIES)
    @RequiresPermission(android.Manifest.permission.DUMP)
    public void persistEmergencyCallDiagnosticData(@NonNull String dropboxTag,
            @NonNull EmergencyCallDiagnosticParams params) {
@@ -18783,7 +18827,7 @@ public class TelephonyManager {
            if (telephony != null) {
                telephony.persistEmergencyCallDiagnosticData(dropboxTag,
                        params.isLogcatCollectionEnabled(),
                        params.getLogcatStartTime(),
                        params.getLogcatCollectionStartTimeMillis(),
                        params.isTelecomDumpSysCollectionEnabled(),
                        params.isTelephonyDumpSysCollectionEnabled());
            }