Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e3eb2bba authored by Michael W's avatar Michael W Committed by Bruno Martins
Browse files

Trust: Onboarding: Listen for locale changes

* When SuW is not yet done, the notification is already posted
* This results in an english notification text when the SuW is finished
  because the notification doesn't update when the locale changes
-> Listen for locale changes and post the notification again (= update)

Change-Id: I920a52c5c85c91adb7333a20d410a5464e80a812
parent 64fdccdf
Loading
Loading
Loading
Loading
+24 −1
Original line number Diff line number Diff line
/*
 * Copyright (c) 2018 The LineageOS Project
 * Copyright (c) 2018-2019 The LineageOS Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
@@ -21,9 +21,11 @@ import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.admin.DevicePolicyManager;
import android.content.BroadcastReceiver;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.Uri;
import android.os.Build;
import android.os.IBinder;
@@ -87,6 +89,7 @@ public class TrustInterfaceService extends LineageSystemService {
        // Onboard
        if (!hasOnboardedUser()) {
            postOnBoardingNotification();
            registerLocaleChangedReceiver();
            return;
        }

@@ -344,6 +347,26 @@ public class TrustInterfaceService extends LineageSystemService {
                LineageSettings.System.TRUST_INTERFACE_HINTED, 0) == 1;
    }

    private void registerLocaleChangedReceiver() {
        IntentFilter filter = new IntentFilter(Intent.ACTION_LOCALE_CHANGED);
        mContext.registerReceiver(mReceiver, filter);
    }

    private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            if (intent.getAction() == Intent.ACTION_LOCALE_CHANGED) {
                if (!hasOnboardedUser()) {
                    // When are not onboarded, we want to change the language of the notification
                    postOnBoardingNotification();
                } else {
                    // We don't care anymore about language changes
                    context.unregisterReceiver(this);
                }
            }
        }
    };

    /* Service */

    private final IBinder mService = new ITrustInterface.Stub() {