Location services is not enabled in Device / Simulator Settings

For my test, I am entering location for my weather test in My app. To
make it work, Location services to be enabled in Device / Simulator
Settings.
Currently Location services is not enabled in simulator. So my tests are failing. Is there a way to enabled it in Android/iOS simulator using code

e.g.

Location white_house = new Location(38.8977, 77.0366, 0);
driver.setLocation(white_house);

@Aleksei

I need to enable Location in Settings Menu of the Android device. How Can I do it via code ?

FYI I have attached Location Setting screen

i guess you need to enable it with your app under test. app should ask permission and enable location -> in code you managing this situation to proceed with Agree or not.