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
@@ -117,16 +117,6 @@ class BaresipService: Service() {
BaresipService.IS_SERVICE_RUNNING = true BaresipService.IS_SERVICE_RUNNING = true
registerReceiver(nr, IntentFilter("android.net.conn.CONNECTIVITY_CHANGE")) registerReceiver(nr, IntentFilter("android.net.conn.CONNECTIVITY_CHANGE"))
showNotification() 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" -> { "UpdateNotification" -> {
@@ -136,6 +126,10 @@ class BaresipService: Service() {
"Stop" -> { "Stop" -> {
Log.i(LOG_TAG, "Received Stop Foreground Intent") Log.i(LOG_TAG, "Received Stop Foreground Intent")
HistoryActivity.saveHistory()
MainActivity.uas.clear()
MainActivity.images.clear()
MainActivity.history.clear()
baresipStop() baresipStop()
BaresipService.IS_SERVICE_RUNNING = false BaresipService.IS_SERVICE_RUNNING = false
unregisterReceiver(nr) unregisterReceiver(nr)
@@ -505,7 +505,6 @@ class MainActivity : AppCompatActivity() {
} }
historyButton.visibility = View.VISIBLE historyButton.visibility = View.VISIBLE
} }
// nm.cancel(INCOMING_ID)
if (!call.hasHistory) { if (!call.hasHistory) {
if (History.aorHistory(history, aor) > HISTORY_SIZE) if (History.aorHistory(history, aor) > HISTORY_SIZE)
History.aorRemoveHistory(history, aor) History.aorRemoveHistory(history, aor)
@@ -557,7 +556,6 @@ class MainActivity : AppCompatActivity() {
Log.d("Baresip", "Resumed") Log.d("Baresip", "Resumed")
imm.hideSoftInputFromWindow(callee.windowToken, 0) imm.hideSoftInputFromWindow(callee.windowToken, 0)
visible = true visible = true
// nm.cancel(INCOMING_ID)
} }
override fun onBackPressed() { override fun onBackPressed() {
@@ -613,11 +611,9 @@ class MainActivity : AppCompatActivity() {
R.id.quit -> { R.id.quit -> {
Log.d("Baresip", "Quiting") Log.d("Baresip", "Quiting")
if (BaresipService.IS_SERVICE_RUNNING) { if (BaresipService.IS_SERVICE_RUNNING) {
HistoryActivity.saveHistory()
baresipService.setAction("Stop"); baresipService.setAction("Stop");
startService(baresipService) startService(baresipService)
} }
// nm.cancelAll()
finish() finish()
// System.exit(0) // System.exit(0)
return true return true