-
Notifications
You must be signed in to change notification settings - Fork 369
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'ensure-relay-list-is-built-and-bundled-in-a-reproducibl…
…e-way-droid-1674'
- Loading branch information
Showing
8 changed files
with
61 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,6 @@ GRADLE_TASKS=( | |
"lint" | ||
) | ||
EXCLUDED_GRADLE_TASKS=( | ||
"-xgenerateRelayList" | ||
"-xcargoBuild" | ||
) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 14 additions & 6 deletions
20
android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/util/ContextExtensions.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,31 @@ | ||
package net.mullvad.mullvadvpn.service.util | ||
|
||
import android.content.Context | ||
import co.touchlab.kermit.Logger | ||
import java.io.File | ||
import java.io.FileNotFoundException | ||
import java.io.FileOutputStream | ||
|
||
fun Context.extractAndOverwriteIfAssetMoreRecent(assetName: String) { | ||
fun Context.extractAndOverwriteIfAssetMoreRecent(assetName: String, requireAssetFile: Boolean) { | ||
val forceOverwriteIfMoreRecent = lastUpdatedTime() > File(filesDir, assetName).lastModified() | ||
val destination = File(filesDir, assetName) | ||
|
||
if (!destination.exists() || forceOverwriteIfMoreRecent) { | ||
extractFile(assetName, destination) | ||
extractFile(assetName, destination, requireAssetFile) | ||
} | ||
} | ||
|
||
private fun Context.lastUpdatedTime(): Long = | ||
packageManager.getPackageInfo(packageName, 0).lastUpdateTime | ||
|
||
private fun Context.extractFile(asset: String, destination: File) { | ||
val destinationStream = FileOutputStream(destination) | ||
assets.open(asset).copyTo(destinationStream) | ||
destinationStream.close() | ||
private fun Context.extractFile(asset: String, destination: File, requireAssetFile: Boolean) { | ||
if (assets.list("")?.contains(asset) == true) { | ||
val destinationStream = FileOutputStream(destination) | ||
assets.open(asset).copyTo(destinationStream) | ||
destinationStream.close() | ||
} else if (requireAssetFile) { | ||
throw FileNotFoundException("Asset $asset not found") | ||
} else { | ||
Logger.i("Asset $asset not found") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters