Replace tag manager with firebase config
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
enablePlugins(AndroidApp)
|
||||
enablePlugins(AndroidGms)
|
||||
|
||||
android.useSupportVectors
|
||||
|
||||
name := "shadowsocks"
|
||||
@@ -19,6 +21,8 @@ libraryDependencies ++=
|
||||
"com.futuremind.recyclerfastscroll" % "fastscroll" % "0.2.5" ::
|
||||
"com.evernote" % "android-job" % "1.1.9" ::
|
||||
"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-analytics" % playServicesVersion ::
|
||||
"com.google.android.gms" % "play-services-gcm" % playServicesVersion ::
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
{
|
||||
"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"
|
||||
}
|
||||
Binary file not shown.
@@ -127,9 +127,8 @@ trait BaseService extends Service {
|
||||
def connect() {
|
||||
profile.name = profile.getName // save original name before it's (possibly) overwritten by IP addresses
|
||||
if (profile.host == "198.199.101.152") {
|
||||
val holder = app.containerHolder
|
||||
val container = holder.getContainer
|
||||
val url = container.getString("proxy_url")
|
||||
val config = app.remoteConfig
|
||||
val url = config.getString("proxy_url")
|
||||
val sig = Utils.getSignature(this)
|
||||
|
||||
val client = new OkHttpClient.Builder()
|
||||
@@ -276,7 +275,7 @@ trait BaseService extends Service {
|
||||
|
||||
override def onCreate() {
|
||||
super.onCreate()
|
||||
app.refreshContainerHolder()
|
||||
app.remoteConfig.fetch()
|
||||
app.updateAssets()
|
||||
}
|
||||
|
||||
@@ -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] = {
|
||||
val result = ArrayBuffer(pluginPath)
|
||||
if (TcpFastOpen.sendEnabled) result += "--fast-open"
|
||||
result
|
||||
}
|
||||
|
||||
protected final def buildShadowsocksConfig(file: String): String = {
|
||||
val config = new JSONObject()
|
||||
.put("server", profile.host)
|
||||
|
||||
@@ -390,7 +390,6 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe
|
||||
|
||||
protected override def onResume() {
|
||||
super.onResume()
|
||||
app.refreshContainerHolder()
|
||||
state match {
|
||||
case State.STOPPING | State.CONNECTING =>
|
||||
case _ => hideCircle()
|
||||
|
||||
@@ -38,9 +38,12 @@ import com.github.shadowsocks.acl.DonaldTrump
|
||||
import com.github.shadowsocks.database.{DBHelper, Profile, ProfileManager}
|
||||
import com.github.shadowsocks.utils.CloseUtils._
|
||||
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.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 eu.chainfire.libsuperuser.Shell
|
||||
|
||||
@@ -61,8 +64,7 @@ object ShadowsocksApplication {
|
||||
class ShadowsocksApplication extends Application {
|
||||
import ShadowsocksApplication._
|
||||
|
||||
final val SIG_FUNC = "getSignature"
|
||||
var containerHolder: ContainerHolder = _
|
||||
lazy val remoteConfig = FirebaseRemoteConfig.getInstance()
|
||||
lazy val tracker: Tracker = GoogleAnalytics.getInstance(this).newTracker(R.xml.tracker)
|
||||
lazy val settings: SharedPreferences = PreferenceManager.getDefaultSharedPreferences(this)
|
||||
lazy val editor: SharedPreferences.Editor = settings.edit
|
||||
@@ -149,35 +151,23 @@ class ShadowsocksApplication extends Application {
|
||||
if (!BuildConfig.DEBUG) java.lang.System.setProperty(LocalLog.LOCAL_LOG_LEVEL_PROPERTY, "ERROR")
|
||||
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true)
|
||||
checkChineseLocale(getResources.getConfiguration)
|
||||
val tm = TagManager.getInstance(this)
|
||||
val pending = tm.loadContainerPreferNonDefault("GTM-NT8WS8", R.raw.gtm_default_container)
|
||||
val callback = new ResultCallback[ContainerHolder] {
|
||||
override def onResult(holder: ContainerHolder) {
|
||||
if (!holder.getStatus.isSuccess) {
|
||||
return
|
||||
}
|
||||
containerHolder = holder
|
||||
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)
|
||||
|
||||
FirebaseApp.initializeApp(this)
|
||||
|
||||
remoteConfig.fetch(60)
|
||||
.addOnCompleteListener(new OnCompleteListener[Void]() {
|
||||
def onComplete(task: Task[Void]) {
|
||||
if (task.isSuccessful()) {
|
||||
remoteConfig.activateFetched()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
JobManager.create(this).addJobCreator(DonaldTrump)
|
||||
|
||||
TcpFastOpen.enabled(settings.getBoolean(Key.tfo, TcpFastOpen.sendEnabled))
|
||||
}
|
||||
|
||||
def refreshContainerHolder() {
|
||||
val holder = app.containerHolder
|
||||
if (holder != null) holder.refresh()
|
||||
}
|
||||
|
||||
def crashRecovery() {
|
||||
val cmd = new ArrayBuffer[String]()
|
||||
|
||||
|
||||
@@ -7,3 +7,5 @@ addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.8.2")
|
||||
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "1.1")
|
||||
|
||||
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.0.0") // fot sbt-0.13.5 or higher
|
||||
|
||||
addSbtPlugin("org.scala-android" % "sbt-android-gms" % "0.4")
|
||||
|
||||
Reference in New Issue
Block a user