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

Commit c5aaf45b authored by Lucas Dupin's avatar Lucas Dupin
Browse files

Restricting UiModeManager#setNightMode

Apps have been trying to set their night modes by calling this
function but they end up toggling the system-wide UiMode.

From now on, an error message will be logged if the app doesn't
hold the right permission.

Change-Id: Ie62c870b84190a62321a05a007cd2bf3dc9851f8
Fixes: 113605757
Test: manual. open app that tries to trigger night mode
parent d5180a5e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -913,7 +913,7 @@
    <!--  Control whether to lock day/night mode change from normal application. When it is
          true, day / night mode change is only allowed to apps with MODIFY_DAY_NIGHT_MODE
          permission. -->
    <bool name="config_lockDayNightMode">false</bool>
    <bool name="config_lockDayNightMode">true</bool>

    <!-- Control the default night mode to use when there is no other mode override set.
         One of the following values (see UiModeManager.java):
+2 −3
Original line number Diff line number Diff line
@@ -306,8 +306,7 @@ final class UiModeManagerService extends SystemService {
            if (isNightModeLocked() && (getContext().checkCallingOrSelfPermission(
                    android.Manifest.permission.MODIFY_DAY_NIGHT_MODE)
                    != PackageManager.PERMISSION_GRANTED)) {
                Slog.e(TAG,
                        "Night mode locked, requires MODIFY_DAY_NIGHT_MODE permission");
                Slog.e(TAG, "Night mode locked, requires MODIFY_DAY_NIGHT_MODE permission");
                return;
            }
            switch (mode) {