MOBILE-4214 settings: Display whether device supports encrypted push

main
Dani Palou 2023-05-29 08:42:36 +02:00
parent c2e65a8917
commit c9355e221f
5 changed files with 30 additions and 2 deletions

View File

@ -2349,6 +2349,7 @@
"core.settings.enablefirebaseanalyticsdescription": "local_moodlemobileapp",
"core.settings.enablerichtexteditor": "local_moodlemobileapp",
"core.settings.enablerichtexteditordescription": "local_moodlemobileapp",
"core.settings.encryptedpushsupported": "local_moodlemobileapp",
"core.settings.entriesincache": "local_moodlemobileapp",
"core.settings.estimatedfreespace": "local_moodlemobileapp",
"core.settings.filesystemroot": "local_moodlemobileapp",

View File

@ -726,7 +726,7 @@ export class CorePushNotificationsProvider {
try {
const data = this.getRequiredRegisterData();
data.publickey = await this.getPublicKey(site);
data.publickey = await this.getPublicKeyForSite(site);
const neededActions = await this.getRegisterDeviceActions(data, site, forceUnregister);
@ -780,11 +780,24 @@ export class CorePushNotificationsProvider {
* @param site Site to register
* @returns Public key, undefined if the site or the device doesn't support encryption.
*/
protected async getPublicKey(site: CoreSite): Promise<string | undefined> {
protected async getPublicKeyForSite(site: CoreSite): Promise<string | undefined> {
if (!site.wsAvailable('core_user_update_user_device_public_key')) {
return;
}
return await this.getPublicKey();
}
/**
* Get the device public key.
*
* @returns Public key, undefined if the device doesn't support encryption.
*/
async getPublicKey(): Promise<string | undefined> {
if (!CorePlatform.isMobile()) {
return;
}
const publicKey = await Push.getPublicKey();
return publicKey ?? undefined;

View File

@ -37,6 +37,7 @@
"enablefirebaseanalyticsdescription": "If enabled, the app will collect anonymous data usage.",
"enablerichtexteditor": "Enable text editor",
"enablerichtexteditordescription": "If enabled, a text editor will be available when entering content.",
"encryptedpushsupported": "Encrypted push notifications supported",
"entriesincache": "{{$a}} entries in cache",
"estimatedfreespace": "Estimated free space",
"filesystemroot": "File system root",

View File

@ -148,6 +148,13 @@
<p>{{ deviceInfo.pushId }}</p>
</ion-label>
</ion-item>
<ion-item *ngIf="deviceInfo.pushId" (longPress)="copyItemInfo($event)">
<ion-label class="ion-text-wrap">
<p class="item-heading">{{ 'core.settings.encryptedpushsupported' | translate }}</p>
<p *ngIf="!deviceInfo.encryptedPushSupported">{{ 'core.no' | translate }}</p>
<p *ngIf="deviceInfo.encryptedPushSupported">{{ 'core.yes' | translate }}</p>
</ion-label>
</ion-item>
<ion-item (longPress)="copyItemInfo($event)">
<ion-label class="ion-text-wrap">
<p class="item-heading">{{ 'core.settings.localnotifavailable' | translate }}</p>

View File

@ -58,6 +58,7 @@ interface CoreSettingsDeviceInfo {
uuid?: string;
pushId?: string;
localNotifAvailable: string;
encryptedPushSupported?: boolean;
}
/**
@ -210,6 +211,11 @@ export class CoreSettingsDeviceInfoPage implements OnDestroy {
const showDevOptionsOnConfig = await CoreConfig.get('showDevOptions', 0);
this.devOptionsForced = CoreConstants.BUILD.isDevelopment || CoreConstants.BUILD.isTesting;
this.showDevOptions = this.devOptionsForced || showDevOptionsOnConfig == 1;
const publicKey = this.deviceInfo.pushId ?
await CoreUtils.ignoreErrors(CorePushNotifications.getPublicKey()) :
undefined;
this.deviceInfo.encryptedPushSupported = publicKey !== undefined;
}
/**