From c8a729f8be441169fdd1f69ae173562b11d18cb1 Mon Sep 17 00:00:00 2001 From: Miriam Zimmerman Date: Wed, 2 Oct 2024 14:45:10 -0400 Subject: [PATCH] Plumb through new ADM setting. Co-authored-by: ayumi-signal --- ts/RemoteConfig.ts | 1 + ts/services/calling.ts | 2 ++ ts/types/Storage.d.ts | 1 + ts/util/ringrtc/ringrtcAdm.ts | 31 +++++++++++++++++++++++++++++++ ts/windows/main/start.ts | 12 ++++++++++++ 5 files changed, 47 insertions(+) create mode 100644 ts/util/ringrtc/ringrtcAdm.ts diff --git a/ts/RemoteConfig.ts b/ts/RemoteConfig.ts index 3b4367d8c2cc..8167c2b27c0a 100644 --- a/ts/RemoteConfig.ts +++ b/ts/RemoteConfig.ts @@ -18,6 +18,7 @@ export type ConfigKeyType = | 'desktop.calling.adhoc' | 'desktop.calling.adhoc.create' | 'desktop.calling.raiseHand' + | 'desktop.calling.ringrtcAdm' | 'desktop.clientExpiration' | 'desktop.backup.credentialFetch' | 'desktop.internalUser' diff --git a/ts/services/calling.ts b/ts/services/calling.ts index 32941f1007b5..f9f54893e6b8 100644 --- a/ts/services/calling.ts +++ b/ts/services/calling.ts @@ -155,6 +155,7 @@ import { getConversationIdForLogging } from '../util/idForLogging'; import { sendCallLinkUpdateSync } from '../util/sendCallLinkUpdateSync'; import { createIdenticon } from '../util/createIdenticon'; import { getColorForCallLink } from '../util/getColorForCallLink'; +import { getUseRingrtcAdm } from '../util/ringrtc/ringrtcAdm'; const { wasGroupCallRingPreviouslyCanceled } = DataReader; const { @@ -378,6 +379,7 @@ export class CallingClass { RingRTC.setConfig({ field_trials: undefined, + use_ringrtc_adm: getUseRingrtcAdm(), }); RingRTC.handleOutgoingSignaling = this.handleOutgoingSignaling.bind(this); diff --git a/ts/types/Storage.d.ts b/ts/types/Storage.d.ts index b175d176d020..6dceb815cf99 100644 --- a/ts/types/Storage.d.ts +++ b/ts/types/Storage.d.ts @@ -110,6 +110,7 @@ export type StorageAccessType = { synced_at: number; userAgent: string; uuid_id: string; + useRingrtcAdm: boolean; pni: string; version: string; linkPreviews: boolean; diff --git a/ts/util/ringrtc/ringrtcAdm.ts b/ts/util/ringrtc/ringrtcAdm.ts new file mode 100644 index 000000000000..67e279270a6f --- /dev/null +++ b/ts/util/ringrtc/ringrtcAdm.ts @@ -0,0 +1,31 @@ +// Copyright 2024 Signal Messenger, LLC +// SPDX-License-Identifier: AGPL-3.0-only + +import * as RemoteConfig from '../../RemoteConfig'; +import OS from '../os/osMain'; +import { isProduction } from '../version'; + +export function getUseRingrtcAdm(): boolean { + const localUseRingrtcAdm = window.storage.get('useRingrtcAdm'); + if (localUseRingrtcAdm !== undefined) { + return localUseRingrtcAdm; + } + + if ( + isProduction(window.getVersion()) || + OS.isLinux() || + !RemoteConfig.isEnabled('desktop.internalUser') + ) { + return false; + } + + return RemoteConfig.isEnabled('desktop.calling.ringrtcAdm'); +} + +export async function setUseRingrtcAdm(value: boolean): Promise { + await window.storage.put('useRingrtcAdm', value); +} + +export async function removeUseRingrtcAdm(): Promise { + await window.storage.remove('useRingrtcAdm'); +} diff --git a/ts/windows/main/start.ts b/ts/windows/main/start.ts index f8cca7d5ad5a..3229f0aff892 100644 --- a/ts/windows/main/start.ts +++ b/ts/windows/main/start.ts @@ -24,6 +24,10 @@ import { initMessageCleanup } from '../../services/messageStateCleanup'; import { Environment, getEnvironment } from '../../environment'; import { isProduction } from '../../util/version'; import { benchmarkConversationOpen } from '../../CI/benchmarkConversationOpen'; +import { + removeUseRingrtcAdm, + setUseRingrtcAdm, +} from '../../util/ringrtc/ringrtcAdm'; window.addEventListener('contextmenu', e => { const node = e.target as Element | null; @@ -74,6 +78,10 @@ if ( name: K, value: StorageAccessType[K] ) => window.storage.put(name, value), + removeUseRingrtcAdm: async () => { + await removeUseRingrtcAdm(); + log.info('Restart to make ADM change take effect!'); + }, setFlag: (name: keyof FeatureFlagType, value: boolean) => { if (!has(window.Flags, name)) { return; @@ -83,6 +91,10 @@ if ( setSfuUrl: (url: string) => { window.Signal.Services.calling._sfuUrl = url; }, + setUseRingrtcAdm: async (value: boolean) => { + await setUseRingrtcAdm(value); + log.info('Restart to make ADM change take effect!'); + }, setIceServerOverride: ( override: GetIceServersResultType | string | undefined ) => {