Fix SSE event bug and make the assertion guarded by a separate flag.
This commit is contained in:
parent
76de183ec2
commit
eb6394eb6a
4 changed files with 26 additions and 4 deletions
|
@ -502,6 +502,18 @@ class RecipientTableTest_getAndPossiblyMerge {
|
|||
expectNoSessionSwitchoverEvent()
|
||||
}
|
||||
|
||||
test("steal, e164+pni+aci * pni+aci, all provided, aci sessions but not pni sessions, no SSE expected") {
|
||||
given(E164_A, PNI_A, ACI_A, createThread = true, aciSession = true, pniSession = false)
|
||||
given(null, PNI_B, ACI_B, createThread = false, aciSession = true, pniSession = false)
|
||||
|
||||
process(E164_A, PNI_B, ACI_A)
|
||||
|
||||
expect(E164_A, PNI_B, ACI_A)
|
||||
expect(null, null, ACI_B)
|
||||
|
||||
expectNoSessionSwitchoverEvent()
|
||||
}
|
||||
|
||||
test("merge, e164 & pni & aci, all provided") {
|
||||
given(E164_A, null, null)
|
||||
given(null, PNI_A, null)
|
||||
|
|
|
@ -1293,7 +1293,7 @@ open class MessageTable(context: Context?, databaseHelper: SignalDatabase) : Dat
|
|||
}
|
||||
|
||||
fun insertSessionSwitchoverEvent(recipientId: RecipientId, threadId: Long, event: SessionSwitchoverEvent) {
|
||||
check(FeatureFlags.phoneNumberPrivacy()) { "Should not occur in a non-PNP world!" }
|
||||
check(!FeatureFlags.blockSessionSwitchoverEvents()) { "Should not occur in a non-PNP world!" }
|
||||
writableDatabase
|
||||
.insertInto(TABLE_NAME)
|
||||
.values(
|
||||
|
|
|
@ -2650,7 +2650,7 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
|
|||
* records and turning it into a possible event.
|
||||
*/
|
||||
private fun sessionSwitchoverEventIfNeeded(pniVerified: Boolean, oldRecord: RecipientRecord?, newRecord: RecipientRecord?): PnpOperation? {
|
||||
return if (oldRecord != null && newRecord != null && needsSessionSwitchoverEvent(pniVerified, oldRecord.serviceId, newRecord.serviceId)) {
|
||||
return if (oldRecord != null && newRecord != null && oldRecord.serviceId == oldRecord.pni && newRecord.serviceId == newRecord.aci && needsSessionSwitchoverEvent(pniVerified, oldRecord.serviceId, newRecord.serviceId)) {
|
||||
PnpOperation.SessionSwitchoverInsert(
|
||||
recipientId = newRecord.id,
|
||||
e164 = newRecord.e164
|
||||
|
|
|
@ -86,6 +86,7 @@ public final class FeatureFlags {
|
|||
private static final String USE_AEC3 = "android.calling.useAec3";
|
||||
private static final String PAYMENTS_COUNTRY_BLOCKLIST = "global.payments.disabledRegions";
|
||||
public static final String PHONE_NUMBER_PRIVACY = "android.pnp";
|
||||
public static final String BLOCK_SSE = "android.blockSessionSwitchoverEvents";
|
||||
private static final String STORIES_AUTO_DOWNLOAD_MAXIMUM = "android.stories.autoDownloadMaximum";
|
||||
private static final String TELECOM_MANUFACTURER_ALLOWLIST = "android.calling.telecomAllowList";
|
||||
private static final String TELECOM_MODEL_BLOCKLIST = "android.calling.telecomModelBlockList";
|
||||
|
@ -183,7 +184,8 @@ public final class FeatureFlags {
|
|||
USERNAMES,
|
||||
INSTANT_VIDEO_PLAYBACK,
|
||||
CONVERSATION_ITEM_V2_TEXT,
|
||||
CRASH_PROMPT_CONFIG
|
||||
CRASH_PROMPT_CONFIG,
|
||||
BLOCK_SSE
|
||||
);
|
||||
|
||||
@VisibleForTesting
|
||||
|
@ -255,7 +257,8 @@ public final class FeatureFlags {
|
|||
PROMPT_FOR_NOTIFICATION_CONFIG,
|
||||
PROMPT_BATTERY_SAVER,
|
||||
USERNAMES,
|
||||
CRASH_PROMPT_CONFIG
|
||||
CRASH_PROMPT_CONFIG,
|
||||
BLOCK_SSE
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -388,6 +391,13 @@ public final class FeatureFlags {
|
|||
return getBoolean(PHONE_NUMBER_PRIVACY, false) || Environment.IS_PNP;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether session switchover events should be blocked on the client.
|
||||
*/
|
||||
public static boolean blockSessionSwitchoverEvents() {
|
||||
return getBoolean(BLOCK_SSE, false) && !phoneNumberPrivacy();
|
||||
}
|
||||
|
||||
/** Whether to use the custom streaming muxer or built in android muxer. */
|
||||
public static boolean useStreamingVideoMuxer() {
|
||||
return getBoolean(CUSTOM_VIDEO_MUXER, false);
|
||||
|
|
Loading…
Add table
Reference in a new issue