From 1a61b586b59243dab6c70984ab4418451f7d78fa Mon Sep 17 00:00:00 2001 From: Naveen Kalla Date: Wed, 3 Mar 2010 18:54:36 -0800 Subject: [PATCH 1/3] Retry pending memory status update to modem when radio is ON. When radio is powered off / airplane mode, memory status updates are ignored by RIL. With this fix, pending memory status updates are sent again when radio is powered back on. --- .../internal/telephony/SMSDispatcher.java | 33 +++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/telephony/java/com/android/internal/telephony/SMSDispatcher.java b/telephony/java/com/android/internal/telephony/SMSDispatcher.java index 53c0bef055519..fc0aa065b0c36 100644 --- a/telephony/java/com/android/internal/telephony/SMSDispatcher.java +++ b/telephony/java/com/android/internal/telephony/SMSDispatcher.java @@ -109,6 +109,12 @@ public abstract class SMSDispatcher extends Handler { /** Stop the sending */ static final protected int EVENT_STOP_SENDING = 10; + /** Memory status reporting is acknowledged by RIL */ + static final protected int EVENT_REPORT_MEMORY_STATUS_DONE = 11; + + /** Radio is ON */ + static final protected int EVENT_RADIO_ON = 12; + protected Phone mPhone; protected Context mContext; protected ContentResolver mResolver; @@ -152,6 +158,7 @@ public abstract class SMSDispatcher extends Handler { private SmsMessageBase.SubmitPduBase mSubmitPduBase; protected boolean mStorageAvailable = true; + protected boolean mReportMemoryStatusPending = false; protected static int getNextConcatenatedRef() { sConcatenatedRef += 1; @@ -235,6 +242,7 @@ public abstract class SMSDispatcher extends Handler { mCm.setOnNewSMS(this, EVENT_NEW_SMS, null); mCm.setOnSmsStatus(this, EVENT_NEW_SMS_STATUS_REPORT, null); mCm.setOnIccSmsFull(this, EVENT_ICC_FULL, null); + mCm.registerForOn(this, EVENT_RADIO_ON, null); // Don't always start message ref at 0. sConcatenatedRef = new Random().nextInt(256); @@ -253,6 +261,7 @@ public abstract class SMSDispatcher extends Handler { mCm.unSetOnNewSMS(this); mCm.unSetOnSmsStatus(this); mCm.unSetOnIccSmsFull(this); + mCm.unregisterForOn(this); } protected void finalize() { @@ -370,6 +379,26 @@ public abstract class SMSDispatcher extends Handler { removeMessages(EVENT_ALERT_TIMEOUT, msg.obj); } break; + + case EVENT_REPORT_MEMORY_STATUS_DONE: + ar = (AsyncResult)msg.obj; + if (ar.exception != null) { + mReportMemoryStatusPending = true; + Log.v(TAG, "Memory status report to modem pending : mStorageAvailable = " + + mStorageAvailable); + } else { + mReportMemoryStatusPending = false; + } + break; + + case EVENT_RADIO_ON: + if (mReportMemoryStatusPending) { + Log.v(TAG, "Sending pending memory status report : mStorageAvailable = " + + mStorageAvailable); + mCm.reportSmsMemoryStatus(mStorageAvailable, + obtainMessage(EVENT_REPORT_MEMORY_STATUS_DONE)); + } + break; } } @@ -940,10 +969,10 @@ public abstract class SMSDispatcher extends Handler { public void onReceive(Context context, Intent intent) { if (intent.getAction().equals(Intent.ACTION_DEVICE_STORAGE_LOW)) { mStorageAvailable = false; - mCm.reportSmsMemoryStatus(false, null); + mCm.reportSmsMemoryStatus(false, obtainMessage(EVENT_REPORT_MEMORY_STATUS_DONE)); } else if (intent.getAction().equals(Intent.ACTION_DEVICE_STORAGE_OK)) { mStorageAvailable = true; - mCm.reportSmsMemoryStatus(true, null); + mCm.reportSmsMemoryStatus(true, obtainMessage(EVENT_REPORT_MEMORY_STATUS_DONE)); } else { // Assume the intent is one of the SMS receive intents that // was sent as an ordered broadcast. Check result and ACK. From 9119caa144c8eafdba986002003521af3aedfe67 Mon Sep 17 00:00:00 2001 From: Rodrigo Damazio Bovendorp Date: Mon, 15 Mar 2010 21:19:59 -0300 Subject: [PATCH 2/3] Updated to WMM2010 Change-Id: I5937eed4a8775eae044500552ec81030b93acb18 --- .../android/hardware/GeomagneticField.java | 121 +++++++++--------- 1 file changed, 60 insertions(+), 61 deletions(-) diff --git a/core/java/android/hardware/GeomagneticField.java b/core/java/android/hardware/GeomagneticField.java index b4c04b1c023f4..96fbe77db087b 100644 --- a/core/java/android/hardware/GeomagneticField.java +++ b/core/java/android/hardware/GeomagneticField.java @@ -26,8 +26,9 @@ import java.util.GregorianCalendar; *

This uses the World Magnetic Model produced by the United States National * Geospatial-Intelligence Agency. More details about the model can be found at * http://www.ngdc.noaa.gov/geomag/WMM/DoDWMM.shtml. - * This class currently uses WMM-2005 which is valid until 2010, but should - * produce acceptable results for several years after that. + * This class currently uses WMM-2010 which is valid until 2015, but should + * produce acceptable results for several years after that. Future versions of + * Android may use a newer version of the model. */ public class GeomagneticField { // The magnetic field at a given point, in nonoteslas in geodetic @@ -43,75 +44,73 @@ public class GeomagneticField { // Constants from WGS84 (the coordinate system used by GPS) static private final float EARTH_SEMI_MAJOR_AXIS_KM = 6378.137f; - static private final float EARTH_SEMI_MINOR_AXIS_KM = 6356.7523f; + static private final float EARTH_SEMI_MINOR_AXIS_KM = 6356.7523142f; static private final float EARTH_REFERENCE_RADIUS_KM = 6371.2f; // These coefficients and the formulae used below are from: - // NOAA Technical Report: The US/UK World Magnetic Model for 2005-2010 + // NOAA Technical Report: The US/UK World Magnetic Model for 2010-2015 static private final float[][] G_COEFF = new float[][] { - { 0f }, - { -29556.8f, -1671.7f }, - { -2340.6f, 3046.9f, 1657.0f }, - { 1335.4f, -2305.1f, 1246.7f, 674.0f }, - { 919.8f, 798.1f, 211.3f, -379.4f, 100.0f }, - { -227.4f, 354.6f, 208.7f, -136.5f, -168.3f, -14.1f }, - { 73.2f, 69.7f, 76.7f, -151.2f, -14.9f, 14.6f, -86.3f }, - { 80.1f, -74.5f, -1.4f, 38.5f, 12.4f, 9.5f, 5.7f, 1.8f }, - { 24.9f, 7.7f, -11.6f, -6.9f, -18.2f, 10.0f, 9.2f, -11.6f, -5.2f }, - { 5.6f, 9.9f, 3.5f, -7.0f, 5.1f, -10.8f, -1.3f, 8.8f, -6.7f, -9.1f }, - { -2.3f, -6.3f, 1.6f, -2.6f, 0.0f, 3.1f, 0.4f, 2.1f, 3.9f, -0.1f, -2.3f }, - { 2.8f, -1.6f, -1.7f, 1.7f, -0.1f, 0.1f, -0.7f, 0.7f, 1.8f, 0.0f, 1.1f, 4.1f }, - { -2.4f, -0.4f, 0.2f, 0.8f, -0.3f, 1.1f, -0.5f, 0.4f, -0.3f, -0.3f, -0.1f, - -0.3f, -0.1f } }; + { 0.0f }, + { -29496.6f, -1586.3f }, + { -2396.6f, 3026.1f, 1668.6f }, + { 1340.1f, -2326.2f, 1231.9f, 634.0f }, + { 912.6f, 808.9f, 166.7f, -357.1f, 89.4f }, + { -230.9f, 357.2f, 200.3f, -141.1f, -163.0f, -7.8f }, + { 72.8f, 68.6f, 76.0f, -141.4f, -22.8f, 13.2f, -77.9f }, + { 80.5f, -75.1f, -4.7f, 45.3f, 13.9f, 10.4f, 1.7f, 4.9f }, + { 24.4f, 8.1f, -14.5f, -5.6f, -19.3f, 11.5f, 10.9f, -14.1f, -3.7f }, + { 5.4f, 9.4f, 3.4f, -5.2f, 3.1f, -12.4f, -0.7f, 8.4f, -8.5f, -10.1f }, + { -2.0f, -6.3f, 0.9f, -1.1f, -0.2f, 2.5f, -0.3f, 2.2f, 3.1f, -1.0f, -2.8f }, + { 3.0f, -1.5f, -2.1f, 1.7f, -0.5f, 0.5f, -0.8f, 0.4f, 1.8f, 0.1f, 0.7f, 3.8f }, + { -2.2f, -0.2f, 0.3f, 1.0f, -0.6f, 0.9f, -0.1f, 0.5f, -0.4f, -0.4f, 0.2f, -0.8f, 0.0f } }; static private final float[][] H_COEFF = new float[][] { - { 0f }, - { 0.0f, 5079.8f }, - { 0.0f, -2594.7f, -516.7f }, - { 0.0f, -199.9f, 269.3f, -524.2f }, - { 0.0f, 281.5f, -226.0f, 145.8f, -304.7f }, - { 0.0f, 42.4f, 179.8f, -123.0f, -19.5f, 103.6f }, - { 0.0f, -20.3f, 54.7f, 63.6f, -63.4f, -0.1f, 50.4f }, - { 0.0f, -61.5f, -22.4f, 7.2f, 25.4f, 11.0f, -26.4f, -5.1f }, - { 0.0f, 11.2f, -21.0f, 9.6f, -19.8f, 16.1f, 7.7f, -12.9f, -0.2f }, - { 0.0f, -20.1f, 12.9f, 12.6f, -6.7f, -8.1f, 8.0f, 2.9f, -7.9f, 6.0f }, - { 0.0f, 2.4f, 0.2f, 4.4f, 4.8f, -6.5f, -1.1f, -3.4f, -0.8f, -2.3f, -7.9f }, - { 0.0f, 0.3f, 1.2f, -0.8f, -2.5f, 0.9f, -0.6f, -2.7f, -0.9f, -1.3f, -2.0f, -1.2f }, - { 0.0f, -0.4f, 0.3f, 2.4f, -2.6f, 0.6f, 0.3f, 0.0f, 0.0f, 0.3f, -0.9f, -0.4f, - 0.8f } }; + { 0.0f }, + { 0.0f, 4944.4f }, + { 0.0f, -2707.7f, -576.1f }, + { 0.0f, -160.2f, 251.9f, -536.6f }, + { 0.0f, 286.4f, -211.2f, 164.3f, -309.1f }, + { 0.0f, 44.6f, 188.9f, -118.2f, 0.0f, 100.9f }, + { 0.0f, -20.8f, 44.1f, 61.5f, -66.3f, 3.1f, 55.0f }, + { 0.0f, -57.9f, -21.1f, 6.5f, 24.9f, 7.0f, -27.7f, -3.3f }, + { 0.0f, 11.0f, -20.0f, 11.9f, -17.4f, 16.7f, 7.0f, -10.8f, 1.7f }, + { 0.0f, -20.5f, 11.5f, 12.8f, -7.2f, -7.4f, 8.0f, 2.1f, -6.1f, 7.0f }, + { 0.0f, 2.8f, -0.1f, 4.7f, 4.4f, -7.2f, -1.0f, -3.9f, -2.0f, -2.0f, -8.3f }, + { 0.0f, 0.2f, 1.7f, -0.6f, -1.8f, 0.9f, -0.4f, -2.5f, -1.3f, -2.1f, -1.9f, -1.8f }, + { 0.0f, -0.9f, 0.3f, 2.1f, -2.5f, 0.5f, 0.6f, 0.0f, 0.1f, 0.3f, -0.9f, -0.2f, 0.9f } }; static private final float[][] DELTA_G = new float[][] { - { 0f }, - { 8.0f, 10.6f }, - { -15.1f, -7.8f, -0.8f }, - { 0.4f, -2.6f, -1.2f, -6.5f }, - { -2.5f, 2.8f, -7.0f, 6.2f, -3.8f }, - { -2.8f, 0.7f, -3.2f, -1.1f, 0.1f, -0.8f }, - { -0.7f, 0.4f, -0.3f, 2.3f, -2.1f, -0.6f, 1.4f }, - { 0.2f, -0.1f, -0.3f, 1.1f, 0.6f, 0.5f, -0.4f, 0.6f }, - { 0.1f, 0.3f, -0.4f, 0.3f, -0.3f, 0.2f, 0.4f, -0.7f, 0.4f }, - { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }, - { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }, - { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }, - { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f } }; + { 0.0f }, + { 11.6f, 16.5f }, + { -12.1f, -4.4f, 1.9f }, + { 0.4f, -4.1f, -2.9f, -7.7f }, + { -1.8f, 2.3f, -8.7f, 4.6f, -2.1f }, + { -1.0f, 0.6f, -1.8f, -1.0f, 0.9f, 1.0f }, + { -0.2f, -0.2f, -0.1f, 2.0f, -1.7f, -0.3f, 1.7f }, + { 0.1f, -0.1f, -0.6f, 1.3f, 0.4f, 0.3f, -0.7f, 0.6f }, + { -0.1f, 0.1f, -0.6f, 0.2f, -0.2f, 0.3f, 0.3f, -0.6f, 0.2f }, + { 0.0f, -0.1f, 0.0f, 0.3f, -0.4f, -0.3f, 0.1f, -0.1f, -0.4f, -0.2f }, + { 0.0f, 0.0f, -0.1f, 0.2f, 0.0f, -0.1f, -0.2f, 0.0f, -0.1f, -0.2f, -0.2f }, + { 0.0f, 0.0f, 0.0f, 0.1f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, -0.1f, 0.0f }, + { 0.0f, 0.0f, 0.1f, 0.1f, -0.1f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, -0.1f, 0.1f } }; static private final float[][] DELTA_H = new float[][] { - { 0f }, - { 0.0f, -20.9f }, - { 0.0f, -23.2f, -14.6f }, - { 0.0f, 5.0f, -7.0f, -0.6f }, - { 0.0f, 2.2f, 1.6f, 5.8f, 0.1f }, - { 0.0f, 0.0f, 1.7f, 2.1f, 4.8f, -1.1f }, - { 0.0f, -0.6f, -1.9f, -0.4f, -0.5f, -0.3f, 0.7f }, - { 0.0f, 0.6f, 0.4f, 0.2f, 0.3f, -0.8f, -0.2f, 0.1f }, - { 0.0f, -0.2f, 0.1f, 0.3f, 0.4f, 0.1f, -0.2f, 0.4f, 0.4f }, - { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }, - { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }, - { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }, - { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f } }; + { 0.0f }, + { 0.0f, -25.9f }, + { 0.0f, -22.5f, -11.8f }, + { 0.0f, 7.3f, -3.9f, -2.6f }, + { 0.0f, 1.1f, 2.7f, 3.9f, -0.8f }, + { 0.0f, 0.4f, 1.8f, 1.2f, 4.0f, -0.6f }, + { 0.0f, -0.2f, -2.1f, -0.4f, -0.6f, 0.5f, 0.9f }, + { 0.0f, 0.7f, 0.3f, -0.1f, -0.1f, -0.8f, -0.3f, 0.3f }, + { 0.0f, -0.1f, 0.2f, 0.4f, 0.4f, 0.1f, -0.1f, 0.4f, 0.3f }, + { 0.0f, 0.0f, -0.2f, 0.0f, -0.1f, 0.1f, 0.0f, -0.2f, 0.3f, 0.2f }, + { 0.0f, 0.1f, -0.1f, 0.0f, -0.1f, -0.1f, 0.0f, -0.1f, -0.2f, 0.0f, -0.1f }, + { 0.0f, 0.0f, 0.1f, 0.0f, 0.1f, 0.0f, 0.1f, 0.0f, -0.1f, -0.1f, 0.0f, -0.1f }, + { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.1f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f } }; static private final long BASE_TIME = - new GregorianCalendar(2005, 1, 1).getTimeInMillis(); + new GregorianCalendar(2010, 1, 1).getTimeInMillis(); // The ratio between the Gauss-normalized associated Legendre functions and // the Schmid quasi-normalized ones. Compute these once staticly since they @@ -191,7 +190,7 @@ public class GeomagneticField { // We now compute the magnetic field strength given the geocentric // location. The magnetic field is the derivative of the potential // function defined by the model. See NOAA Technical Report: The US/UK - // World Magnetic Model for 2005-2010 for the derivation. + // World Magnetic Model for 2010-2015 for the derivation. float gcX = 0.0f; // Geocentric northwards component. float gcY = 0.0f; // Geocentric eastwards component. float gcZ = 0.0f; // Geocentric downwards component. @@ -406,4 +405,4 @@ public class GeomagneticField { } return schmidtQuasiNorm; } -} \ No newline at end of file +} From ed0d1ab2864a62793ec9c0797251e11cec7e850c Mon Sep 17 00:00:00 2001 From: Johannes Carlsson Date: Mon, 8 Mar 2010 10:19:31 +0100 Subject: [PATCH 3/3] Everytime Bluetooth was turned off two file descriptors were not closed Using close instead of shutdown on the file descriptors and only clear the file descriptor that was closed. If both file descriptors are cleared the thread will not be able to close it. --- core/jni/android_server_BluetoothEventLoop.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/core/jni/android_server_BluetoothEventLoop.cpp b/core/jni/android_server_BluetoothEventLoop.cpp index d2e94546cbafe..fdc97eeb889e9 100644 --- a/core/jni/android_server_BluetoothEventLoop.cpp +++ b/core/jni/android_server_BluetoothEventLoop.cpp @@ -564,7 +564,10 @@ static void *eventLoopMain(void *ptr) { NULL, NULL, NULL, NULL, NULL); tearDownEventLoop(nat); nat->vm->DetachCurrentThread(); - shutdown(nat->controlFdR,SHUT_RDWR); + + int fd = nat->controlFdR; + nat->controlFdR = 0; + close(fd); return NULL; } case EVENT_LOOP_ADD: @@ -653,9 +656,12 @@ static jboolean startEventLoopNative(JNIEnv *env, jobject object) { done: if (JNI_FALSE == result) { - if (nat->controlFdW || nat->controlFdR) { - shutdown(nat->controlFdW, SHUT_RDWR); + if (nat->controlFdW) { + close(nat->controlFdW); nat->controlFdW = 0; + } + if (nat->controlFdR) { + close(nat->controlFdR); nat->controlFdR = 0; } if (nat->me) env->DeleteGlobalRef(nat->me); @@ -692,9 +698,10 @@ static void stopEventLoopNative(JNIEnv *env, jobject object) { nat->watchData = NULL; nat->pollDataSize = 0; nat->pollMemberCount = 0; - shutdown(nat->controlFdW, SHUT_RDWR); + + int fd = nat->controlFdW; nat->controlFdW = 0; - nat->controlFdR = 0; + close(fd); } pthread_mutex_unlock(&(nat->thread_mutex)); #endif // HAVE_BLUETOOTH