use of cyanogenmod.profiles.ConnectionSettings in project android_packages_apps_CMParts by LineageOS.
the class SetupActionsFragment method fillProfileWithCurrentSettings.
public static void fillProfileWithCurrentSettings(Context context, Profile profile) {
// bt
if (DeviceUtils.deviceSupportsBluetooth()) {
profile.setConnectionSettings(new ConnectionSettings(ConnectionSettings.PROFILE_CONNECTION_BLUETOOTH, BluetoothAdapter.getDefaultAdapter().isEnabled() ? 1 : 0, true));
}
// gps
LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
boolean gpsEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
profile.setConnectionSettings(new ConnectionSettings(ConnectionSettings.PROFILE_CONNECTION_GPS, gpsEnabled ? 1 : 0, true));
// wifi
WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
profile.setConnectionSettings(new ConnectionSettings(ConnectionSettings.PROFILE_CONNECTION_WIFI, wifiManager.isWifiEnabled() ? 1 : 0, true));
// auto sync data
profile.setConnectionSettings(new ConnectionSettings(ConnectionSettings.PROFILE_CONNECTION_SYNC, ContentResolver.getMasterSyncAutomatically() ? 1 : 0, true));
// mobile data
if (DeviceUtils.deviceSupportsMobileData(context)) {
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
profile.setConnectionSettings(new ConnectionSettings(ConnectionSettings.PROFILE_CONNECTION_MOBILEDATA, cm.getMobileDataEnabled() ? 1 : 0, true));
}
// wifi hotspot
profile.setConnectionSettings(new ConnectionSettings(ConnectionSettings.PROFILE_CONNECTION_WIFIAP, wifiManager.isWifiApEnabled() ? 1 : 0, true));
// nfc
if (DeviceUtils.deviceSupportsNfc(context)) {
NfcManager nfcManager = (NfcManager) context.getSystemService(Context.NFC_SERVICE);
profile.setConnectionSettings(new ConnectionSettings(ConnectionSettings.PROFILE_CONNECTION_NFC, nfcManager.getDefaultAdapter().isEnabled() ? 1 : 0, true));
}
// alarm volume
final AudioManager am = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
profile.setStreamSettings(new StreamSettings(AudioManager.STREAM_ALARM, am.getStreamVolume(AudioManager.STREAM_ALARM), true));
// media volume
profile.setStreamSettings(new StreamSettings(AudioManager.STREAM_MUSIC, am.getStreamVolume(AudioManager.STREAM_MUSIC), true));
// ringtone volume
profile.setStreamSettings(new StreamSettings(AudioManager.STREAM_RING, am.getStreamVolume(AudioManager.STREAM_RING), true));
// notification volume
profile.setStreamSettings(new StreamSettings(AudioManager.STREAM_NOTIFICATION, am.getStreamVolume(AudioManager.STREAM_NOTIFICATION), true));
// ring mode
String ringValue;
switch(am.getRingerMode()) {
default:
case AudioManager.RINGER_MODE_NORMAL:
ringValue = "normal";
break;
case AudioManager.RINGER_MODE_SILENT:
ringValue = "mute";
break;
case AudioManager.RINGER_MODE_VIBRATE:
ringValue = "vibrate";
break;
}
profile.setRingMode(new RingModeSettings(ringValue, true));
// airplane mode
boolean airplaneMode = Settings.Global.getInt(context.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON, 0) != 0;
profile.setAirplaneMode(new AirplaneModeSettings(airplaneMode ? 1 : 0, true));
// lock screen mode
// populated only from profiles, so we can read the current profile,
// but let's skip this one
}
use of cyanogenmod.profiles.ConnectionSettings in project android_packages_apps_CMParts by LineageOS.
the class SetupActionsFragment method generatePreferredNetworkOverrideItem.
private ConnectionOverrideItem generatePreferredNetworkOverrideItem(int subId) {
ConnectionSettings settings = mProfile.getConnectionSettingWithSubId(subId);
if (settings == null) {
settings = new ConnectionSettings(ConnectionSettings.PROFILE_CONNECTION_2G3G4G);
settings.setSubId(subId);
mProfile.setConnectionSettings(settings);
}
return new ConnectionOverrideItem(settings.getConnectionId(), settings);
}
use of cyanogenmod.profiles.ConnectionSettings in project android_packages_apps_CMParts by LineageOS.
the class SetupActionsFragment method generateConnectionOverrideItem.
private ConnectionOverrideItem generateConnectionOverrideItem(int connectionId) {
ConnectionSettings settings = mProfile.getSettingsForConnection(connectionId);
if (settings == null) {
settings = new ConnectionSettings(connectionId);
mProfile.setConnectionSettings(settings);
}
return new ConnectionOverrideItem(connectionId, settings);
}
Aggregations