Fix chat storage issue

This commit is contained in:
Sylvain Berfini 2013-05-07 11:31:00 +02:00
parent 40aee4de97
commit 39233976a7
2 changed files with 12 additions and 15 deletions

View file

@ -106,7 +106,6 @@ public class LinphoneActivity extends FragmentActivity implements
private FragmentsAvailable currentFragment, nextFragment; private FragmentsAvailable currentFragment, nextFragment;
private Fragment dialerFragment, messageListenerFragment, messageListFragment, friendStatusListenerFragment; private Fragment dialerFragment, messageListenerFragment, messageListFragment, friendStatusListenerFragment;
private SavedState dialerSavedState; private SavedState dialerSavedState;
private ChatStorage chatStorage;
private boolean preferLinphoneContacts = false, isAnimationDisabled = false, isContactPresenceDisabled = true; private boolean preferLinphoneContacts = false, isAnimationDisabled = false, isContactPresenceDisabled = true;
private Handler mHandler = new Handler(); private Handler mHandler = new Handler();
private List<Contact> contactList, sipContactList; private List<Contact> contactList, sipContactList;
@ -1170,10 +1169,10 @@ public class LinphoneActivity extends FragmentActivity implements
} }
public ChatStorage getChatStorage() { public ChatStorage getChatStorage() {
if (chatStorage == null) { if (LinphoneManager.getInstance().chatStorage == null) {
chatStorage = new ChatStorage(this); return new ChatStorage(this);
} }
return chatStorage; return LinphoneManager.getInstance().chatStorage;
} }
public void addContact(String displayName, String sipUri) public void addContact(String displayName, String sipUri)
@ -1255,11 +1254,6 @@ public class LinphoneActivity extends FragmentActivity implements
prepareContactsInBackground(); prepareContactsInBackground();
if (chatStorage != null) {
chatStorage.close();
}
chatStorage = new ChatStorage(this);
updateMissedChatCount(); updateMissedChatCount();
displayMissedCalls(LinphoneManager.getLc().getMissedCallsCount()); displayMissedCalls(LinphoneManager.getLc().getMissedCallsCount());
@ -1284,11 +1278,6 @@ public class LinphoneActivity extends FragmentActivity implements
@Override @Override
protected void onDestroy() { protected void onDestroy() {
LinphoneManager.removeListener(this); LinphoneManager.removeListener(this);
if (chatStorage != null) {
chatStorage.close();
chatStorage = null;
}
if (mOrientationHelper != null) { if (mOrientationHelper != null) {
mOrientationHelper.disable(); mOrientationHelper.disable();

View file

@ -157,6 +157,8 @@ public final class LinphoneManager implements LinphoneCoreListener {
private BroadcastReceiver bluetoothReiceiver = new BluetoothManager(); private BroadcastReceiver bluetoothReiceiver = new BluetoothManager();
public boolean isBluetoothScoConnected; public boolean isBluetoothScoConnected;
public boolean isUsingBluetoothAudioRoute; public boolean isUsingBluetoothAudioRoute;
public ChatStorage chatStorage;
private static List<LinphoneSimpleListener> simpleListeners = new ArrayList<LinphoneSimpleListener>(); private static List<LinphoneSimpleListener> simpleListeners = new ArrayList<LinphoneSimpleListener>();
public static void addListener(LinphoneSimpleListener listener) { public static void addListener(LinphoneSimpleListener listener) {
@ -188,6 +190,8 @@ public final class LinphoneManager implements LinphoneCoreListener {
mPowerManager = (PowerManager) c.getSystemService(Context.POWER_SERVICE); mPowerManager = (PowerManager) c.getSystemService(Context.POWER_SERVICE);
mConnectivityManager = (ConnectivityManager) c.getSystemService(Context.CONNECTIVITY_SERVICE); mConnectivityManager = (ConnectivityManager) c.getSystemService(Context.CONNECTIVITY_SERVICE);
mR = c.getResources(); mR = c.getResources();
chatStorage = new ChatStorage(mServiceContext);
} }
private static final int LINPHONE_VOLUME_STREAM = STREAM_VOICE_CALL; private static final int LINPHONE_VOLUME_STREAM = STREAM_VOICE_CALL;
@ -959,6 +963,11 @@ public final class LinphoneManager implements LinphoneCoreListener {
@TargetApi(Build.VERSION_CODES.HONEYCOMB) @TargetApi(Build.VERSION_CODES.HONEYCOMB)
private void doDestroy() { private void doDestroy() {
if (chatStorage != null) {
chatStorage.close();
chatStorage = null;
}
try { try {
if (Version.sdkAboveOrEqual(Version.API11_HONEYCOMB_30)) if (Version.sdkAboveOrEqual(Version.API11_HONEYCOMB_30))
mBluetoothAdapter.closeProfileProxy(BluetoothProfile.HEADSET, mBluetoothHeadset); mBluetoothAdapter.closeProfileProxy(BluetoothProfile.HEADSET, mBluetoothHeadset);
@ -1099,7 +1108,6 @@ public final class LinphoneManager implements LinphoneCoreListener {
} }
LinphoneAddress from = message.getFrom(); LinphoneAddress from = message.getFrom();
ChatStorage chatStorage = new ChatStorage(mServiceContext);
String textMessage = message.getText(); String textMessage = message.getText();
String url = message.getExternalBodyUrl(); String url = message.getExternalBodyUrl();