This commit is contained in:
Max Lv
2015-11-21 11:59:05 +08:00
parent e636b9f78e
commit ff23bae671
6 changed files with 46 additions and 8 deletions
@@ -44,6 +44,9 @@ import java.util.{Timer, TimerTask}
import android.app.Notification
import android.content.Context
import android.os.{Handler, RemoteCallbackList}
import android.util.Log
import com.github.shadowsocks.database.{Profile, ProfileManager}
import com.github.shadowsocks.aidl.{Config, IShadowsocksService, IShadowsocksServiceCallback}
import com.github.shadowsocks.utils.{State, TrafficMonitor, TrafficMonitorThread}
@@ -127,6 +130,23 @@ trait BaseService {
}
}
def updateTrafficTotal(tx: Long, rx: Long) {
val handler = new Handler(getContext.getMainLooper)
handler.post(() => {
if (config != null) {
ShadowsocksApplication.profileManager.getProfile(config.profileId) match {
case Some(profile) => {
profile.tx += tx;
profile.rx += rx;
Log.d("test", profile.tx + " " + profile.rx)
ShadowsocksApplication.profileManager.updateProfile(profile)
}
case None => // Ignore
}
}
})
}
def clearChildProcessStream()
def stopBackgroundService()
def getServiceMode: Int
@@ -143,7 +163,7 @@ trait BaseService {
changeState(s, null)
}
def updateTraffic(txRate: String, rxRate: String, txTotal: String, rxTotal: String) {
def updateTrafficRate(txRate: String, rxRate: String, txTotal: String, rxTotal: String) {
val handler = new Handler(getContext.getMainLooper)
handler.post(() => {
if (callbackCount > 0) {