import android.os.ResultReceiver;
import android.os.ServiceManager;
import android.os.SystemClock;
+import android.os.UserHandle;
+import android.os.UserManager;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.Base64;
private PowerManager mPowerManager;
private PowerManager.WakeLock mWakeLock;
private String mWakeLockName;
+ private UserManager mUserManager;
private ProfileObserver mProfileObserver;
getAdapterPropertyNative(AbstractionLayer.BT_PROPERTY_BDNAME);
mAlarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
mPowerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
+ mUserManager = (UserManager) getSystemService(Context.USER_SERVICE);
mBatteryStats = IBatteryStats.Stub.asInterface(ServiceManager.getService(
BatteryStats.SERVICE_NAME));
public synchronized boolean enable(boolean quietMode) {
enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, "Need BLUETOOTH ADMIN permission");
+ // Enforce the user restriction for disallowing Bluetooth if it was set.
+ if (mUserManager.hasUserRestriction(UserManager.DISALLOW_BLUETOOTH, UserHandle.SYSTEM)) {
+ debugLog("enable() called when Bluetooth was disallowed");
+ return false;
+ }
+
debugLog("enable() - Enable called with quiet mode status = " + mQuietmode);
mQuietmode = quietMode;
Message m = mAdapterStateMachine.obtainMessage(AdapterState.BLE_TURN_ON);