save history in baresipservice

clear global vars at quit
This commit is contained in:
Juha Heinanen
2018-06-23 14:34:28 +03:00
parent e8a1f5864b
commit 92c13cce4f
2 changed files with 4 additions and 14 deletions

View File

@ -117,16 +117,6 @@ class BaresipService: Service() {
BaresipService.IS_SERVICE_RUNNING = true
registerReceiver(nr, IntentFilter("android.net.conn.CONNECTIVITY_CHANGE"))
showNotification()
val handler = Handler()
val delay = 1000 * 600L
handler.postDelayed(object : Runnable {
override fun run() {
Log.d(LOG_TAG, "Handler based registration")
UserAgent.register(MainActivity.uas)
handler.postDelayed(this, delay)
}
}, delay)
}
"UpdateNotification" -> {
@ -136,6 +126,10 @@ class BaresipService: Service() {
"Stop" -> {
Log.i(LOG_TAG, "Received Stop Foreground Intent")
HistoryActivity.saveHistory()
MainActivity.uas.clear()
MainActivity.images.clear()
MainActivity.history.clear()
baresipStop()
BaresipService.IS_SERVICE_RUNNING = false
unregisterReceiver(nr)

View File

@ -505,7 +505,6 @@ class MainActivity : AppCompatActivity() {
}
historyButton.visibility = View.VISIBLE
}
// nm.cancel(INCOMING_ID)
if (!call.hasHistory) {
if (History.aorHistory(history, aor) > HISTORY_SIZE)
History.aorRemoveHistory(history, aor)
@ -557,7 +556,6 @@ class MainActivity : AppCompatActivity() {
Log.d("Baresip", "Resumed")
imm.hideSoftInputFromWindow(callee.windowToken, 0)
visible = true
// nm.cancel(INCOMING_ID)
}
override fun onBackPressed() {
@ -613,11 +611,9 @@ class MainActivity : AppCompatActivity() {
R.id.quit -> {
Log.d("Baresip", "Quiting")
if (BaresipService.IS_SERVICE_RUNNING) {
HistoryActivity.saveHistory()
baresipService.setAction("Stop");
startService(baresipService)
}
// nm.cancelAll()
finish()
// System.exit(0)
return true