It's pretty easy to set the autoBrightness in Android, isn't it?
Settings.System.putInt(resolver,
Settings.System.SCREEN_BRIGHTNESS_MODE, 0); // 0 is manual, 1 is auto
But if you are toggling:
boolean isAuto = Settings.System.getInt(resolver,
Settings.System.SCREEN_BRIGHTNESS_MODE) == 1;
Settings.System.putInt(resolver,
Settings.System.SCREEN_BRIGHTNESS_MODE, isAuto ? 0 : 1);
It won't automatically adapt until you lock the screen and lock it again.