Bluetooth: Check for mPanService before changing tethering state

Checking for mPanService before changing OR checking tethering state,
otherwise it will lead to application crash while checking isTetheringOn
OR changing tethering state.

Change-Id: I00844c03cdb8616118c1d50d7d31c75e51f0ef9b
This commit is contained in:
Hemant Gupta
2015-02-15 18:56:54 +05:30
committed by Andre Eisenbach
parent 378939ad14
commit 58fbffc36f

View File

@@ -333,19 +333,25 @@ public final class BluetoothPan implements BluetoothProfile {
public void setBluetoothTethering(boolean value) {
if (DBG) log("setBluetoothTethering(" + value + ")");
try {
mPanService.setBluetoothTethering(value);
} catch (RemoteException e) {
Log.e(TAG, "Stack:" + Log.getStackTraceString(new Throwable()));
if (mPanService != null && isEnabled()) {
try {
mPanService.setBluetoothTethering(value);
} catch (RemoteException e) {
Log.e(TAG, "Stack:" + Log.getStackTraceString(new Throwable()));
}
}
}
public boolean isTetheringOn() {
if (VDBG) log("isTetheringOn()");
try {
return mPanService.isTetheringOn();
} catch (RemoteException e) {
Log.e(TAG, "Stack:" + Log.getStackTraceString(new Throwable()));
if (mPanService != null && isEnabled()) {
try {
return mPanService.isTetheringOn();
} catch (RemoteException e) {
Log.e(TAG, "Stack:" + Log.getStackTraceString(new Throwable()));
}
}
return false;
}