Prevent dark mode from activating during battery saver
According to the source code file

frameworks/base/core/java/android/provider/Settings.java

there is a global setting in the user profile called battery_saver_constants, which can hold several comma separated parameters. These parameters are applied when battery saver is on. Here's the list:
/**
 * Battery Saver specific settings
 * This is encoded as a key=value list, separated by commas. Ex:
 *
 * &quot;vibration_disabled=true,adjust_brightness_factor=0.5&quot;
 *
 * The following keys are supported:
 *
 * &lt;pre&gt;
 * advertise_is_enabled              (boolean)
 * datasaver_disabled                (boolean)
 * enable_night_mode                 (boolean)
 * launch_boost_disabled             (boolean)
 * vibration_disabled                (boolean)
 * animation_disabled                (boolean)
 * soundtrigger_disabled             (boolean)
 * fullbackup_deferred               (boolean)
 * keyvaluebackup_deferred           (boolean)
 * firewall_disabled                 (boolean)
 * gps_mode                          (int)
 * adjust_brightness_disabled        (boolean)
 * adjust_brightness_factor          (float)
 * force_all_apps_standby            (boolean)
 * force_background_check            (boolean)
 * optional_sensors_disabled         (boolean)
 * aod_disabled                      (boolean)
 * quick_doze_enabled                (boolean)
 * &lt;/pre&gt;
 * @hide
 * @see com.android.server.power.batterysaver.BatterySaverPolicy
 */

On recent Android's, the global settings configuration file has XML format and is located here

/data/system/users/0/settings_global.xml

So you can add this new parameter called battery_saver_constants with its value enable_night_mode=false like this:
&lt;setting id=&quot;9999&quot; name=&quot;battery_saver_constants&quot; value=&quot;enable_night_mode=false&quot; defaultValue=&quot;enable_night_mode=false&quot; package=&quot;android&quot; defaultSysSet=&quot;true&quot; /&gt;

Notice the id parameter, it can be any number but should be unique in this configuration file.
P.S. You need root to edit this file.