Include DisconnectCause Builder
As part of telecom mainline prep, the previously hidden DisconnectCause
constructor (which includes the Telephony debug info) was promoted to a
system API. From API feedback, a request was put forward to add a
Builder to consolidate the construction of the DisconnectCause instance.
This CL adds the Builder and reverts the previous changes to make the
constructor an API. Instead, the Telephony reference has been resolved
to use the builder pattern instead. The other constructors have been
untouched sincce there are many references within Telecom, which would
make the changes unnecessarily noisy. Those can be cleaned up for a
separate refactor but they shouldn't block mainline prep work.
Bug: 324414185
Bug: 311773409
Test: atest TelecomUnitTests, atest DataObjectUnitTests
Change-Id: I3fc8bac4c55a22ccddc93f6ba2c33488221b4470
diff --git a/tests/tests/telecom/src/android/telecom/cts/DataObjectUnitTests.java b/tests/tests/telecom/src/android/telecom/cts/DataObjectUnitTests.java
index e84e73e..fc4b4ed 100644
--- a/tests/tests/telecom/src/android/telecom/cts/DataObjectUnitTests.java
+++ b/tests/tests/telecom/src/android/telecom/cts/DataObjectUnitTests.java
@@ -214,15 +214,16 @@
final CharSequence description = "Mobile network not available";
final String reason = "CTS Testing";
ImsReasonInfo reasonInfo = new ImsReasonInfo(ImsReasonInfo.CODE_UNSPECIFIED, 0, "");
- DisconnectCause cause = new DisconnectCause(
- DisconnectCause.ERROR,
- label,
- description,
- reason,
- ToneGenerator.TONE_CDMA_CALLDROP_LITE,
- android.telephony.DisconnectCause.NORMAL,
- PreciseDisconnectCause.NORMAL,
- reasonInfo);
+ DisconnectCause cause = new DisconnectCause.Builder()
+ .setCode(DisconnectCause.ERROR)
+ .setLabel(label)
+ .setDescription(description)
+ .setReason(reason)
+ .setTone(ToneGenerator.TONE_CDMA_CALLDROP_LITE)
+ .setTelephonyDisconnectCause(android.telephony.DisconnectCause.NORMAL)
+ .setTelephonyPreciseDisconnectCause(PreciseDisconnectCause.NORMAL)
+ .setImsReasonInfo(reasonInfo)
+ .build();
assertEquals(DisconnectCause.ERROR, cause.getCode());
assertEquals(label, cause.getLabel());
assertEquals(description, cause.getDescription());