Commit 6636cf81 authored by Max Lv's avatar Max Lv

Replace tag manager with firebase config

parent 6df8f14f
enablePlugins(AndroidApp) enablePlugins(AndroidApp)
enablePlugins(AndroidGms)
android.useSupportVectors android.useSupportVectors
name := "shadowsocks" name := "shadowsocks"
...@@ -19,6 +21,8 @@ libraryDependencies ++= ...@@ -19,6 +21,8 @@ libraryDependencies ++=
"com.futuremind.recyclerfastscroll" % "fastscroll" % "0.2.5" :: "com.futuremind.recyclerfastscroll" % "fastscroll" % "0.2.5" ::
"com.evernote" % "android-job" % "1.1.9" :: "com.evernote" % "android-job" % "1.1.9" ::
"com.github.jorgecastilloprz" % "fabprogresscircle" % "1.01" :: "com.github.jorgecastilloprz" % "fabprogresscircle" % "1.01" ::
"com.google.firebase" % "firebase-core" % playServicesVersion ::
"com.google.firebase" % "firebase-config" % playServicesVersion ::
"com.google.android.gms" % "play-services-ads" % playServicesVersion :: "com.google.android.gms" % "play-services-ads" % playServicesVersion ::
"com.google.android.gms" % "play-services-analytics" % playServicesVersion :: "com.google.android.gms" % "play-services-analytics" % playServicesVersion ::
"com.google.android.gms" % "play-services-gcm" % playServicesVersion :: "com.google.android.gms" % "play-services-gcm" % playServicesVersion ::
......
{
"project_info": {
"project_number": "261400168171",
"firebase_url": "https://admob-app-id-3330146721.firebaseio.com",
"project_id": "admob-app-id-3330146721",
"storage_bucket": "admob-app-id-3330146721.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:261400168171:android:dbdd6331c434162f",
"android_client_info": {
"package_name": "com.github.shadowsocks"
}
},
"oauth_client": [
{
"client_id": "261400168171-sfik8o3pj7e243583olorh7s5974vab1.apps.googleusercontent.com",
"client_type": 1,
"android_info": {
"package_name": "com.github.shadowsocks",
"certificate_hash": "58a90f84cfe99d4280aec677c9a1292fae131677"
}
},
{
"client_id": "261400168171-g7aelv5bu012ojr7dod7lq09c9anjimh.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyCee3fAad7nb3YsxeUO9mqqHFfAvsSCbVs"
}
],
"services": {
"analytics_service": {
"status": 1
},
"appinvite_service": {
"status": 1,
"other_platform_oauth_client": []
},
"ads_service": {
"status": 2
}
}
}
],
"configuration_version": "1"
}
\ No newline at end of file
...@@ -127,9 +127,8 @@ trait BaseService extends Service { ...@@ -127,9 +127,8 @@ trait BaseService extends Service {
def connect() { def connect() {
profile.name = profile.getName // save original name before it's (possibly) overwritten by IP addresses profile.name = profile.getName // save original name before it's (possibly) overwritten by IP addresses
if (profile.host == "198.199.101.152") { if (profile.host == "198.199.101.152") {
val holder = app.containerHolder val config = app.remoteConfig
val container = holder.getContainer val url = config.getString("proxy_url")
val url = container.getString("proxy_url")
val sig = Utils.getSignature(this) val sig = Utils.getSignature(this)
val client = new OkHttpClient.Builder() val client = new OkHttpClient.Builder()
...@@ -276,7 +275,7 @@ trait BaseService extends Service { ...@@ -276,7 +275,7 @@ trait BaseService extends Service {
override def onCreate() { override def onCreate() {
super.onCreate() super.onCreate()
app.refreshContainerHolder() app.remoteConfig.fetch()
app.updateAssets() app.updateAssets()
} }
...@@ -301,23 +300,12 @@ trait BaseService extends Service { ...@@ -301,23 +300,12 @@ trait BaseService extends Service {
} }
} }
def getBlackList: String = {
val default = getString(R.string.black_list)
try {
val container = app.containerHolder.getContainer
val update = container.getString("black_list_lite")
val list = if (update == null || update.isEmpty) default else update
"exclude = " + list + ";"
} catch {
case _: Exception => "exclude = " + default + ";"
}
}
protected def buildPluginCommandLine(): ArrayBuffer[String] = { protected def buildPluginCommandLine(): ArrayBuffer[String] = {
val result = ArrayBuffer(pluginPath) val result = ArrayBuffer(pluginPath)
if (TcpFastOpen.sendEnabled) result += "--fast-open" if (TcpFastOpen.sendEnabled) result += "--fast-open"
result result
} }
protected final def buildShadowsocksConfig(file: String): String = { protected final def buildShadowsocksConfig(file: String): String = {
val config = new JSONObject() val config = new JSONObject()
.put("server", profile.host) .put("server", profile.host)
......
...@@ -390,7 +390,6 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe ...@@ -390,7 +390,6 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe
protected override def onResume() { protected override def onResume() {
super.onResume() super.onResume()
app.refreshContainerHolder()
state match { state match {
case State.STOPPING | State.CONNECTING => case State.STOPPING | State.CONNECTING =>
case _ => hideCircle() case _ => hideCircle()
......
...@@ -38,9 +38,12 @@ import com.github.shadowsocks.acl.DonaldTrump ...@@ -38,9 +38,12 @@ import com.github.shadowsocks.acl.DonaldTrump
import com.github.shadowsocks.database.{DBHelper, Profile, ProfileManager} import com.github.shadowsocks.database.{DBHelper, Profile, ProfileManager}
import com.github.shadowsocks.utils.CloseUtils._ import com.github.shadowsocks.utils.CloseUtils._
import com.github.shadowsocks.utils._ import com.github.shadowsocks.utils._
import com.google.android.gms.tasks.OnCompleteListener
import com.google.android.gms.tasks.Task
import com.google.android.gms.analytics.{GoogleAnalytics, HitBuilders, StandardExceptionParser, Tracker} import com.google.android.gms.analytics.{GoogleAnalytics, HitBuilders, StandardExceptionParser, Tracker}
import com.google.android.gms.common.api.ResultCallback import com.google.android.gms.common.api.ResultCallback
import com.google.android.gms.tagmanager.{ContainerHolder, TagManager} import com.google.firebase.remoteconfig.FirebaseRemoteConfig
import com.google.firebase.FirebaseApp
import com.j256.ormlite.logger.LocalLog import com.j256.ormlite.logger.LocalLog
import eu.chainfire.libsuperuser.Shell import eu.chainfire.libsuperuser.Shell
...@@ -61,8 +64,7 @@ object ShadowsocksApplication { ...@@ -61,8 +64,7 @@ object ShadowsocksApplication {
class ShadowsocksApplication extends Application { class ShadowsocksApplication extends Application {
import ShadowsocksApplication._ import ShadowsocksApplication._
final val SIG_FUNC = "getSignature" lazy val remoteConfig = FirebaseRemoteConfig.getInstance()
var containerHolder: ContainerHolder = _
lazy val tracker: Tracker = GoogleAnalytics.getInstance(this).newTracker(R.xml.tracker) lazy val tracker: Tracker = GoogleAnalytics.getInstance(this).newTracker(R.xml.tracker)
lazy val settings: SharedPreferences = PreferenceManager.getDefaultSharedPreferences(this) lazy val settings: SharedPreferences = PreferenceManager.getDefaultSharedPreferences(this)
lazy val editor: SharedPreferences.Editor = settings.edit lazy val editor: SharedPreferences.Editor = settings.edit
...@@ -149,35 +151,23 @@ class ShadowsocksApplication extends Application { ...@@ -149,35 +151,23 @@ class ShadowsocksApplication extends Application {
if (!BuildConfig.DEBUG) java.lang.System.setProperty(LocalLog.LOCAL_LOG_LEVEL_PROPERTY, "ERROR") if (!BuildConfig.DEBUG) java.lang.System.setProperty(LocalLog.LOCAL_LOG_LEVEL_PROPERTY, "ERROR")
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true) AppCompatDelegate.setCompatVectorFromResourcesEnabled(true)
checkChineseLocale(getResources.getConfiguration) checkChineseLocale(getResources.getConfiguration)
val tm = TagManager.getInstance(this)
val pending = tm.loadContainerPreferNonDefault("GTM-NT8WS8", R.raw.gtm_default_container) FirebaseApp.initializeApp(this)
val callback = new ResultCallback[ContainerHolder] {
override def onResult(holder: ContainerHolder) { remoteConfig.fetch(60)
if (!holder.getStatus.isSuccess) { .addOnCompleteListener(new OnCompleteListener[Void]() {
return def onComplete(task: Task[Void]) {
} if (task.isSuccessful()) {
containerHolder = holder remoteConfig.activateFetched()
val container = holder.getContainer
container.registerFunctionCallMacroCallback(SIG_FUNC,
(functionName: String, parameters: util.Map[String, AnyRef]) => {
if (functionName == SIG_FUNC) {
Utils.getSignature(getApplicationContext)
}
null
})
} }
} }
pending.setResultCallback(callback, 2, TimeUnit.SECONDS) })
JobManager.create(this).addJobCreator(DonaldTrump) JobManager.create(this).addJobCreator(DonaldTrump)
TcpFastOpen.enabled(settings.getBoolean(Key.tfo, TcpFastOpen.sendEnabled)) TcpFastOpen.enabled(settings.getBoolean(Key.tfo, TcpFastOpen.sendEnabled))
} }
def refreshContainerHolder() {
val holder = app.containerHolder
if (holder != null) holder.refresh()
}
def crashRecovery() { def crashRecovery() {
val cmd = new ArrayBuffer[String]() val cmd = new ArrayBuffer[String]()
......
...@@ -7,3 +7,5 @@ addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.8.2") ...@@ -7,3 +7,5 @@ addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.8.2")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "1.1") addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "1.1")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.0.0") // fot sbt-0.13.5 or higher addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.0.0") // fot sbt-0.13.5 or higher
addSbtPlugin("org.scala-android" % "sbt-android-gms" % "0.4")
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment