use of android.bluetooth.IBluetoothManager in project android_frameworks_base by ResurrectionRemix.
the class ShutdownThread method shutdownRadios.
private void shutdownRadios(final int timeout) {
// If a radio is wedged, disabling it may hang so we do this work in another thread,
// just in case.
final long endTime = SystemClock.elapsedRealtime() + timeout;
final boolean[] done = new boolean[1];
Thread t = new Thread() {
public void run() {
boolean nfcOff;
boolean bluetoothOff;
boolean radioOff;
final INfcAdapter nfc = INfcAdapter.Stub.asInterface(ServiceManager.checkService("nfc"));
final ITelephony phone = ITelephony.Stub.asInterface(ServiceManager.checkService("phone"));
final IBluetoothManager bluetooth = IBluetoothManager.Stub.asInterface(ServiceManager.checkService(BluetoothAdapter.BLUETOOTH_MANAGER_SERVICE));
try {
nfcOff = nfc == null || nfc.getState() == NfcAdapter.STATE_OFF;
if (!nfcOff) {
Log.w(TAG, "Turning off NFC...");
// Don't persist new state
nfc.disable(false);
}
} catch (RemoteException ex) {
Log.e(TAG, "RemoteException during NFC shutdown", ex);
nfcOff = true;
}
try {
bluetoothOff = bluetooth == null || bluetooth.getState() == BluetoothAdapter.STATE_OFF;
if (!bluetoothOff) {
Log.w(TAG, "Disabling Bluetooth...");
// disable but don't persist new state
bluetooth.disable(mContext.getPackageName(), false);
}
} catch (RemoteException ex) {
Log.e(TAG, "RemoteException during bluetooth shutdown", ex);
bluetoothOff = true;
}
try {
radioOff = phone == null || !phone.needMobileRadioShutdown();
if (!radioOff) {
Log.w(TAG, "Turning off cellular radios...");
phone.shutdownMobileRadios();
}
} catch (RemoteException ex) {
Log.e(TAG, "RemoteException during radio shutdown", ex);
radioOff = true;
}
Log.i(TAG, "Waiting for NFC, Bluetooth and Radio...");
long delay = endTime - SystemClock.elapsedRealtime();
while (delay > 0) {
if (mRebootHasProgressBar) {
int status = (int) ((timeout - delay) * 1.0 * (RADIO_STOP_PERCENT - PACKAGE_MANAGER_STOP_PERCENT) / timeout);
status += PACKAGE_MANAGER_STOP_PERCENT;
sInstance.setRebootProgress(status, null);
}
if (!bluetoothOff) {
try {
bluetoothOff = bluetooth.getState() == BluetoothAdapter.STATE_OFF;
} catch (RemoteException ex) {
Log.e(TAG, "RemoteException during bluetooth shutdown", ex);
bluetoothOff = true;
}
if (bluetoothOff) {
Log.i(TAG, "Bluetooth turned off.");
}
}
if (!radioOff) {
try {
radioOff = !phone.needMobileRadioShutdown();
} catch (RemoteException ex) {
Log.e(TAG, "RemoteException during radio shutdown", ex);
radioOff = true;
}
if (radioOff) {
Log.i(TAG, "Radio turned off.");
}
}
if (!nfcOff) {
try {
nfcOff = nfc.getState() == NfcAdapter.STATE_OFF;
} catch (RemoteException ex) {
Log.e(TAG, "RemoteException during NFC shutdown", ex);
nfcOff = true;
}
if (nfcOff) {
Log.i(TAG, "NFC turned off.");
}
}
if (radioOff && bluetoothOff && nfcOff) {
Log.i(TAG, "NFC, Radio and Bluetooth shutdown complete.");
done[0] = true;
break;
}
SystemClock.sleep(PHONE_STATE_POLL_SLEEP_MSEC);
delay = endTime - SystemClock.elapsedRealtime();
}
}
};
t.start();
try {
t.join(timeout);
} catch (InterruptedException ex) {
}
if (!done[0]) {
Log.w(TAG, "Timed out waiting for NFC, Radio and Bluetooth shutdown.");
}
}
use of android.bluetooth.IBluetoothManager in project android_frameworks_base by crdroidandroid.
the class ShutdownThread method shutdownRadios.
private void shutdownRadios(final int timeout) {
// If a radio is wedged, disabling it may hang so we do this work in another thread,
// just in case.
final long endTime = SystemClock.elapsedRealtime() + timeout;
final boolean[] done = new boolean[1];
Thread t = new Thread() {
public void run() {
boolean nfcOff;
boolean bluetoothOff;
boolean radioOff;
final INfcAdapter nfc = INfcAdapter.Stub.asInterface(ServiceManager.checkService("nfc"));
final ITelephony phone = ITelephony.Stub.asInterface(ServiceManager.checkService("phone"));
final IBluetoothManager bluetooth = IBluetoothManager.Stub.asInterface(ServiceManager.checkService(BluetoothAdapter.BLUETOOTH_MANAGER_SERVICE));
try {
nfcOff = nfc == null || nfc.getState() == NfcAdapter.STATE_OFF;
if (!nfcOff) {
Log.w(TAG, "Turning off NFC...");
// Don't persist new state
nfc.disable(false);
}
} catch (RemoteException ex) {
Log.e(TAG, "RemoteException during NFC shutdown", ex);
nfcOff = true;
}
try {
bluetoothOff = bluetooth == null || bluetooth.getState() == BluetoothAdapter.STATE_OFF;
if (!bluetoothOff) {
Log.w(TAG, "Disabling Bluetooth...");
// disable but don't persist new state
bluetooth.disable(mContext.getPackageName(), false);
}
} catch (RemoteException ex) {
Log.e(TAG, "RemoteException during bluetooth shutdown", ex);
bluetoothOff = true;
}
try {
radioOff = phone == null || !phone.needMobileRadioShutdown();
if (!radioOff) {
Log.w(TAG, "Turning off cellular radios...");
phone.shutdownMobileRadios();
}
} catch (RemoteException ex) {
Log.e(TAG, "RemoteException during radio shutdown", ex);
radioOff = true;
}
Log.i(TAG, "Waiting for NFC, Bluetooth and Radio...");
long delay = endTime - SystemClock.elapsedRealtime();
while (delay > 0) {
if (mRebootHasProgressBar) {
int status = (int) ((timeout - delay) * 1.0 * (RADIO_STOP_PERCENT - PACKAGE_MANAGER_STOP_PERCENT) / timeout);
status += PACKAGE_MANAGER_STOP_PERCENT;
sInstance.setRebootProgress(status, null);
}
if (!bluetoothOff) {
try {
bluetoothOff = bluetooth.getState() == BluetoothAdapter.STATE_OFF;
} catch (RemoteException ex) {
Log.e(TAG, "RemoteException during bluetooth shutdown", ex);
bluetoothOff = true;
}
if (bluetoothOff) {
Log.i(TAG, "Bluetooth turned off.");
}
}
if (!radioOff) {
try {
radioOff = !phone.needMobileRadioShutdown();
} catch (RemoteException ex) {
Log.e(TAG, "RemoteException during radio shutdown", ex);
radioOff = true;
}
if (radioOff) {
Log.i(TAG, "Radio turned off.");
}
}
if (!nfcOff) {
try {
nfcOff = nfc.getState() == NfcAdapter.STATE_OFF;
} catch (RemoteException ex) {
Log.e(TAG, "RemoteException during NFC shutdown", ex);
nfcOff = true;
}
if (nfcOff) {
Log.i(TAG, "NFC turned off.");
}
}
if (radioOff && bluetoothOff && nfcOff) {
Log.i(TAG, "NFC, Radio and Bluetooth shutdown complete.");
done[0] = true;
break;
}
SystemClock.sleep(PHONE_STATE_POLL_SLEEP_MSEC);
delay = endTime - SystemClock.elapsedRealtime();
}
}
};
t.start();
try {
t.join(timeout);
} catch (InterruptedException ex) {
}
if (!done[0]) {
Log.w(TAG, "Timed out waiting for NFC, Radio and Bluetooth shutdown.");
}
}
use of android.bluetooth.IBluetoothManager in project android_frameworks_base by ParanoidAndroid.
the class ShutdownThread method shutdownRadios.
private void shutdownRadios(int timeout) {
// If a radio is wedged, disabling it may hang so we do this work in another thread,
// just in case.
final long endTime = SystemClock.elapsedRealtime() + timeout;
final boolean[] done = new boolean[1];
Thread t = new Thread() {
public void run() {
boolean nfcOff;
boolean bluetoothOff;
boolean radioOff;
final INfcAdapter nfc = INfcAdapter.Stub.asInterface(ServiceManager.checkService("nfc"));
final ITelephony phone = ITelephony.Stub.asInterface(ServiceManager.checkService("phone"));
final IBluetoothManager bluetooth = IBluetoothManager.Stub.asInterface(ServiceManager.checkService(BluetoothAdapter.BLUETOOTH_MANAGER_SERVICE));
try {
nfcOff = nfc == null || nfc.getState() == NfcAdapter.STATE_OFF;
if (!nfcOff) {
Log.w(TAG, "Turning off NFC...");
// Don't persist new state
nfc.disable(false);
}
} catch (RemoteException ex) {
Log.e(TAG, "RemoteException during NFC shutdown", ex);
nfcOff = true;
}
try {
bluetoothOff = bluetooth == null || !bluetooth.isEnabled();
if (!bluetoothOff) {
Log.w(TAG, "Disabling Bluetooth...");
// disable but don't persist new state
bluetooth.disable(false);
}
} catch (RemoteException ex) {
Log.e(TAG, "RemoteException during bluetooth shutdown", ex);
bluetoothOff = true;
}
try {
radioOff = phone == null || !phone.isRadioOn();
if (!radioOff) {
Log.w(TAG, "Turning off radio...");
phone.setRadio(false);
}
} catch (RemoteException ex) {
Log.e(TAG, "RemoteException during radio shutdown", ex);
radioOff = true;
}
Log.i(TAG, "Waiting for NFC, Bluetooth and Radio...");
while (SystemClock.elapsedRealtime() < endTime) {
if (!bluetoothOff) {
try {
bluetoothOff = !bluetooth.isEnabled();
} catch (RemoteException ex) {
Log.e(TAG, "RemoteException during bluetooth shutdown", ex);
bluetoothOff = true;
}
if (bluetoothOff) {
Log.i(TAG, "Bluetooth turned off.");
}
}
if (!radioOff) {
try {
radioOff = !phone.isRadioOn();
} catch (RemoteException ex) {
Log.e(TAG, "RemoteException during radio shutdown", ex);
radioOff = true;
}
if (radioOff) {
Log.i(TAG, "Radio turned off.");
}
}
if (!nfcOff) {
try {
nfcOff = nfc.getState() == NfcAdapter.STATE_OFF;
} catch (RemoteException ex) {
Log.e(TAG, "RemoteException during NFC shutdown", ex);
nfcOff = true;
}
if (radioOff) {
Log.i(TAG, "NFC turned off.");
}
}
if (radioOff && bluetoothOff && nfcOff) {
Log.i(TAG, "NFC, Radio and Bluetooth shutdown complete.");
done[0] = true;
break;
}
SystemClock.sleep(PHONE_STATE_POLL_SLEEP_MSEC);
}
}
};
t.start();
try {
t.join(timeout);
} catch (InterruptedException ex) {
}
if (!done[0]) {
Log.w(TAG, "Timed out waiting for NFC, Radio and Bluetooth shutdown.");
}
}
use of android.bluetooth.IBluetoothManager in project android_frameworks_base by DirtyUnicorns.
the class ShutdownThread method shutdownRadios.
private void shutdownRadios(final int timeout) {
// If a radio is wedged, disabling it may hang so we do this work in another thread,
// just in case.
final long endTime = SystemClock.elapsedRealtime() + timeout;
final boolean[] done = new boolean[1];
Thread t = new Thread() {
public void run() {
boolean nfcOff;
boolean bluetoothOff;
boolean radioOff;
final INfcAdapter nfc = INfcAdapter.Stub.asInterface(ServiceManager.checkService("nfc"));
final ITelephony phone = ITelephony.Stub.asInterface(ServiceManager.checkService("phone"));
final IBluetoothManager bluetooth = IBluetoothManager.Stub.asInterface(ServiceManager.checkService(BluetoothAdapter.BLUETOOTH_MANAGER_SERVICE));
try {
nfcOff = nfc == null || nfc.getState() == NfcAdapter.STATE_OFF;
if (!nfcOff) {
Log.w(TAG, "Turning off NFC...");
// Don't persist new state
nfc.disable(false);
}
} catch (RemoteException ex) {
Log.e(TAG, "RemoteException during NFC shutdown", ex);
nfcOff = true;
}
try {
bluetoothOff = bluetooth == null || bluetooth.getState() == BluetoothAdapter.STATE_OFF;
if (!bluetoothOff) {
Log.w(TAG, "Disabling Bluetooth...");
// disable but don't persist new state
bluetooth.disable(mContext.getPackageName(), false);
}
} catch (RemoteException ex) {
Log.e(TAG, "RemoteException during bluetooth shutdown", ex);
bluetoothOff = true;
}
try {
radioOff = phone == null || !phone.needMobileRadioShutdown();
if (!radioOff) {
Log.w(TAG, "Turning off cellular radios...");
phone.shutdownMobileRadios();
}
} catch (RemoteException ex) {
Log.e(TAG, "RemoteException during radio shutdown", ex);
radioOff = true;
}
Log.i(TAG, "Waiting for NFC, Bluetooth and Radio...");
long delay = endTime - SystemClock.elapsedRealtime();
while (delay > 0) {
if (mRebootHasProgressBar) {
int status = (int) ((timeout - delay) * 1.0 * (RADIO_STOP_PERCENT - PACKAGE_MANAGER_STOP_PERCENT) / timeout);
status += PACKAGE_MANAGER_STOP_PERCENT;
sInstance.setRebootProgress(status, null);
}
if (!bluetoothOff) {
try {
bluetoothOff = bluetooth.getState() == BluetoothAdapter.STATE_OFF;
} catch (RemoteException ex) {
Log.e(TAG, "RemoteException during bluetooth shutdown", ex);
bluetoothOff = true;
}
if (bluetoothOff) {
Log.i(TAG, "Bluetooth turned off.");
}
}
if (!radioOff) {
try {
radioOff = !phone.needMobileRadioShutdown();
} catch (RemoteException ex) {
Log.e(TAG, "RemoteException during radio shutdown", ex);
radioOff = true;
}
if (radioOff) {
Log.i(TAG, "Radio turned off.");
}
}
if (!nfcOff) {
try {
nfcOff = nfc.getState() == NfcAdapter.STATE_OFF;
} catch (RemoteException ex) {
Log.e(TAG, "RemoteException during NFC shutdown", ex);
nfcOff = true;
}
if (nfcOff) {
Log.i(TAG, "NFC turned off.");
}
}
if (radioOff && bluetoothOff && nfcOff) {
Log.i(TAG, "NFC, Radio and Bluetooth shutdown complete.");
done[0] = true;
break;
}
SystemClock.sleep(PHONE_STATE_POLL_SLEEP_MSEC);
delay = endTime - SystemClock.elapsedRealtime();
}
}
};
t.start();
try {
t.join(timeout);
} catch (InterruptedException ex) {
}
if (!done[0]) {
Log.w(TAG, "Timed out waiting for NFC, Radio and Bluetooth shutdown.");
}
}
use of android.bluetooth.IBluetoothManager in project platform_frameworks_base by android.
the class ShutdownThread method shutdownRadios.
private void shutdownRadios(final int timeout) {
// If a radio is wedged, disabling it may hang so we do this work in another thread,
// just in case.
final long endTime = SystemClock.elapsedRealtime() + timeout;
final boolean[] done = new boolean[1];
Thread t = new Thread() {
public void run() {
boolean nfcOff;
boolean bluetoothOff;
boolean radioOff;
final INfcAdapter nfc = INfcAdapter.Stub.asInterface(ServiceManager.checkService("nfc"));
final ITelephony phone = ITelephony.Stub.asInterface(ServiceManager.checkService("phone"));
final IBluetoothManager bluetooth = IBluetoothManager.Stub.asInterface(ServiceManager.checkService(BluetoothAdapter.BLUETOOTH_MANAGER_SERVICE));
try {
nfcOff = nfc == null || nfc.getState() == NfcAdapter.STATE_OFF;
if (!nfcOff) {
Log.w(TAG, "Turning off NFC...");
// Don't persist new state
nfc.disable(false);
}
} catch (RemoteException ex) {
Log.e(TAG, "RemoteException during NFC shutdown", ex);
nfcOff = true;
}
try {
bluetoothOff = bluetooth == null || bluetooth.getState() == BluetoothAdapter.STATE_OFF;
if (!bluetoothOff) {
Log.w(TAG, "Disabling Bluetooth...");
// disable but don't persist new state
bluetooth.disable(mContext.getPackageName(), false);
}
} catch (RemoteException ex) {
Log.e(TAG, "RemoteException during bluetooth shutdown", ex);
bluetoothOff = true;
}
try {
radioOff = phone == null || !phone.needMobileRadioShutdown();
if (!radioOff) {
Log.w(TAG, "Turning off cellular radios...");
phone.shutdownMobileRadios();
}
} catch (RemoteException ex) {
Log.e(TAG, "RemoteException during radio shutdown", ex);
radioOff = true;
}
Log.i(TAG, "Waiting for NFC, Bluetooth and Radio...");
long delay = endTime - SystemClock.elapsedRealtime();
while (delay > 0) {
if (mRebootHasProgressBar) {
int status = (int) ((timeout - delay) * 1.0 * (RADIO_STOP_PERCENT - PACKAGE_MANAGER_STOP_PERCENT) / timeout);
status += PACKAGE_MANAGER_STOP_PERCENT;
sInstance.setRebootProgress(status, null);
}
if (!bluetoothOff) {
try {
bluetoothOff = bluetooth.getState() == BluetoothAdapter.STATE_OFF;
} catch (RemoteException ex) {
Log.e(TAG, "RemoteException during bluetooth shutdown", ex);
bluetoothOff = true;
}
if (bluetoothOff) {
Log.i(TAG, "Bluetooth turned off.");
}
}
if (!radioOff) {
try {
radioOff = !phone.needMobileRadioShutdown();
} catch (RemoteException ex) {
Log.e(TAG, "RemoteException during radio shutdown", ex);
radioOff = true;
}
if (radioOff) {
Log.i(TAG, "Radio turned off.");
}
}
if (!nfcOff) {
try {
nfcOff = nfc.getState() == NfcAdapter.STATE_OFF;
} catch (RemoteException ex) {
Log.e(TAG, "RemoteException during NFC shutdown", ex);
nfcOff = true;
}
if (nfcOff) {
Log.i(TAG, "NFC turned off.");
}
}
if (radioOff && bluetoothOff && nfcOff) {
Log.i(TAG, "NFC, Radio and Bluetooth shutdown complete.");
done[0] = true;
break;
}
SystemClock.sleep(PHONE_STATE_POLL_SLEEP_MSEC);
delay = endTime - SystemClock.elapsedRealtime();
}
}
};
t.start();
try {
t.join(timeout);
} catch (InterruptedException ex) {
}
if (!done[0]) {
Log.w(TAG, "Timed out waiting for NFC, Radio and Bluetooth shutdown.");
}
}
Aggregations