title: How to set default settings in android overlay (captive portal mode)
body: <p>I am working an aosp project. For this project, I want to set the captive portal check off by default in the aosp build. I figured and tested that I can set the setting via:</p>
  
  <pre><code>settings put global captive_portal_detection_enabled 0 
  </code></pre>
  
  <p>see also <a href="https://www.kuketz-blog.de/android-captive-portal-check-aenderung/" rel="nofollow noreferrer">https://www.kuketz-blog.de/android-captive-portal-check-aenderung/</a></p>
  
  <p>So usually I will set this by using the overlay mechanism for the resources in the device, for example in overlay/frameworks/base/core/packages/settingsprovider/res/value:</p>
  
  <pre><code>&lt;resources&gt;
      &lt;!-- disable lockscreen by default to avoid showing of user switcher --&gt;
      &lt;bool name="def_lockscreen_disabled"&gt;true&lt;/bool&gt;
  &lt;/resources&gt;
  </code></pre>
  
  <p>I figured, that the default value for the captive portal is in the aosp ConnectivityService defined like</p>
  
  <pre><code>        private int getCaptivePortalMode() {
              return Settings.Global.getInt(mContext.getContentResolver(),
                      Settings.Global.CAPTIVE_PORTAL_MODE,
                      Settings.Global.CAPTIVE_PORTAL_MODE_PROMPT);
          }
  </code></pre>
  
  <p>I tried several ways to override it but prepending config_ or _def does not work, adding the entry by</p>
  
  <pre><code>&lt;resources&gt;
  &lt;!-- disable captive portal checking --&gt;
      &lt;add-resource type="integer" name="config_captive_portal_mode"/&gt;
      &lt;integer name="config_captive_portal_mode"&gt;0&lt;/integer&gt;
  &lt;/resources&gt;
  </code></pre>
  
  <p>now I only have 2 options left, but I do not like any of them:
  a) patch aosp -> have troubles with updates
  b) run a script on the first startup -> ugly</p>
  
  <p>Did I miss something?</p>