-
Notifications
You must be signed in to change notification settings - Fork 1.4k
feat(voip): call waiting, busy detection, and videoconf blocking #7077
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 14 commits
5dae4b5
d324a86
266922e
bd7158c
309cbba
328b646
8fc00f5
f30a57a
12c6cac
5ae590d
beb9a7c
385991d
4a0e2f7
36ed84f
9e71e6c
c7e4f74
72ab82e
408cced
5828949
ab85a8f
d7bffcd
6bebf15
db0bb36
3bc1473
126715d
f279495
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| import { PermissionsAndroid } from 'react-native'; | ||
|
|
||
| describe('requestPhoneStatePermission', () => { | ||
| afterEach(() => { | ||
| jest.restoreAllMocks(); | ||
| }); | ||
|
|
||
| it('does not call PermissionsAndroid.request when not on Android', () => { | ||
| jest.resetModules(); | ||
| jest.doMock('./helpers', () => ({ | ||
| ...jest.requireActual<typeof import('./helpers')>('./helpers'), | ||
|
Check failure on line 11 in app/lib/methods/voipPhoneStatePermission.test.ts
|
||
| isAndroid: false | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| })); | ||
| const spy = jest.spyOn(PermissionsAndroid, 'request').mockResolvedValue('granted' as never); | ||
| const { requestPhoneStatePermission } = require('./voipPhoneStatePermission'); | ||
|
|
||
| requestPhoneStatePermission(); | ||
|
|
||
| expect(spy).not.toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| it('requests READ_PHONE_STATE on Android with i18n rationale keys', () => { | ||
| jest.resetModules(); | ||
| jest.doMock('../../i18n', () => ({ | ||
| __esModule: true, | ||
| default: { t: (key: string) => key } | ||
| })); | ||
| jest.doMock('./helpers', () => ({ | ||
| ...jest.requireActual<typeof import('./helpers')>('./helpers'), | ||
|
Check failure on line 29 in app/lib/methods/voipPhoneStatePermission.test.ts
|
||
| isAndroid: true | ||
| })); | ||
| const spy = jest.spyOn(PermissionsAndroid, 'request').mockResolvedValue('granted' as never); | ||
| const { requestPhoneStatePermission } = require('./voipPhoneStatePermission'); | ||
|
|
||
| requestPhoneStatePermission(); | ||
|
|
||
| expect(spy).toHaveBeenCalledWith(PermissionsAndroid.PERMISSIONS.READ_PHONE_STATE, { | ||
| buttonPositive: 'Ok', | ||
| message: 'Phone_state_permission_message', | ||
| title: 'Phone_state_permission_title' | ||
| }); | ||
| }); | ||
|
|
||
| it('does not prompt again in the same session on Android', () => { | ||
| jest.resetModules(); | ||
| jest.doMock('../../i18n', () => ({ | ||
| __esModule: true, | ||
| default: { t: (key: string) => key } | ||
| })); | ||
| jest.doMock('./helpers', () => ({ | ||
| ...jest.requireActual<typeof import('./helpers')>('./helpers'), | ||
|
Check failure on line 51 in app/lib/methods/voipPhoneStatePermission.test.ts
|
||
| isAndroid: true | ||
| })); | ||
| const spy = jest.spyOn(PermissionsAndroid, 'request').mockResolvedValue('granted' as never); | ||
| const { requestPhoneStatePermission } = require('./voipPhoneStatePermission'); | ||
|
|
||
| requestPhoneStatePermission(); | ||
| requestPhoneStatePermission(); | ||
|
|
||
| expect(spy).toHaveBeenCalledTimes(1); | ||
| }); | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import { PermissionsAndroid } from 'react-native'; | ||
|
|
||
| import i18n from '../../i18n'; | ||
| import { isAndroid } from './helpers'; | ||
|
|
||
| let askedThisSession = false; | ||
|
|
||
| export const requestPhoneStatePermission = (): void => { | ||
| if (!isAndroid) { | ||
| return; | ||
| } | ||
| if (askedThisSession) { | ||
| return; | ||
| } | ||
| askedThisSession = true; | ||
|
|
||
| PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.READ_PHONE_STATE, { | ||
| buttonPositive: 'Ok', | ||
| message: i18n.t('Phone_state_permission_message'), | ||
| title: i18n.t('Phone_state_permission_title') | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| }); | ||
| }; | ||
Uh oh!
There was an error while loading. Please reload this page.