Skip to content

Commit

Permalink
Gradle update (#637)
Browse files Browse the repository at this point in the history
* Update gradle and dokka

* fix issues after gradle and kotlin updates

* fix unit test

* update CHANGELOG

* Fix unit tests

* Fix lint

* Fix lint app

* Fix crash

---------

Co-authored-by: Ziyi Zhang <[email protected]>
  • Loading branch information
linsang21 and ziyiz-amzn authored Oct 4, 2024
1 parent 4750a80 commit 4c49a9c
Show file tree
Hide file tree
Showing 1,936 changed files with 194,396 additions and 34,010 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## Unreleased

### Changed
* Upgrade gradle version and dokka

## [0.23.0] - 2024-08-15

### Changed
Expand Down
48 changes: 26 additions & 22 deletions amazon-chime-sdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
import org.jetbrains.dokka.gradle.DokkaTask

apply from: rootProject.file('publishing.gradle')
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'org.jetbrains.dokka'
apply plugin: 'jacoco'

Expand All @@ -23,8 +23,8 @@ ext.versionMinor = versionProperties.getProperty('versionMinor') as Integer
ext.versionPatch = versionProperties.getProperty('versionPatch') as Integer

android {
compileSdkVersion project.ext.chimeCompileSdkVersion
buildToolsVersion project.ext.chimeBuildToolsVersion
compileSdk project.ext.chimeCompileSdkVersion
buildToolsVersion = project.ext.chimeBuildToolsVersion

defaultConfig {
minSdkVersion project.ext.chimeMinSdkVersion
Expand All @@ -38,7 +38,7 @@ android {

kotlinOptions {
jvmTarget = '1.8'
freeCompilerArgs += ["-Xjvm-default=enable"]
freeCompilerArgs += ["-Xjvm-default=all"]
}

buildTypes {
Expand All @@ -60,6 +60,10 @@ android {
jacoco {
includeNoLocationClasses = true
}
jvmArgs(
"--add-opens", "java.base/java.util=ALL-UNNAMED",
"--add-opens", "java.base/java.lang.reflect=ALL-UNNAMED"
)
}
// This causes system calls to return default (i.e. null or zero) values rather then
// immediately throwing exceptions. Without this, tests covering anything with significant OpenGLES or
Expand All @@ -73,27 +77,27 @@ android {
targetCompatibility JavaVersion.VERSION_1_8
}

dokka {
outputFormat = 'html'
outputDirectory = "docs"

configuration {
includeNonPublic = false
skipDeprecated = true
skipEmptyPackages = true

perPackageOption {
prefix = "com.amazonaws.services.chime.sdk.meetings.internal"
suppress = true
}
}
}

defaultConfig {
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
}

tasks.withType(DokkaTask.class) {
dokkaSourceSets.configureEach {
documentedVisibilities.set([
Visibility.PUBLIC,
Visibility.PROTECTED
])
skipEmptyPackages.set(true)
skipDeprecated.set(true)

perPackageOption {
matchingRegex.set(".*internal.*")
suppress.set(true)
}
}
}

tasks.withType(Test) {
jacoco {
includeNoLocationClasses = true
Expand Down Expand Up @@ -144,11 +148,11 @@ dependencies {
implementation 'com.google.code.gson:gson:2.9.0'
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.3.3'
testImplementation 'junit:junit:4.12'
testImplementation "io.mockk:mockk:1.10.0"
testImplementation "io.mockk:mockk:1.13.12"
// Android Test only
androidTestImplementation 'androidx.test:core:1.3.0'
androidTestImplementation 'androidx.test:runner:1.3.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'io.mockk:mockk-android:1.10.0'
androidTestImplementation 'io.mockk:mockk-android:1.13.12'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.1.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ class DefaultActiveSpeakerDetector(
activityTimer.scheduleAtFixedRate(
object : TimerTask() {
override fun run() {
observerToPolicy.values.forEach { policy ->
speakerScores.keys.forEach { attendeeInfo ->
observerToPolicy.values.iterator().forEach { policy ->
speakerScores.keys.iterator().forEach { attendeeInfo ->
val lastTimestamp = mostRecentUpdateTimestamp[attendeeInfo] ?: 0
if (System.currentTimeMillis() - lastTimestamp > ACTIVITY_WAIT_INTERVAL_MS) {
updateScore(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class BackgroundBlurVideoFrameProcessor @JvmOverloads constructor(
)
frame.release()

sinks.forEach { it.onVideoFrameReceived(processedFrame) }
sinks.iterator().forEach { it.onVideoFrameReceived(processedFrame) }
processedFrame.release()
JniUtil.nativeFreeByteBuffer(rgbaData)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class BackgroundReplacementVideoFrameProcessor @JvmOverloads constructor(
)
frame.release()

sinks.forEach { it.onVideoFrameReceived(processedFrame) }
sinks.iterator().forEach { it.onVideoFrameReceived(processedFrame) }
processedFrame.release()
JniUtil.nativeFreeByteBuffer(rgbaData)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ class DefaultCameraCaptureSource @JvmOverloads constructor(
val maxFps: Int = 30

val chosenCaptureFormat: VideoCaptureFormat? =
MediaDevice.listSupportedVideoCaptureFormats(cameraManager, device, maxFps, maxWidth, maxHeight).minBy { format ->
MediaDevice.listSupportedVideoCaptureFormats(cameraManager, device, maxFps, maxWidth, maxHeight).minByOrNull { format ->
abs(format.width - this.format.width) + abs(format.height - this.format.height)
}
val surfaceTextureFormat: VideoCaptureFormat = chosenCaptureFormat ?: run {
Expand Down Expand Up @@ -260,7 +260,7 @@ class DefaultCameraCaptureSource @JvmOverloads constructor(

val processedFrame =
VideoFrame(frame.timestampNs, processedBuffer, getCaptureFrameRotation())
sinks.forEach { it.onVideoFrameReceived(processedFrame) }
sinks.iterator().forEach { it.onVideoFrameReceived(processedFrame) }
processedBuffer.release()
}

Expand Down Expand Up @@ -390,11 +390,11 @@ class DefaultCameraCaptureSource @JvmOverloads constructor(
// Pick range with max closest to but not exceeding the set max framerate
val bestFpsRange = fpsRanges
.filter { it.upper <= this.format.maxFps }
.minBy { this.format.maxFps - it.upper }
.minByOrNull { this.format.maxFps - it.upper }
?: run {
logger.warn(TAG, "No FPS ranges below set max FPS")
// Just fall back to the closest
return@run fpsRanges.minBy { abs(this.format.maxFps - it.upper) }
return@run fpsRanges.minByOrNull { abs(this.format.maxFps - it.upper) }
} ?: run {
logger.error(TAG, "No valid FPS ranges")
handleCameraCaptureFail(CaptureSourceError.ConfigurationFailure)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ class DefaultScreenCaptureSource(

// Ignore frames while we are recreating the surface and display
if (isResizingForOrientationChange) return
sinks.forEach { it.onVideoFrameReceived(frame) }
sinks.iterator().forEach { it.onVideoFrameReceived(frame) }
}

private fun resize() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ class DefaultSurfaceTextureCaptureSource(
val alignedTimestamp = timestampAligner.translateTimestamp(surfaceTexture.timestamp)
val frame = VideoFrame(alignedTimestamp, buffer)

sinks.forEach { it.onVideoFrameReceived(frame) }
sinks.iterator().forEach { it.onVideoFrameReceived(frame) }
frame.release()

// If we have min FPS set, check in a while if we should resend the previous frame
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ data class MediaDevice(
val characteristics = cameraManager.getCameraCharacteristics(mediaDevice.id ?: return emptyList())
val fps = characteristics.get(
CameraCharacteristics.CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES
)?.map { it.upper }?.filter { it <= maxVideoFps }?.max() ?: DEFAULT_MAX_VIDEO_FORMAT_FPS
)?.map { it.upper }?.filter { it <= maxVideoFps }?.maxOrNull() ?: DEFAULT_MAX_VIDEO_FORMAT_FPS

val streamMap =
characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ class DefaultAudioClientObserver(
meetingStatsCollector.incrementPoorConnectionCount()
notifyAudioClientObserver { observer -> observer.onConnectionBecamePoor() }
}
else -> Unit
}
else -> Unit
}
}
SessionStateControllerAction.Reconnecting -> {
Expand All @@ -156,8 +158,10 @@ class DefaultAudioClientObserver(
}
handleOnAudioSessionFailed(newAudioStatus)
}
else -> Unit
}
}
else -> Unit
}
currentAudioState = newAudioState
currentAudioStatus = newAudioStatus
Expand Down Expand Up @@ -558,7 +562,7 @@ class DefaultAudioClientObserver(
}

private fun notifyFailed(statusCode: MeetingSessionStatusCode?) {
val attributes = statusCode?.let {
val attributes: MutableMap<EventAttributeName, Any>? = statusCode?.let {
mutableMapOf(
EventAttributeName.meetingStatus to statusCode,
EventAttributeName.meetingErrorMessage to statusCode.toString()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ object IngestionEventConverter {
}

private fun toIngestionPayload(event: MeetingEventItem, metadataAttributeKeys: Set<String>): IngestionPayload {
val payload = mutableMapOf(
val payload: MutableMap<String, Any> = mutableMapOf(
NAME_KEY to event.data.name,
TIMESTAMP_KEY to (event.data.eventAttributes[EventAttributeName.timestampMs.name] as Double).toLong(),
ID_KEY to event.id
Expand All @@ -130,7 +130,7 @@ object IngestionEventConverter {
}

private fun toIngestionPayload(dirtyEvent: DirtyMeetingEventItem, metadataAttributeKeys: Set<String>): IngestionPayload {
val payload = mutableMapOf(
val payload: MutableMap<String, Any> = mutableMapOf(
NAME_KEY to dirtyEvent.data.name,
TTL_KEY to dirtyEvent.ttl,
TIMESTAMP_KEY to (dirtyEvent.data.eventAttributes[EventAttributeName.timestampMs.name] as Double).toLong(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ object AppInfoUtil {
private lateinit var clientUtcOffset: String

private fun initializeAppInfo(context: Context) {
manufacturer = DeviceUtils.deviceManufacturer
model = DeviceUtils.deviceModel
osVersion = DeviceUtils.osVersion
manufacturer = DeviceUtils.deviceManufacturer.toString()
model = DeviceUtils.deviceModel.toString()
osVersion = DeviceUtils.osVersion.toString()
val packageName = context.packageName
val packageInfo = context.packageManager.getPackageInfo(packageName, 0)
appName = String.format("Android %s", packageInfo.versionName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ class DeviceUtils {
Versioning.sdkVersion()
}

val deviceModel: String by lazy {
val deviceModel: String? by lazy {
android.os.Build.MODEL
}

val deviceManufacturer: String by lazy {
val deviceManufacturer: String? by lazy {
android.os.Build.MANUFACTURER
}

Expand All @@ -35,7 +35,7 @@ class DeviceUtils {
val osName: String by lazy {
"Android"
}
val osVersion: String by lazy {
val osVersion: String? by lazy {
android.os.Build.VERSION.RELEASE
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,6 @@ class VideoSourceAdapter : VideoSink,
val videoClientFrame = com.xodee.client.video.VideoFrame(
frame.width, frame.height, frame.timestampNs, frame.rotation.degrees, buffer
)
sinks.forEach { it.onFrameCaptured(videoClientFrame) }
sinks.iterator().forEach { it.onFrameCaptured(videoClientFrame) }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class ConsoleLogger(private var level: LogLevel = LogLevel.INFO) : Logger {
LogLevel.INFO -> Log.i(tag, msg)
LogLevel.WARN -> Log.w(tag, msg)
LogLevel.ERROR -> Log.e(tag, msg)
else -> Unit
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class DefaultSurfaceTextureCaptureSourceTest {
every { EGL14.eglCreatePbufferSurface(any(), any(), any(), any()) } returns mockEglSurface

mockkConstructor(SurfaceTexture::class)
every { anyConstructed<SurfaceTexture>().setDefaultBufferSize(any(), any()) } just runs

mockkConstructor(TimestampAligner::class)
every { anyConstructed<TimestampAligner>().translateTimestamp(any()) } returns 0
Expand All @@ -96,14 +97,6 @@ class DefaultSurfaceTextureCaptureSourceTest {

@Test
fun `constructor sets expected dimensions of surface`() {
DefaultSurfaceTextureCaptureSource(
mockLogger,
testWidth,
testHeight,
testContentHint,
mockEglCoreFactory
)

verify { anyConstructed<SurfaceTexture>().setDefaultBufferSize(testWidth, testHeight) }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,50 @@ import org.junit.Test
class DeviceUtilsTest {
@Test
fun `sdkName should return "amazon-chime-sdk-android"`() {
Assert.assertEquals("amazon-chime-sdk-android", DeviceUtils.sdkName)
val expected = "amazon-chime-sdk-android"
val actual = DeviceUtils.sdkName
Assert.assertEquals(expected, actual)
}

@Test
fun `osName should return "Android"`() {
Assert.assertEquals("Android", DeviceUtils.osName)
val expected = "Android"
val actual = DeviceUtils.osName
Assert.assertEquals(expected, actual)
}

@Test
fun `osVersion should return "Android"`() {
Assert.assertEquals(android.os.Build.VERSION.RELEASE, DeviceUtils.osVersion)
fun `osVersion should return version`() {
val expected = android.os.Build.VERSION.RELEASE
val actual = DeviceUtils.osVersion
Assert.assertEquals(expected, actual)
}

@Test
fun `sdkVersion should return value same as BuildConfig`() {
Assert.assertEquals(BuildConfig.VERSION_NAME, DeviceUtils.sdkVersion)
val expected = BuildConfig.VERSION_NAME
val actual = DeviceUtils.sdkVersion
Assert.assertEquals(expected, actual)
}

@Test
fun `deviceName should return value same as vendor + model`() {
Assert.assertEquals("${android.os.Build.MANUFACTURER} ${android.os.Build.MODEL}", DeviceUtils.deviceName)
val expected = "${android.os.Build.MANUFACTURER} ${android.os.Build.MODEL}"
val actual = DeviceUtils.deviceName
Assert.assertEquals(expected, actual)
}

@Test
fun `deviceModel should return value same as model`() {
Assert.assertEquals(android.os.Build.MODEL, DeviceUtils.deviceModel)
val expected = android.os.Build.MODEL
val actual = DeviceUtils.deviceModel
Assert.assertEquals(expected, actual)
}

@Test
fun `deviceManufacturer should return value same as vendor`() {
Assert.assertEquals(android.os.Build.MANUFACTURER, DeviceUtils.deviceManufacturer)
val expected = android.os.Build.MANUFACTURER
val actual = DeviceUtils.deviceManufacturer
Assert.assertEquals(expected, actual)
}
}
Loading

0 comments on commit 4c49a9c

Please sign in to comment.