Skip to content

Commit cf69b2d

Browse files
committed
feat(play): drop the activation gate
Play builds no longer configure the mobile entitlement runtime, run the server activation flow or ship the entitlement activity; the app instead publishes an always-allowed snapshot at startup so every automation gate reader (app and hook mirror) sees the open state, including installs that cached an unactivated decision. The entitlement activity is removed from the play manifest. Sideload channels keep the token/Telegram activation flow unchanged.
1 parent 0aab082 commit cf69b2d

4 files changed

Lines changed: 45 additions & 12 deletions

File tree

‎app/build.gradle.kts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,15 @@ android {
7272
productFlavors {
7373
getByName("play") {
7474
buildConfigField("String", "MOBILE_ENTITLEMENT_CHANNEL", "\"play\"")
75+
buildConfigField("boolean", "ENABLE_MOBILE_ENTITLEMENT", "false")
7576
}
7677
getByName("github") {
7778
buildConfigField("String", "MOBILE_ENTITLEMENT_CHANNEL", "\"sideload\"")
79+
buildConfigField("boolean", "ENABLE_MOBILE_ENTITLEMENT", "true")
7880
}
7981
getByName("fdroid") {
8082
buildConfigField("String", "MOBILE_ENTITLEMENT_CHANNEL", "\"sideload\"")
83+
buildConfigField("boolean", "ENABLE_MOBILE_ENTITLEMENT", "true")
8184
}
8285
}
8386

‎app/src/main/java/com/github/magisk317/smscode/service/AutoInputAccessibilityService.kt‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -192,12 +192,15 @@ class AutoInputAccessibilityService : AccessibilityService() {
192192
return AutoInputAccessibilityNodeHelper.performAutoInput(rootInActiveWindow, code, autoEnter)
193193
}
194194

195-
private fun isMobileAutomationAllowed(): Boolean = runBlocking(Dispatchers.IO) {
196-
AppPreferencesDataStore.getBoolean(
197-
applicationContext,
198-
PrefConst.KEY_MOBILE_ENTITLEMENT_AUTOMATION_ALLOWED,
199-
PrefConst.DEFAULT_MOBILE_ENTITLEMENT_AUTOMATION_ALLOWED,
200-
)
195+
private fun isMobileAutomationAllowed(): Boolean {
196+
if (!com.github.tianma8023.xposed.smscode.BuildConfig.ENABLE_MOBILE_ENTITLEMENT) return true
197+
return runBlocking(Dispatchers.IO) {
198+
AppPreferencesDataStore.getBoolean(
199+
applicationContext,
200+
PrefConst.KEY_MOBILE_ENTITLEMENT_AUTOMATION_ALLOWED,
201+
PrefConst.DEFAULT_MOBILE_ENTITLEMENT_AUTOMATION_ALLOWED,
202+
)
203+
}
201204
}
202205

203206

‎app/src/main/java/com/github/magisk317/smscode/ui/app/SmsCodeApplication.kt‎

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,15 @@ class SmsCodeApplication : Application() {
5858
override fun onCreate() {
5959
super.onCreate()
6060
AppPreferencesDataStore.install(XscPreferenceHooks)
61-
configureMobileEntitlement()
61+
if (BuildConfig.ENABLE_MOBILE_ENTITLEMENT) {
62+
configureMobileEntitlement()
63+
} else {
64+
// Play distribution ships without the activation gate; publish an
65+
// always-allowed snapshot so the automation gates (app and hook
66+
// mirror) see the open state, including installs that cached an
67+
// unactivated decision.
68+
publishAutomationAlwaysAllowed()
69+
}
6270
android.util.Log.w("smscode", "SmsCodeApplication.onCreate() START")
6371
val installationId = AnonymousInstallationId.getOrCreate(this, TELEMETRY_PREFS_NAME)
6472
runBlocking {
@@ -127,7 +135,18 @@ class SmsCodeApplication : Application() {
127135
importPendingCodeRecords()
128136
syncPreferences()
129137
registerLicenseActivityKiller()
130-
MobileEntitlementCoordinator.initialize(this, applicationScope)
138+
if (BuildConfig.ENABLE_MOBILE_ENTITLEMENT) {
139+
MobileEntitlementCoordinator.initialize(this, applicationScope)
140+
}
141+
}
142+
143+
private fun publishAutomationAlwaysAllowed() {
144+
runBlocking {
145+
AppPreferencesDataStore.batchEdit(this@SmsCodeApplication) {
146+
setBoolean(PrefConst.KEY_MOBILE_ENTITLEMENT_AUTOMATION_ALLOWED, true)
147+
}
148+
HookPreferenceMirror.publish(this@SmsCodeApplication)
149+
}
131150
}
132151

133152
private fun configureMobileEntitlement() {
@@ -317,8 +336,10 @@ class SmsCodeApplication : Application() {
317336
override fun onActivityStarted(activity: Activity) {
318337
if (startedActivityCount == 0) {
319338
if (entitlementForegroundPrimed) {
320-
applicationScope.launch {
321-
runCatching { MobileEntitlementCoordinator.refresh(this@SmsCodeApplication) }
339+
if (BuildConfig.ENABLE_MOBILE_ENTITLEMENT) {
340+
applicationScope.launch {
341+
runCatching { MobileEntitlementCoordinator.refresh(this@SmsCodeApplication) }
342+
}
322343
}
323344
} else {
324345
// initialize() covers the first process start.

‎app/src/play/AndroidManifest.xml‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools">
34

45
<!-- Required for Google Play Billing donations in the Play distribution. -->
56
<uses-permission android:name="com.android.vending.BILLING" />
@@ -11,6 +12,11 @@
1112
<package android:name="com.android.vending" />
1213
</queries>
1314

14-
<application android:networkSecurityConfig="@xml/network_security_config" />
15+
<application android:networkSecurityConfig="@xml/network_security_config">
16+
<!-- Play distribution ships without the activation gate. -->
17+
<activity
18+
android:name="com.github.magisk317.smscode.entitlement.MobileEntitlementActivity"
19+
tools:node="remove" />
20+
</application>
1521

1622
</manifest>

0 commit comments

Comments
 (0)