summaryrefslogtreecommitdiffstats
path: root/core/java/com
diff options
context:
space:
mode:
authorMartijn Coenen <maco@google.com>2012-04-20 13:05:04 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-04-20 13:05:04 -0700
commite81e3a4f85147ada753100b8a78584ce008d9e63 (patch)
treedd60c9acb8cf09d11a0c014653fff5dc7ce80c41 /core/java/com
parent48b6b711a772893ba080d84b6cd3df0e5aa70ee2 (diff)
parent3bba8d0457408421a6468f03bbb36e9ff32b81cf (diff)
downloadframeworks_base-e81e3a4f85147ada753100b8a78584ce008d9e63.zip
frameworks_base-e81e3a4f85147ada753100b8a78584ce008d9e63.tar.gz
frameworks_base-e81e3a4f85147ada753100b8a78584ce008d9e63.tar.bz2
Merge "Added NFC disable during phone shutdown"
Diffstat (limited to 'core/java/com')
-rw-r--r--core/java/com/android/internal/app/ShutdownThread.java37
1 files changed, 31 insertions, 6 deletions
diff --git a/core/java/com/android/internal/app/ShutdownThread.java b/core/java/com/android/internal/app/ShutdownThread.java
index 6a46929..c03694f 100644
--- a/core/java/com/android/internal/app/ShutdownThread.java
+++ b/core/java/com/android/internal/app/ShutdownThread.java
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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++) {
@@ -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);