Loading core/java/android/nfc/INfcAdapter.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -34,7 +34,7 @@ interface INfcAdapter INfcAdapterExtras getNfcAdapterExtrasInterface(in String pkg); int getState(); boolean disable(); boolean disable(boolean saveState); boolean enable(); boolean enableNdefPush(); boolean disableNdefPush(); Loading core/java/android/nfc/NfcAdapter.java +2 −1 Original line number Diff line number Diff line Loading @@ -574,9 +574,10 @@ public final class NfcAdapter { * * @hide */ public boolean disable() { try { return sService.disable(); return sService.disable(true); } catch (RemoteException e) { attemptDeadServiceRecovery(e); return false; Loading core/java/com/android/internal/app/ShutdownThread.java +31 −6 Original line number Diff line number Diff line Loading @@ -24,6 +24,8 @@ import android.app.IActivityManager; import android.app.ProgressDialog; import android.bluetooth.BluetoothAdapter; import android.bluetooth.IBluetooth; import android.nfc.NfcAdapter; import android.nfc.INfcAdapter; import android.content.BroadcastReceiver; import android.content.Context; import android.content.DialogInterface; Loading @@ -48,7 +50,7 @@ import android.view.WindowManager; public final class ShutdownThread extends Thread { // constants private static final String TAG = "ShutdownThread"; private static final int MAX_NUM_PHONE_STATE_READS = 16; private static final int MAX_NUM_PHONE_STATE_READS = 24; private static final int PHONE_STATE_POLL_SLEEP_MSEC = 500; // maximum time we wait for the shutdown broadcast before going on. private static final int MAX_BROADCAST_TIME = 10*1000; Loading Loading @@ -231,6 +233,7 @@ public final class ShutdownThread extends Thread { * Shuts off power regardless of radio and bluetooth state if the alloted time has passed. */ public void run() { boolean nfcOff; boolean bluetoothOff; boolean radioOff; Loading Loading @@ -284,16 +287,29 @@ public final class ShutdownThread extends Thread { } } final INfcAdapter nfc = INfcAdapter.Stub.asInterface(ServiceManager.checkService("nfc")); final ITelephony phone = ITelephony.Stub.asInterface(ServiceManager.checkService("phone")); final IBluetooth bluetooth = IBluetooth.Stub.asInterface(ServiceManager.checkService( BluetoothAdapter.BLUETOOTH_SERVICE)); final IMountService mount = IMountService.Stub.asInterface( ServiceManager.checkService("mount")); try { nfcOff = nfc == null || nfc.getState() == NfcAdapter.STATE_OFF; if (!nfcOff) { Log.w(TAG, "Turning off NFC..."); nfc.disable(false); // Don't persist new state } } catch (RemoteException ex) { Log.e(TAG, "RemoteException during NFC shutdown", ex); nfcOff = true; } try { bluetoothOff = bluetooth == null || bluetooth.getBluetoothState() == BluetoothAdapter.STATE_OFF; Loading @@ -317,7 +333,7 @@ public final class ShutdownThread extends Thread { radioOff = true; } Log.i(TAG, "Waiting for Bluetooth and Radio..."); Log.i(TAG, "Waiting for NFC, Bluetooth and Radio..."); // Wait a max of 32 seconds for clean shutdown for (int i = 0; i < MAX_NUM_PHONE_STATE_READS; i++) { Loading @@ -338,8 +354,17 @@ public final class ShutdownThread extends Thread { radioOff = true; } } if (radioOff && bluetoothOff) { Log.i(TAG, "Radio and Bluetooth shutdown complete."); if (!nfcOff) { try { nfcOff = nfc.getState() == NfcAdapter.STATE_OFF; } catch (RemoteException ex) { Log.e(TAG, "RemoteException during NFC shutdown", ex); nfcOff = true; } } if (radioOff && bluetoothOff && nfcOff) { Log.i(TAG, "NFC, Radio and Bluetooth shutdown complete."); break; } SystemClock.sleep(PHONE_STATE_POLL_SLEEP_MSEC); Loading Loading
core/java/android/nfc/INfcAdapter.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -34,7 +34,7 @@ interface INfcAdapter INfcAdapterExtras getNfcAdapterExtrasInterface(in String pkg); int getState(); boolean disable(); boolean disable(boolean saveState); boolean enable(); boolean enableNdefPush(); boolean disableNdefPush(); Loading
core/java/android/nfc/NfcAdapter.java +2 −1 Original line number Diff line number Diff line Loading @@ -574,9 +574,10 @@ public final class NfcAdapter { * * @hide */ public boolean disable() { try { return sService.disable(); return sService.disable(true); } catch (RemoteException e) { attemptDeadServiceRecovery(e); return false; Loading
core/java/com/android/internal/app/ShutdownThread.java +31 −6 Original line number Diff line number Diff line Loading @@ -24,6 +24,8 @@ import android.app.IActivityManager; import android.app.ProgressDialog; import android.bluetooth.BluetoothAdapter; import android.bluetooth.IBluetooth; import android.nfc.NfcAdapter; import android.nfc.INfcAdapter; import android.content.BroadcastReceiver; import android.content.Context; import android.content.DialogInterface; Loading @@ -48,7 +50,7 @@ import android.view.WindowManager; public final class ShutdownThread extends Thread { // constants private static final String TAG = "ShutdownThread"; private static final int MAX_NUM_PHONE_STATE_READS = 16; private static final int MAX_NUM_PHONE_STATE_READS = 24; private static final int PHONE_STATE_POLL_SLEEP_MSEC = 500; // maximum time we wait for the shutdown broadcast before going on. private static final int MAX_BROADCAST_TIME = 10*1000; Loading Loading @@ -231,6 +233,7 @@ public final class ShutdownThread extends Thread { * Shuts off power regardless of radio and bluetooth state if the alloted time has passed. */ public void run() { boolean nfcOff; boolean bluetoothOff; boolean radioOff; Loading Loading @@ -284,16 +287,29 @@ public final class ShutdownThread extends Thread { } } final INfcAdapter nfc = INfcAdapter.Stub.asInterface(ServiceManager.checkService("nfc")); final ITelephony phone = ITelephony.Stub.asInterface(ServiceManager.checkService("phone")); final IBluetooth bluetooth = IBluetooth.Stub.asInterface(ServiceManager.checkService( BluetoothAdapter.BLUETOOTH_SERVICE)); final IMountService mount = IMountService.Stub.asInterface( ServiceManager.checkService("mount")); try { nfcOff = nfc == null || nfc.getState() == NfcAdapter.STATE_OFF; if (!nfcOff) { Log.w(TAG, "Turning off NFC..."); nfc.disable(false); // Don't persist new state } } catch (RemoteException ex) { Log.e(TAG, "RemoteException during NFC shutdown", ex); nfcOff = true; } try { bluetoothOff = bluetooth == null || bluetooth.getBluetoothState() == BluetoothAdapter.STATE_OFF; Loading @@ -317,7 +333,7 @@ public final class ShutdownThread extends Thread { radioOff = true; } Log.i(TAG, "Waiting for Bluetooth and Radio..."); Log.i(TAG, "Waiting for NFC, Bluetooth and Radio..."); // Wait a max of 32 seconds for clean shutdown for (int i = 0; i < MAX_NUM_PHONE_STATE_READS; i++) { Loading @@ -338,8 +354,17 @@ public final class ShutdownThread extends Thread { radioOff = true; } } if (radioOff && bluetoothOff) { Log.i(TAG, "Radio and Bluetooth shutdown complete."); if (!nfcOff) { try { nfcOff = nfc.getState() == NfcAdapter.STATE_OFF; } catch (RemoteException ex) { Log.e(TAG, "RemoteException during NFC shutdown", ex); nfcOff = true; } } if (radioOff && bluetoothOff && nfcOff) { Log.i(TAG, "NFC, Radio and Bluetooth shutdown complete."); break; } SystemClock.sleep(PHONE_STATE_POLL_SLEEP_MSEC); Loading