fix proximity sensor crashes while exiting

This commit is contained in:
Jehan Monnier 2010-03-22 12:03:53 +01:00
parent e8fa8e493c
commit cf93c422b5
3 changed files with 7 additions and 7 deletions

View file

@ -3,9 +3,9 @@
package="org.linphone" package="org.linphone"
android:versionCode="1" android:versionCode="1"
android:versionName="1.0"> android:versionName="1.0">
<uses-sdk android:minSdkVersion="3" />
<application android:icon="@drawable/linphone2" android:label="@string/app_name" android:debuggable = "true"> <application android:icon="@drawable/linphone2" android:label="@string/app_name" android:debuggable = "true">
<uses-sdk android:minSdkVersion="3" />
<activity android:name=".LinphoneActivity" <activity android:name=".LinphoneActivity"
android:label="@string/app_name" android:label="@string/app_name"

View file

@ -21,9 +21,7 @@ package org.linphone;
import org.linphone.core.LinphoneAddress; import org.linphone.core.LinphoneAddress;
import org.linphone.core.LinphoneCore; import org.linphone.core.LinphoneCore;
import org.linphone.core.LinphoneCoreException; import org.linphone.core.LinphoneCoreException;
import org.linphone.core.LinphoneCoreFactory;
import org.linphone.core.LinphoneCoreListener; import org.linphone.core.LinphoneCoreListener;
import org.linphone.core.LinphoneProxyConfig;
import org.linphone.core.LinphoneCore.GeneralState; import org.linphone.core.LinphoneCore.GeneralState;
import android.app.Activity; import android.app.Activity;
@ -86,7 +84,7 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
/** /**
* *
* @return nul if not ready yet * @return null if not ready yet
*/ */
public static DialerActivity getDialer() { public static DialerActivity getDialer() {
if (theDialer == null) { if (theDialer == null) {
@ -351,7 +349,6 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
break; break;
} }
case GSTATE_CALL_ERROR: { case GSTATE_CALL_ERROR: {
Toast toast = Toast.makeText(this Toast toast = Toast.makeText(this
,String.format(getString(R.string.call_error),lc.getRemoteAddress()) ,String.format(getString(R.string.call_error),lc.getRemoteAddress())
, Toast.LENGTH_LONG); , Toast.LENGTH_LONG);

View file

@ -139,6 +139,9 @@ public class LinphoneActivity extends TabActivity implements SensorEventListener
@Override @Override
protected void onDestroy() { protected void onDestroy() {
super.onDestroy(); super.onDestroy();
if (isFinishing()) {
if (mSensorManager!=null) mSensorManager.unregisterListener(this);
}
} }
@Override @Override
@ -146,8 +149,6 @@ public class LinphoneActivity extends TabActivity implements SensorEventListener
// Inflate the currently selected menu XML resource. // Inflate the currently selected menu XML resource.
MenuInflater inflater = getMenuInflater(); MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.linphone_activity_menu, menu); inflater.inflate(R.menu.linphone_activity_menu, menu);
return true; return true;
} }
@ -207,6 +208,8 @@ public class LinphoneActivity extends TabActivity implements SensorEventListener
} }
public void onSensorChanged(SensorEvent event) { public void onSensorChanged(SensorEvent event) {
if (LinphoneService.isready() == false) return; //nop nothing to do
WindowManager.LayoutParams lAttrs =getWindow().getAttributes(); WindowManager.LayoutParams lAttrs =getWindow().getAttributes();
if (LinphoneService.instance().getLinphoneCore().isIncall() && event.values[0] == 0) { if (LinphoneService.instance().getLinphoneCore().isIncall() && event.values[0] == 0) {
lAttrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN; lAttrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;