Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
bannedbook committed Apr 23, 2020
1 parent e7e793a commit 47fa793
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 23 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ buildscript {
junitVersion = '4.13'
androidTestVersion = '1.2.0'
androidEspressoVersion = '3.2.0'
versionCode = 5000678
versionName = '5.0.6.4-nightly'
versionCode = 5000688
versionName = '5.0.6.5-nightly'
resConfigs = ['ar', 'es', 'fa', 'fr', 'ja', 'ko', 'ru', 'tr', 'zh-rCN', 'zh-rTW']
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ object ProfileManager {
* Note: It's caller's responsibility to update DirectBoot profile if necessary.
*/
@Throws(SQLException::class)
fun updateProfile(profile: Profile) = check(PrivateDatabase.profileDao.update(profile) == 1)
fun updateProfile(profile: Profile) = try {check(PrivateDatabase.profileDao.update(profile) == 1)}catch (t:Throwable){printLog(t)}

@Throws(IOException::class)
fun getProfile(id: Long): Profile? = try {
Expand Down
2 changes: 2 additions & 0 deletions core/src/main/java/com/github/shadowsocks/utils/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import android.os.Build
import android.system.ErrnoException
import android.system.Os
import android.system.OsConstants
import android.util.Log
import android.util.TypedValue
import androidx.annotation.AttrRes
import androidx.preference.Preference
Expand Down Expand Up @@ -142,6 +143,7 @@ val Intent.datas get() = listOfNotNull(data) + (clipData?.asIterable()?.mapNotNu

fun printLog(t: Throwable) {
Crashlytics.logException(t)
Log.e("Utils","printLog",t)
t.printStackTrace()
}

Expand Down
2 changes: 1 addition & 1 deletion gitupdate.bat
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ git pull origin master
git add -A
git commit -m "update"
git push origin master
git tag -a v5.0.6.4 -m "release v5.0.6.4"
git tag -a v5.0.6.5 -m "release v5.0.6.5"
git push origin --tags
pause
20 changes: 13 additions & 7 deletions mobile/src/main/java/com/github/shadowsocks/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import com.github.shadowsocks.preference.OnPreferenceDataStoreChangeListener
import com.github.shadowsocks.subscription.SubscriptionFragment
import com.github.shadowsocks.utils.Key
import com.github.shadowsocks.utils.SingleInstanceActivity
import com.github.shadowsocks.utils.printLog
import com.github.shadowsocks.widget.ListHolderListener
import com.github.shadowsocks.widget.ServiceButton
import com.github.shadowsocks.widget.StatsBar
Expand Down Expand Up @@ -124,14 +125,19 @@ class MainActivity : AppCompatActivity(), ShadowsocksConnection.Callback, OnPref
stateListener?.invoke(state)
}

private fun toggle() = when {
state.canStop -> Core.stopService()
DataStore.serviceMode == Key.modeVpn -> {
val intent = VpnService.prepare(this)
if (intent != null) startActivityForResult(intent, REQUEST_CONNECT)
else onActivityResult(REQUEST_CONNECT, Activity.RESULT_OK, null)
private fun toggle() = try {
when {
state.canStop -> Core.stopService()
DataStore.serviceMode == Key.modeVpn -> {
val intent = VpnService.prepare(this)
if (intent != null) startActivityForResult(intent, REQUEST_CONNECT)
else onActivityResult(REQUEST_CONNECT, Activity.RESULT_OK, null)
}
else -> Core.startService()
}
else -> Core.startService()
}
catch (t:Throwable){
printLog(t)
}

private val handler = Handler()
Expand Down
26 changes: 14 additions & 12 deletions mobile/src/main/java/com/github/shadowsocks/ProfilesFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -645,17 +645,19 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener {
profilesAdapter.notifyDataSetChanged()

for (k in 0 until profilesAdapter.profiles.size) {
Log.e("tcping","$k")
GlobalScope.launch {
profilesAdapter.profiles[k].elapsed = tcping(profilesAdapter.profiles[k].host, profilesAdapter.profiles[k].remotePort)
ProfileManager.updateProfile(profilesAdapter.profiles[k])
Log.e("tcping","$k - "+profilesAdapter.profiles[k].elapsed)
activity?.runOnUiThread() {
Log.e("tcping","$k - update")
profilesAdapter.refreshId(profilesAdapter.profiles[k].id)
try {
Log.e("tcping", "$k")
GlobalScope.launch {
profilesAdapter.profiles[k].elapsed = tcping(profilesAdapter.profiles[k].host, profilesAdapter.profiles[k].remotePort)
ProfileManager.updateProfile(profilesAdapter.profiles[k])
Log.e("tcping", "$k - " + profilesAdapter.profiles[k].elapsed)
activity?.runOnUiThread() {
Log.e("tcping", "$k - update")
profilesAdapter.refreshId(profilesAdapter.profiles[k].id)
}
}
}

catch(e:IndexOutOfBoundsException){}
}
true
}
Expand Down Expand Up @@ -710,9 +712,9 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener {
Core.stopService()
var isProxyStarted=false
for (k in 0 until profilesAdapter.profiles.size) {
if(testInvalidOnly && profilesAdapter.profiles[k].elapsed>0)continue
Log.e("real_ping_all",k.toString())
try {
if(testInvalidOnly && profilesAdapter.profiles[k].elapsed>0)continue
Log.e("real_ping_all",k.toString())
profilesAdapter.profiles[k].elapsed=-2
val old = DataStore.profileId
Core.switchProfile(profilesAdapter.profiles[k].id)
Expand Down Expand Up @@ -766,7 +768,7 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener {
profilesAdapter.profiles.clear()
profilesAdapter.profiles.addAll(list)
profilesAdapter.notifyDataSetChanged()
Core.alertMessage(getString(R.string.toast_test_ended),activity)
try{Core.alertMessage(activity.getString(R.string.toast_test_ended),activity)}catch (t:Throwable){}
}
}
}
Expand Down

0 comments on commit 47fa793

Please sign in to comment.