Skip to content

Commit 5d2c0d9

Browse files
author
Latitude Bot
committed
chore: bump version to 0.0.11 and implement disableAntiBrickingMeasures for improved channel switching in selection policy
1 parent bd26bf5 commit 5d2c0d9

5 files changed

Lines changed: 40 additions & 8 deletions

File tree

packages/expo-updates/android/src/main/java/expo/modules/updates/selectionpolicy/LoaderSelectionPolicyFilterAware.kt

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,13 @@ import org.json.JSONObject
1010
* matches the given manifest filters.
1111
*
1212
* Uses `commitTime` to determine ordering of updates.
13+
*
14+
* When `disableAntiBrickingMeasures` is true, the commit time check is bypassed to allow
15+
* switching between channels even when the target channel has an older update.
1316
*/
14-
class LoaderSelectionPolicyFilterAware : LoaderSelectionPolicy {
17+
class LoaderSelectionPolicyFilterAware(
18+
private val disableAntiBrickingMeasures: Boolean = false
19+
) : LoaderSelectionPolicy {
1520
override fun shouldLoadNewUpdate(
1621
newUpdate: UpdateEntity?,
1722
launchedUpdate: UpdateEntity?,
@@ -29,11 +34,16 @@ class LoaderSelectionPolicyFilterAware : LoaderSelectionPolicy {
2934
}
3035
// if the current update doesn't pass the manifest filters
3136
// we should load the new update no matter the commitTime
32-
return if (!SelectionPolicies.matchesFilters(launchedUpdate, filters)) {
33-
true
34-
} else {
35-
newUpdate.commitTime.after(launchedUpdate.commitTime)
37+
if (!SelectionPolicies.matchesFilters(launchedUpdate, filters)) {
38+
return true
39+
}
40+
// When anti-bricking measures are disabled (channel switching enabled),
41+
// always load the update regardless of commit time. This allows switching
42+
// to channels that may have older updates than the current one.
43+
if (disableAntiBrickingMeasures) {
44+
return true
3645
}
46+
return newUpdate.commitTime.after(launchedUpdate.commitTime)
3747
}
3848

3949
override fun shouldLoadRollBackToEmbeddedDirective(

packages/expo-updates/android/src/main/java/expo/modules/updates/selectionpolicy/SelectionPolicyFactory.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,12 @@ object SelectionPolicyFactory {
1212
config: UpdatesConfiguration? = null,
1313
filterByChannel: Boolean = false
1414
): SelectionPolicy {
15+
// When disableAntiBrickingMeasures is enabled, pass it to the loader selection policy
16+
// to allow loading updates with older commit times (needed for channel switching)
17+
val disableAntiBrickingMeasures = config?.disableAntiBrickingMeasures ?: false
1518
return SelectionPolicy(
1619
LauncherSelectionPolicyFilterAware(runtimeVersion, config, filterByChannel),
17-
LoaderSelectionPolicyFilterAware(),
20+
LoaderSelectionPolicyFilterAware(disableAntiBrickingMeasures),
1821
ReaperSelectionPolicyFilterAware()
1922
)
2023
}

packages/expo-updates/ios/EXUpdates/SelectionPolicy/LoaderSelectionPolicyFilterAware.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,19 @@ import Foundation
88
* matches the given manifest filters.
99
*
1010
* Uses `commitTime` to determine ordering of updates.
11+
*
12+
* When `disableAntiBrickingMeasures` is true, the commit time check is bypassed to allow
13+
* switching between channels even when the target channel has an older update.
1114
*/
1215
@objc(EXUpdatesLoaderSelectionPolicyFilterAware)
1316
@objcMembers
1417
public final class LoaderSelectionPolicyFilterAware: NSObject, LoaderSelectionPolicy {
18+
private let disableAntiBrickingMeasures: Bool
19+
20+
public init(disableAntiBrickingMeasures: Bool = false) {
21+
self.disableAntiBrickingMeasures = disableAntiBrickingMeasures
22+
}
23+
1524
public func shouldLoadNewUpdate(_ newUpdate: Update?, withLaunchedUpdate launchedUpdate: Update?, filters: [String: Any]?) -> Bool {
1625
guard let newUpdate = newUpdate,
1726
SelectionPolicies.doesUpdate(newUpdate, matchFilters: filters) else {
@@ -28,6 +37,13 @@ public final class LoaderSelectionPolicyFilterAware: NSObject, LoaderSelectionPo
2837
return true
2938
}
3039

40+
// When anti-bricking measures are disabled (channel switching enabled),
41+
// always load the update regardless of commit time. This allows switching
42+
// to channels that may have older updates than the current one.
43+
if disableAntiBrickingMeasures {
44+
return true
45+
}
46+
3147
return launchedUpdate.commitTime.compare(newUpdate.commitTime) == .orderedAscending
3248
}
3349

packages/expo-updates/ios/EXUpdates/SelectionPolicy/SelectionPolicyFactory.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,12 @@ public final class SelectionPolicyFactory: NSObject {
1414
config: UpdatesConfig? = nil,
1515
filterByChannel: Bool = false
1616
) -> SelectionPolicy {
17+
// When disableAntiBrickingMeasures is enabled, pass it to the loader selection policy
18+
// to allow loading updates with older commit times (needed for channel switching)
19+
let disableAntiBrickingMeasures = config?.disableAntiBrickingMeasures ?? false
1720
return SelectionPolicy.init(
1821
launcherSelectionPolicy: LauncherSelectionPolicyFilterAware.init(runtimeVersion: runtimeVersion, config: config, filterByChannel: filterByChannel),
19-
loaderSelectionPolicy: LoaderSelectionPolicyFilterAware(),
22+
loaderSelectionPolicy: LoaderSelectionPolicyFilterAware(disableAntiBrickingMeasures: disableAntiBrickingMeasures),
2023
reaperSelectionPolicy: ReaperSelectionPolicyFilterAware()
2124
)
2225
}

packages/expo-updates/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@latitudegames/expo-updates",
3-
"version": "0.0.10",
3+
"version": "0.0.11",
44
"description": "Fetches and manages remotely-hosted assets and updates to your app's JS bundle.",
55
"main": "build/index.js",
66
"types": "build/index.d.ts",

0 commit comments

Comments
 (0)