diff options
Diffstat (limited to 'src/com/android/bluetooth/pan/PanService.java')
-rw-r--r-- | src/com/android/bluetooth/pan/PanService.java | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/com/android/bluetooth/pan/PanService.java b/src/com/android/bluetooth/pan/PanService.java index aa5a1fd31..92eab7787 100644 --- a/src/com/android/bluetooth/pan/PanService.java +++ b/src/com/android/bluetooth/pan/PanService.java @@ -40,6 +40,7 @@ import com.android.bluetooth.Utils; import com.android.bluetooth.btservice.AdapterService; import com.android.bluetooth.btservice.MetricsLogger; import com.android.bluetooth.btservice.ProfileService; +import com.android.internal.annotations.VisibleForTesting; import java.net.InetAddress; import java.util.ArrayList; @@ -67,6 +68,9 @@ public class PanService extends ProfileService { private String mNapIfaceAddr; private boolean mNativeAvailable; + @VisibleForTesting + UserManager mUserManager; + private static final int MESSAGE_CONNECT = 1; private static final int MESSAGE_DISCONNECT = 2; private static final int MESSAGE_CONNECT_STATE_CHANGED = 11; @@ -116,6 +120,8 @@ public class PanService extends ProfileService { initializeNative(); mNativeAvailable = true; + mUserManager = (UserManager) getSystemService(Context.USER_SERVICE); + mNetworkFactory = new BluetoothTetheringNetworkFactory(getBaseContext(), getMainLooper(), this); setPanService(this); @@ -137,6 +143,9 @@ public class PanService extends ProfileService { cleanupNative(); mNativeAvailable = false; } + + mUserManager = null; + if (mPanDevices != null) { int[] desiredStates = {BluetoothProfile.STATE_CONNECTING, BluetoothProfile.STATE_CONNECTED, BluetoothProfile.STATE_DISCONNECTING}; @@ -319,6 +328,10 @@ public class PanService extends ProfileService { public boolean connect(BluetoothDevice device) { enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission"); + if (mUserManager.isGuestUser()) { + Log.w(TAG, "Guest user does not have the permission to change the WiFi network"); + return false; + } if (getConnectionState(device) != BluetoothProfile.STATE_DISCONNECTED) { Log.e(TAG, "Pan Device not disconnected: " + device); return false; |