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
This commit is contained in:
Michael W
2019-02-24 21:34:10 +01:00
parent f3b2904187
commit 9a2567bf78

View File

@@ -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;
@@ -98,6 +100,7 @@ public class TrustInterfaceService extends LineageSystemService {
// Onboard
if (!hasOnboardedUser()) {
postOnBoardingNotification();
registerLocaleChangedReceiver();
return;
}
@@ -354,6 +357,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() {