update linphone factory to handle LinphoneAddress parsing error

This commit is contained in:
Jehan Monnier 2013-05-22 16:04:59 +02:00
parent a2a5cc6ad4
commit c461dd3f1e
10 changed files with 57 additions and 15 deletions

View file

@ -20,7 +20,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
import java.util.List;
import org.linphone.core.LinphoneAddress;
import org.linphone.core.LinphoneCoreException;
import org.linphone.core.LinphoneCoreFactory;
import org.linphone.mediastream.Log;
import android.os.Bundle;
import android.os.Handler;
@ -234,7 +236,13 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte
view.setTag(contact);
int unreadMessagesCount = LinphoneActivity.instance().getChatStorage().getUnreadMessageCount(contact);
LinphoneAddress address = LinphoneCoreFactory.instance().createLinphoneAddress(contact);
LinphoneAddress address;
try {
address = LinphoneCoreFactory.instance().createLinphoneAddress(contact);
} catch (LinphoneCoreException e) {
Log.e("Chat view cannot parse address",e);
return view;
}
LinphoneUtils.findUriPictureOfContactAndSetDisplayName(address, view.getContext().getContentResolver());
List<ChatMessage> messages = LinphoneActivity.instance().getChatMessages(contact);

View file

@ -21,7 +21,9 @@ import java.text.SimpleDateFormat;
import java.util.Calendar;
import org.linphone.core.LinphoneAddress;
import org.linphone.core.LinphoneCoreException;
import org.linphone.core.LinphoneCoreFactory;
import org.linphone.mediastream.Log;
import org.linphone.ui.AvatarWithShadow;
import android.annotation.SuppressLint;
@ -104,7 +106,13 @@ public class HistoryDetailFragment extends Fragment implements OnClickListener {
time.setText(callTime == null ? "" : callTime);
date.setText(timestampToHumanDate(callDate));
LinphoneAddress lAddress = LinphoneCoreFactory.instance().createLinphoneAddress(sipUri);
LinphoneAddress lAddress;
try {
lAddress = LinphoneCoreFactory.instance().createLinphoneAddress(sipUri);
} catch (LinphoneCoreException e) {
Log.e("History details error",e);
return;
}
LinphoneUtils.findUriPictureOfContactAndSetDisplayName(lAddress, view.getContext().getContentResolver());
String displayName = lAddress.getDisplayName();
if (displayName != null) {

View file

@ -1270,7 +1270,13 @@ public class InCallActivity extends FragmentActivity implements
private void displayCall(Resources resources, LinphoneCall call, int index) {
String sipUri = call.getRemoteAddress().asStringUriOnly();
LinphoneAddress lAddress = LinphoneCoreFactory.instance().createLinphoneAddress(sipUri);
LinphoneAddress lAddress;
try {
lAddress = LinphoneCoreFactory.instance().createLinphoneAddress(sipUri);
} catch (LinphoneCoreException e) {
Log.e("Incall activity cannot parse remote address",e);
lAddress= LinphoneCoreFactory.instance().createLinphoneAddress("uknown","unknown","unkonown");
}
// Control Row
LinearLayout callView = (LinearLayout) inflater.inflate(R.layout.active_call_control_row, container, false);

View file

@ -430,7 +430,13 @@ public class LinphoneActivity extends FragmentActivity implements
}
public void displayHistoryDetail(String sipUri, LinphoneCallLog log) {
LinphoneAddress lAddress = LinphoneCoreFactory.instance().createLinphoneAddress(sipUri);
LinphoneAddress lAddress;
try {
lAddress = LinphoneCoreFactory.instance().createLinphoneAddress(sipUri);
} catch (LinphoneCoreException e) {
Log.e("Cannot display history details",e);
return;
}
Uri uri = LinphoneUtils.findUriPictureOfContactAndSetDisplayName(lAddress, getContentResolver());
String displayName = lAddress.getDisplayName();
@ -517,7 +523,13 @@ public class LinphoneActivity extends FragmentActivity implements
return;
}
LinphoneAddress lAddress = LinphoneCoreFactory.instance().createLinphoneAddress(sipUri);
LinphoneAddress lAddress;
try {
lAddress = LinphoneCoreFactory.instance().createLinphoneAddress(sipUri);
} catch (LinphoneCoreException e) {
Log.e("Cannot display chat",e);
return;
}
Uri uri = LinphoneUtils.findUriPictureOfContactAndSetDisplayName(lAddress, getContentResolver());
String displayName = lAddress.getDisplayName();
String pictureUri = uri == null ? null : uri.toString();

View file

@ -323,7 +323,13 @@ public final class LinphoneService extends Service implements LinphoneServiceLis
mMsgNotifCount++;
}
Uri pictureUri = LinphoneUtils.findUriPictureOfContactAndSetDisplayName(LinphoneCoreFactoryImpl.instance().createLinphoneAddress(fromSipUri), getContentResolver());
Uri pictureUri;
try {
pictureUri = LinphoneUtils.findUriPictureOfContactAndSetDisplayName(LinphoneCoreFactoryImpl.instance().createLinphoneAddress(fromSipUri), getContentResolver());
} catch (LinphoneCoreException e1) {
Log.e("Cannot parse from address",e1);
pictureUri=null;
}
Bitmap bm = null;
try {
bm = MediaStore.Images.Media.getBitmap(getContentResolver(), pictureUri);

View file

@ -34,6 +34,7 @@ import org.linphone.core.LinphoneAddress;
import org.linphone.core.LinphoneCall;
import org.linphone.core.LinphoneCall.State;
import org.linphone.core.LinphoneCore;
import org.linphone.core.LinphoneCoreException;
import org.linphone.core.LinphoneCoreFactory;
import org.linphone.mediastream.Log;
import org.linphone.mediastream.Version;
@ -71,7 +72,12 @@ public final class LinphoneUtils {
//private static final String strictSipAddressRegExp = "^sip:(\\+)?[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\\.-][a-z0-9]+)*)+\\.[a-z]{2,}$";
public static boolean isSipAddress(String numberOrAddress) {
return LinphoneCoreFactory.instance().createLinphoneAddress(numberOrAddress) != null;
try {
LinphoneCoreFactory.instance().createLinphoneAddress(numberOrAddress);
return true;
} catch (LinphoneCoreException e) {
return false;
}
}
public static boolean isStrictSipAddress(String numberOrAddress) {

@ -1 +1 @@
Subproject commit 249c4d986954243e03a4c3e7044a772aca27090c
Subproject commit da87ffc3e63942ee29ac00da674afdc216e19774

View file

@ -4,11 +4,7 @@
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry kind="lib" path="libs/robotium-solo-3.6.jar">
<attributes>
<attribute name="javadoc_location" value="jar:platform:/resource/Linphone-Android-NewUI-Tests/libs/robotium-solo-3.6-javadoc.jar!/"/>
</attributes>
</classpathentry>
<classpathentry combineaccessrules="false" kind="src" path="/linphone-android-private"/>
<classpathentry kind="lib" path="libs/robotium-solo-4.1.jar"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>

View file

@ -17,7 +17,7 @@ import android.widget.ListView;
import com.jayway.android.robotium.solo.Solo;
public class AudioAndVideoCodecsTest extends ActivityInstrumentationTestCase2<LinphoneActivity> {
private static final String sipAdressToCall = "cotcot@sip.linphone.org";
private static final String sipAdressToCall = "macmini@sip.linphone.org";
private Solo solo;
@SuppressWarnings("deprecation")

View file

@ -14,7 +14,7 @@ import android.widget.ListView;
import com.jayway.android.robotium.solo.Solo;
public class SignalingTest extends ActivityInstrumentationTestCase2<LinphoneActivity> {
private static final String sipAdressToCall = "cotcot@sip.linphone.org";
private static final String sipAdressToCall = "macmini@sip.linphone.org";
private Solo solo;
@SuppressWarnings("deprecation")