Detect Airplane Mode, GSM and WiFi

Hi,  I'm trying to make an app for an old android 5.1.1 device which has limited battery.  To extend battery life, I wanted to make sure the mobile phone is in airplane mode, and that Wifi and GSM (and others like location, bluetooth, etc) are both disable.  is there a way to do this checking?

Also, is there a way to programatically enable them as well? maybe before closing the app, the app will auto-enable these settings back.