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

Commit 6ea063eb authored by Beverly's avatar Beverly Committed by Beverly Tai
Browse files

Translate SystemUi NotifChannels on locale change

Register receiver outside of the on boot receiver

Test: manual
Change-Id: Id286647ffe68704f928ca55dcae14dadc4fa998d
Fixes: 64887866
parent 4fca6d6b
Loading
Loading
Loading
Loading
+16 −16
Original line number Diff line number Diff line
@@ -69,8 +69,8 @@ public class SystemUIApplication extends Application implements SysUiServiceProv
        SystemUIFactory.createFromConfig(this);

        if (Process.myUserHandle().equals(UserHandle.SYSTEM)) {
            IntentFilter filter = new IntentFilter(Intent.ACTION_BOOT_COMPLETED);
            filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
            IntentFilter bootCompletedFilter = new IntentFilter(Intent.ACTION_BOOT_COMPLETED);
            bootCompletedFilter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
            registerReceiver(new BroadcastReceiver() {
                @Override
                public void onReceive(Context context, Intent intent) {
@@ -86,11 +86,21 @@ public class SystemUIApplication extends Application implements SysUiServiceProv
                        }
                    }

                    IntentFilter localeChangedFilter = new IntentFilter(
                            Intent.ACTION_LOCALE_CHANGED);
                    registerReceiver(mLocaleChangeReceiver, localeChangedFilter);

                }
            }, bootCompletedFilter);

            IntentFilter localeChangedFilter = new IntentFilter(Intent.ACTION_LOCALE_CHANGED);
            registerReceiver(new BroadcastReceiver() {
                @Override
                public void onReceive(Context context, Intent intent) {
                    if (Intent.ACTION_LOCALE_CHANGED.equals(intent.getAction())) {
                        if (!mBootCompleted) return;
                        // Update names of SystemUi notification channels
                        NotificationChannels.createAll(context);
                    }
            }, filter);
                }
            }, localeChangedFilter);
        } else {
            // We don't need to startServices for sub-process that is doing some tasks.
            // (screenshots, sweetsweetdesserts or tuner ..)
@@ -239,14 +249,4 @@ public class SystemUIApplication extends Application implements SysUiServiceProv
    public SystemUI[] getServices() {
        return mServices;
    }

    private final BroadcastReceiver mLocaleChangeReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            if (Intent.ACTION_LOCALE_CHANGED.equals(intent.getAction())) {
                // Update names of SystemUi notification channels
                NotificationChannels.createAll(context);
            }
        }
    };
}