Loading src/java/com/android/internal/telephony/imsphone/ImsPhoneCallTracker.java +57 −5 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import static com.android.internal.annotations.VisibleForTesting.Visibility.PRIV import static com.android.internal.telephony.Phone.CS_FALLBACK; import android.annotation.NonNull; import android.annotation.Nullable; import android.app.usage.NetworkStatsManager; import android.compat.annotation.UnsupportedAppUsage; import android.content.BroadcastReceiver; Loading Loading @@ -925,8 +926,10 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall { * {@code ImsReasonInfo#CODE_*} value. * * See {@link CarrierConfigManager#KEY_IMS_REASONINFO_MAPPING_STRING_ARRAY}. * This ImsReasonInfoKeyPair with this key stating will consider getExtraMessage a match * if the carrier config messages starts with getExtraMessage result. */ private Map<Pair<Integer, String>, Integer> mImsReasonCodeMap = new ArrayMap<>(); private Map<ImsReasonInfoKeyPair, Integer> mImsReasonCodeMap = new ArrayMap<>(); /** Loading Loading @@ -985,6 +988,54 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall { // Used for important operational related events for logging. private final LocalLog mOperationLocalLog = new LocalLog(64); /** * Container to ease passing around a tuple of two objects. This object provides a sensible * implementation of equals(), returning true/false using equals() for one object (Integer) * and startsWith() for another object (String). Also the startsWith() in this equals() method * will return true for A.startsWith(B) if B.second starts with A.second. */ private static class ImsReasonInfoKeyPair extends Pair<Integer, String> { /** * Constructor for a ImsReasonInfoKeyPair. * * @param first Integer in the ImsReasonInfoKeyPair * @param second String in the ImsReasonInfoKeyPair */ private ImsReasonInfoKeyPair(Integer first, String second) { super(first, second); } /** * Checks the two objects for equality by delegating to their respective * {@link Object#equals(Object)} methods. * * @param o the {@link com.android.internal.telephony.imsphone.ImsReasonInfoKeyPair} to * which this one is to be checked for equality * @return true if the underlying objects of the ImsReasonInfoKeyPair are * considered equal and startsWith */ @Override public boolean equals(@Nullable Object o) { if (!(o instanceof ImsReasonInfoKeyPair)) { return false; } ImsReasonInfoKeyPair p = (ImsReasonInfoKeyPair) o; return Objects.equals(p.first, first) && Objects.toString(second).startsWith(Objects.toString(p.second)); } /** * Compute a hash code using the hash code of the Integer key * * @return a hashcode of the first */ @Override public int hashCode() { return (first == null ? 0 : first.hashCode()); } } //***** Events Loading Loading @@ -2829,7 +2880,7 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall { if (message != null) { message = message.toLowerCase(); } mImsReasonCodeMap.put(new Pair<>(fromCode, message), toCode); mImsReasonCodeMap.put(new ImsReasonInfoKeyPair(fromCode, message), toCode); } /** Loading @@ -2852,9 +2903,10 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall { } log("maybeRemapReasonCode : fromCode = " + reasonInfo.getCode() + " ; message = " + reason); Pair<Integer, String> toCheck = new Pair<>(code, reason); Pair<Integer, String> wildcardToCheck = new Pair<>(null, reason); Pair<Integer, String> wildcardMessageToCheck = new Pair<>(code, null); ImsReasonInfoKeyPair toCheck = new ImsReasonInfoKeyPair(code, reason); ImsReasonInfoKeyPair wildcardToCheck = new ImsReasonInfoKeyPair(null, reason); ImsReasonInfoKeyPair wildcardMessageToCheck = new ImsReasonInfoKeyPair(code, null); if (mImsReasonCodeMap.containsKey(toCheck)) { int toCode = mImsReasonCodeMap.get(toCheck); Loading tests/telephonytests/src/com/android/internal/telephony/imsphone/ImsPhoneCallTrackerTest.java +5 −0 Original line number Diff line number Diff line Loading @@ -1006,7 +1006,9 @@ public class ImsPhoneCallTrackerTest extends TelephonyTest { PersistableBundle bundle = new PersistableBundle(); String[] mappings = new String[]{ "1014|call completed elsewhere|1014", "1014|Call Rejected By User|510", "1014|*|510", "510|Call completed elsewhere|1014", }; bundle.putStringArray(CarrierConfigManager.KEY_IMS_REASONINFO_MAPPING_STRING_ARRAY, mappings); Loading @@ -1024,6 +1026,9 @@ public class ImsPhoneCallTrackerTest extends TelephonyTest { new ImsReasonInfo(1014, 200, "Call Rejected By User"))); // 1014 -> 510 assertEquals(ImsReasonInfo.CODE_ANSWERED_ELSEWHERE, mCTUT.maybeRemapReasonCode( new ImsReasonInfo(1014, 200, "Call completed elsewhere"))); // 1014 -> 1014 assertEquals(ImsReasonInfo.CODE_ANSWERED_ELSEWHERE, mCTUT.maybeRemapReasonCode( new ImsReasonInfo(510, 200, "Call completed elsewhere by instance urn:gsma:imei:xxx"))); // 510 -> 1014 // Simulate that after SIM swap the new carrier config doesn't have the mapping for 1014 loadReasonCodeRemapCarrierConfig(); Loading Loading
src/java/com/android/internal/telephony/imsphone/ImsPhoneCallTracker.java +57 −5 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import static com.android.internal.annotations.VisibleForTesting.Visibility.PRIV import static com.android.internal.telephony.Phone.CS_FALLBACK; import android.annotation.NonNull; import android.annotation.Nullable; import android.app.usage.NetworkStatsManager; import android.compat.annotation.UnsupportedAppUsage; import android.content.BroadcastReceiver; Loading Loading @@ -925,8 +926,10 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall { * {@code ImsReasonInfo#CODE_*} value. * * See {@link CarrierConfigManager#KEY_IMS_REASONINFO_MAPPING_STRING_ARRAY}. * This ImsReasonInfoKeyPair with this key stating will consider getExtraMessage a match * if the carrier config messages starts with getExtraMessage result. */ private Map<Pair<Integer, String>, Integer> mImsReasonCodeMap = new ArrayMap<>(); private Map<ImsReasonInfoKeyPair, Integer> mImsReasonCodeMap = new ArrayMap<>(); /** Loading Loading @@ -985,6 +988,54 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall { // Used for important operational related events for logging. private final LocalLog mOperationLocalLog = new LocalLog(64); /** * Container to ease passing around a tuple of two objects. This object provides a sensible * implementation of equals(), returning true/false using equals() for one object (Integer) * and startsWith() for another object (String). Also the startsWith() in this equals() method * will return true for A.startsWith(B) if B.second starts with A.second. */ private static class ImsReasonInfoKeyPair extends Pair<Integer, String> { /** * Constructor for a ImsReasonInfoKeyPair. * * @param first Integer in the ImsReasonInfoKeyPair * @param second String in the ImsReasonInfoKeyPair */ private ImsReasonInfoKeyPair(Integer first, String second) { super(first, second); } /** * Checks the two objects for equality by delegating to their respective * {@link Object#equals(Object)} methods. * * @param o the {@link com.android.internal.telephony.imsphone.ImsReasonInfoKeyPair} to * which this one is to be checked for equality * @return true if the underlying objects of the ImsReasonInfoKeyPair are * considered equal and startsWith */ @Override public boolean equals(@Nullable Object o) { if (!(o instanceof ImsReasonInfoKeyPair)) { return false; } ImsReasonInfoKeyPair p = (ImsReasonInfoKeyPair) o; return Objects.equals(p.first, first) && Objects.toString(second).startsWith(Objects.toString(p.second)); } /** * Compute a hash code using the hash code of the Integer key * * @return a hashcode of the first */ @Override public int hashCode() { return (first == null ? 0 : first.hashCode()); } } //***** Events Loading Loading @@ -2829,7 +2880,7 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall { if (message != null) { message = message.toLowerCase(); } mImsReasonCodeMap.put(new Pair<>(fromCode, message), toCode); mImsReasonCodeMap.put(new ImsReasonInfoKeyPair(fromCode, message), toCode); } /** Loading @@ -2852,9 +2903,10 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall { } log("maybeRemapReasonCode : fromCode = " + reasonInfo.getCode() + " ; message = " + reason); Pair<Integer, String> toCheck = new Pair<>(code, reason); Pair<Integer, String> wildcardToCheck = new Pair<>(null, reason); Pair<Integer, String> wildcardMessageToCheck = new Pair<>(code, null); ImsReasonInfoKeyPair toCheck = new ImsReasonInfoKeyPair(code, reason); ImsReasonInfoKeyPair wildcardToCheck = new ImsReasonInfoKeyPair(null, reason); ImsReasonInfoKeyPair wildcardMessageToCheck = new ImsReasonInfoKeyPair(code, null); if (mImsReasonCodeMap.containsKey(toCheck)) { int toCode = mImsReasonCodeMap.get(toCheck); Loading
tests/telephonytests/src/com/android/internal/telephony/imsphone/ImsPhoneCallTrackerTest.java +5 −0 Original line number Diff line number Diff line Loading @@ -1006,7 +1006,9 @@ public class ImsPhoneCallTrackerTest extends TelephonyTest { PersistableBundle bundle = new PersistableBundle(); String[] mappings = new String[]{ "1014|call completed elsewhere|1014", "1014|Call Rejected By User|510", "1014|*|510", "510|Call completed elsewhere|1014", }; bundle.putStringArray(CarrierConfigManager.KEY_IMS_REASONINFO_MAPPING_STRING_ARRAY, mappings); Loading @@ -1024,6 +1026,9 @@ public class ImsPhoneCallTrackerTest extends TelephonyTest { new ImsReasonInfo(1014, 200, "Call Rejected By User"))); // 1014 -> 510 assertEquals(ImsReasonInfo.CODE_ANSWERED_ELSEWHERE, mCTUT.maybeRemapReasonCode( new ImsReasonInfo(1014, 200, "Call completed elsewhere"))); // 1014 -> 1014 assertEquals(ImsReasonInfo.CODE_ANSWERED_ELSEWHERE, mCTUT.maybeRemapReasonCode( new ImsReasonInfo(510, 200, "Call completed elsewhere by instance urn:gsma:imei:xxx"))); // 510 -> 1014 // Simulate that after SIM swap the new carrier config doesn't have the mapping for 1014 loadReasonCodeRemapCarrierConfig(); Loading