diff options
author | Danny Baumann <dannybaumann@web.de> | 2014-11-12 17:14:27 -0800 |
---|---|---|
committer | Adnan Begovic <adnan@cyngn.com> | 2015-10-26 16:11:13 -0700 |
commit | d40cd5728a415efd72ee192fa6f67727411ed959 (patch) | |
tree | ae0afabb0d80930130005dd09c6c864e9177cfb1 /src/com/android/settings/profiles/ProfilesUtils.java | |
parent | cf65d3f14dce8dae3590daac56bdd59be28e1779 (diff) | |
download | packages_apps_Settings-d40cd5728a415efd72ee192fa6f67727411ed959.zip packages_apps_Settings-d40cd5728a415efd72ee192fa6f67727411ed959.tar.gz packages_apps_Settings-d40cd5728a415efd72ee192fa6f67727411ed959.tar.bz2 |
Profiles : Settings
Change-Id: I072758a1c5ec04ef34077551220b6611068fe71d
Diffstat (limited to 'src/com/android/settings/profiles/ProfilesUtils.java')
-rw-r--r-- | src/com/android/settings/profiles/ProfilesUtils.java | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/src/com/android/settings/profiles/ProfilesUtils.java b/src/com/android/settings/profiles/ProfilesUtils.java new file mode 100644 index 0000000..4f59dd9 --- /dev/null +++ b/src/com/android/settings/profiles/ProfilesUtils.java @@ -0,0 +1,68 @@ +package com.android.settings.profiles; + +import android.bluetooth.BluetoothAdapter; +import android.content.ContentResolver; +import android.content.Context; +import android.content.pm.PackageManager; +import android.content.res.Resources; +import android.hardware.Camera; +import android.hardware.display.DisplayManager; +import android.hardware.display.WifiDisplayStatus; +import android.hardware.Sensor; +import android.hardware.SensorManager; +import android.net.ConnectivityManager; +import android.nfc.NfcAdapter; +import android.os.BatteryManager; +import android.os.UserHandle; +import android.provider.Settings; +import android.telephony.TelephonyManager; +import android.text.TextUtils; + +import com.android.internal.telephony.PhoneConstants; + +public class ProfilesUtils { + public static boolean deviceSupportsUsbTether(Context ctx) { + ConnectivityManager cm = (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE); + return (cm.getTetherableUsbRegexs().length != 0); + } + + public static boolean deviceSupportsWifiDisplay(Context ctx) { + DisplayManager dm = (DisplayManager) ctx.getSystemService(Context.DISPLAY_SERVICE); + return (dm.getWifiDisplayStatus().getFeatureState() != WifiDisplayStatus.FEATURE_STATE_UNAVAILABLE); + } + + public static boolean deviceSupportsMobileData(Context ctx) { + ConnectivityManager cm = (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE); + return cm.isNetworkSupported(ConnectivityManager.TYPE_MOBILE); + } + + public static boolean deviceSupportsBluetooth() { + return (BluetoothAdapter.getDefaultAdapter() != null); + } + + public static boolean systemProfilesEnabled(ContentResolver resolver) { + return (Settings.System.getInt(resolver, Settings.System.SYSTEM_PROFILES_ENABLED, 1) == 1); + } + + public static boolean deviceSupportsNfc(Context ctx) { + return NfcAdapter.getDefaultAdapter(ctx) != null; + } + + public static boolean deviceSupportsCamera() { + return Camera.getNumberOfCameras() > 0; + } + + public static boolean deviceSupportsGps(Context context) { + return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_LOCATION_GPS); + } + + public static boolean adbEnabled(ContentResolver resolver) { + return (Settings.Global.getInt(resolver, Settings.Global.ADB_ENABLED, 0)) == 1; + } + + public static boolean deviceSupportsCompass(Context context) { + SensorManager sm = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE); + return (sm.getDefaultSensor(Sensor.TYPE_ACCELEROMETER) != null + && sm.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD) != null); + } +} |