diff --git a/build.gradle b/build.gradle index 79149a8..9ea07e1 100644 --- a/build.gradle +++ b/build.gradle @@ -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'] } diff --git a/core/src/main/java/com/github/shadowsocks/database/ProfileManager.kt b/core/src/main/java/com/github/shadowsocks/database/ProfileManager.kt index ff8ba0c..36ea048 100644 --- a/core/src/main/java/com/github/shadowsocks/database/ProfileManager.kt +++ b/core/src/main/java/com/github/shadowsocks/database/ProfileManager.kt @@ -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 { diff --git a/core/src/main/java/com/github/shadowsocks/utils/Utils.kt b/core/src/main/java/com/github/shadowsocks/utils/Utils.kt index d0582dc..4f44531 100644 --- a/core/src/main/java/com/github/shadowsocks/utils/Utils.kt +++ b/core/src/main/java/com/github/shadowsocks/utils/Utils.kt @@ -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 @@ -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() } diff --git a/gitupdate.bat b/gitupdate.bat index b7c808d..e6a7f47 100644 --- a/gitupdate.bat +++ b/gitupdate.bat @@ -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 \ No newline at end of file diff --git a/mobile/src/main/java/com/github/shadowsocks/MainActivity.kt b/mobile/src/main/java/com/github/shadowsocks/MainActivity.kt index 13cdf76..ab36a22 100644 --- a/mobile/src/main/java/com/github/shadowsocks/MainActivity.kt +++ b/mobile/src/main/java/com/github/shadowsocks/MainActivity.kt @@ -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 @@ -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() diff --git a/mobile/src/main/java/com/github/shadowsocks/ProfilesFragment.kt b/mobile/src/main/java/com/github/shadowsocks/ProfilesFragment.kt index 04f9ea1..34d5826 100644 --- a/mobile/src/main/java/com/github/shadowsocks/ProfilesFragment.kt +++ b/mobile/src/main/java/com/github/shadowsocks/ProfilesFragment.kt @@ -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 } @@ -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) @@ -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){} } } }