[configuration] set much lower leader weight for non-BR devices

There can be cases that both a phone and accessory can be a leader
of their own partitions and then merges together when the user
moves close to the accessory. In this case, it's better for the
phone to always attach to the accessory as a Child rather than
being a Leader.

To achieve this, we can set a leader weight less than the default
value 64 - currently, 32 for non-BR Android devices.

Bug: 404979710
Change-Id: I63bff20e9945751449299545a03f52764e28f9b8
diff --git a/src/android/android_rcp_host.cpp b/src/android/android_rcp_host.cpp
index f24ccae..4c81e98 100644
--- a/src/android/android_rcp_host.cpp
+++ b/src/android/android_rcp_host.cpp
@@ -72,6 +72,7 @@
     otError          error = OT_ERROR_NONE;
     std::string      message;
     otLinkModeConfig linkModeConfig;
+    bool             borderRouterEnabled = aConfiguration.borderRouterEnabled;
 
     otbrLogInfo("Set configuration: %s", aConfiguration.toString().c_str());
 
@@ -90,9 +91,17 @@
 
     // - In non-BR mode, this device should try to be a router only when there are no other routers
     // - 16 is the default ROUTER_UPGRADE_THRESHOLD value defined in OpenThread
-    otThreadSetRouterUpgradeThreshold(GetOtInstance(), (aConfiguration.borderRouterEnabled ? 16 : 1));
+    otThreadSetRouterUpgradeThreshold(GetOtInstance(), (borderRouterEnabled ? 16 : 1));
 
-    if (aConfiguration.borderRouterEnabled && aConfiguration.srpServerWaitForBorderRoutingEnabled)
+    // Sets much lower Leader / Partition weight for a non-BR device so that it would
+    // not attempt to be the new leader after merging partitions. Keeps BR using the
+    // default Leader weight value 64.
+    //
+    // TODO: b/404979710 - sets leader weight higher based on the new Thread 1.4 device
+    // properties feature.
+    otThreadSetLocalLeaderWeight(GetOtInstance(), (borderRouterEnabled ? 64 : 32));
+
+    if (borderRouterEnabled && aConfiguration.srpServerWaitForBorderRoutingEnabled)
     {
         // This will automatically disable fast-start mode if it was ever enabled
         otSrpServerSetAutoEnableMode(GetOtInstance(), true);
@@ -103,7 +112,7 @@
         otSrpServerEnableFastStartMode(GetOtInstance());
     }
 
-    SetBorderRouterEnabled(aConfiguration.borderRouterEnabled);
+    SetBorderRouterEnabled(borderRouterEnabled);
 
     mConfiguration = aConfiguration;