Skip to content

Commit

Permalink
Merge pull request #20 from Parseus/dev
Browse files Browse the repository at this point in the history
Dev -> master: version 2.2.1
  • Loading branch information
Parseus authored Jun 18, 2021
2 parents fd01567 + 37462ad commit 6f383ab
Show file tree
Hide file tree
Showing 85 changed files with 926 additions and 352 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,8 @@
app/build
app/build/generated/not_namespaced_r_class_sources/debug/processDebugResources/r/androidx/asynclayoutinflater/R.java
app/nonFree
app/nonFreeMobile
app/standardMobile
app/standardTv
app/standard
.idea/kotlinc.xml
4 changes: 4 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 22 additions & 15 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,27 @@ android {
applicationId "com.parseus.codecinfo"
minSdkVersion 16
targetSdkVersion 30
versionCode 17
versionName "2.1.0"
versionCode 19
versionName "2.2.1"
resConfigs "en"

vectorDrawables.useSupportLibrary = true

manifestPlaceholders = [appName:"android.app.Application"]
}
buildTypes {
debug {
versionNameSuffix "-dev"
multiDexEnabled true
manifestPlaceholders = [appName:"androidx.multidex.MultiDexApplication"]
if (!gradle.startParameter.taskNames.toString().contains('StandardTv')) {
multiDexEnabled true
manifestPlaceholders = [appName:"androidx.multidex.MultiDexApplication"]
} else {
manifestPlaceholders = [appName:"android.app.Application"]
}
}
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
manifestPlaceholders = [appName:"android.app.Application"]
}
}

Expand Down Expand Up @@ -86,31 +89,35 @@ android {

configurations {
nonFreeMobileImplementation {}
nonFreeMobileDebugImplementation {}
standardMobileDebugImplementation {}
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

implementation 'androidx.appcompat:appcompat:1.3.0-beta01'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation "androidx.core:core-ktx:1.5.0-beta01"
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation "androidx.core:core-ktx:1.5.0"
implementation 'androidx.preference:preference-ktx:1.1.1'
implementation 'com.google.android.material:material:1.3.0-rc01'

implementation 'com.github.ditacristianionut:AppInfoBadge:1.3'
implementation "com.squareup.leakcanary:plumber-android:$leakCanary_version"
implementation "com.squareup.moshi:moshi:$moshi_version"
kapt "com.squareup.moshi:moshi-kotlin-codegen:$moshi_version"
implementation "com.squareup.okio:okio:2.10.0"

debugImplementation 'androidx.multidex:multidex:2.0.1'
debugImplementation "com.squareup.leakcanary:leakcanary-android:$leakCanary_version"
standardMobileDebugImplementation 'androidx.multidex:multidex:2.0.1'
nonFreeMobileDebugImplementation 'androidx.multidex:multidex:2.0.1'

tvImplementation 'androidx.leanback:leanback:1.1.0-rc01'
tvImplementation 'androidx.leanback:leanback-preference:1.1.0-rc01'

tvImplementation 'androidx.leanback:leanback:1.1.0-beta01'
tvImplementation 'androidx.leanback:leanback-preference:1.1.0-beta01'
mobileImplementation 'androidx.constraintlayout:constraintlayout:2.0.4'
mobileImplementation 'com.github.ditacristianionut:AppInfoBadge:1.3'
mobileImplementation 'com.google.android.material:material:1.4.0-rc01'

nonFreeMobileImplementation fileTree(include: ['*.jar'], dir: 'libs')
nonFreeMobileImplementation 'com.google.android.play:core:1.9.1'
nonFreeMobileImplementation 'com.google.android.play:core:1.10.0'
nonFreeMobileImplementation ('com.google.android.play:core-ktx:1.8.1') {
exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-jdk7'
}
Expand Down
8 changes: 1 addition & 7 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,4 @@
-dontwarn android.hardware.scontext.**
-dontwarn com.samsung.**
#noinspection ShrinkerUnresolvedReference
-keep class com.samsung.** { *; }

# TODO: Remove after LeakCanary 2.7 is released
# Enum values are referenced reflectively in EnumSet initialization
-keepclassmembers,allowoptimization enum leakcanary.AndroidLeakFixes {
public static **[] values();
}
-keep class com.samsung.** { *; }
13 changes: 1 addition & 12 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,9 @@
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:name="${appName}"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:theme="@style/Theme.CodecInfo"
tools:ignore="MissingClass,RtlEnabled,UnusedAttribute">

<provider
android:authorities="${applicationId}.fileprovider"
android:name="androidx.core.content.FileProvider"
android:grantUriPermissions="true"
android:exported="false">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>

</application>

Expand Down
12 changes: 12 additions & 0 deletions app/src/main/assets/changelog.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
<html>
<body>

<h2>Version 2.3.0</h2>
<p>UI improvements for bigger tablets and Chromebooks.</p>
<p>App should now be resizable if Samsung DeX is enabled.</p>
<p>Bugfixes and general improvements.</p>

<h2>Version 2.2.0</h2>
<p>Added querying for System Renawability Message (SRM) properties for Widevine.</p>
<p>Listing secure decoders on Android 5.0-6.0 should now be more reliable.</p>
<p>Added a workaround for Oppo R9 not listing a generic raw audio decoder.</p>
<p>(Android TV) Significant APK size reduction.</p>
<p>Reported max resolution should be now more accurate for some codecs.</p>

<h2>Version 2.1.0</h2>
<p>Codec Info will now detect and inform users about known issues with some codecs. If you know about an issue that's not being displayed, please send a feedback email about it!
<p>Added a notification for the user if getting a codec list is impossible due to an Android platform bug.</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ package com.parseus.codecinfo.data.codecinfo

import android.annotation.SuppressLint
import android.content.Context
import android.media.MediaCodec
import android.media.MediaCodecInfo
import android.media.MediaCodecInfo.CodecCapabilities.*
import android.media.MediaCodecList
import android.media.MediaFormat
import android.os.Build
import android.os.Build.VERSION.SDK_INT
import android.util.Range
import androidx.annotation.RequiresApi
Expand All @@ -16,10 +18,7 @@ import com.parseus.codecinfo.data.DetailsProperty
import com.parseus.codecinfo.data.codecinfo.colorformats.*
import com.parseus.codecinfo.data.codecinfo.profilelevels.*
import com.parseus.codecinfo.data.codecinfo.profilelevels.VP9Levels.*
import com.parseus.codecinfo.utils.isAudioCodec
import com.parseus.codecinfo.utils.toBytesPerSecond
import com.parseus.codecinfo.utils.toHexHstring
import com.parseus.codecinfo.utils.toKiloHertz
import com.parseus.codecinfo.utils.*
import java.util.*
import kotlin.collections.ArrayList

Expand All @@ -39,6 +38,9 @@ private const val DIVX6_1080P_MAX_FRAME_RATE = 30
private val DIVX4_MAX_RESOLUTION = intArrayOf(720, 576)
private val DIVX6_MAX_RESOLUTION = intArrayOf(1920, 1080)

private const val GOOGLE_RAW_DECODER = "OMX.google.raw.decoder"
private const val MEDIATEK_RAW_DECODER = "OMX.MTK.AUDIO.DECODER.RAW"

private val platformSupportedTypes = arrayOf(
"audio/3gpp",
"audio/amr-mb",
Expand Down Expand Up @@ -102,11 +104,38 @@ fun getSimpleCodecInfoList(context: Context, isAudio: Boolean): MutableList<Code
return mutableListOf()
}
} else {
@Suppress("DEPRECATION")
Array(MediaCodecList.getCodecCount()) { i -> MediaCodecList.getCodecInfoAt(i) }
try {
@Suppress("DEPRECATION")
Array(MediaCodecList.getCodecCount()) { i -> MediaCodecList.getCodecInfoAt(i) }
} catch (e: Exception) {
return mutableListOf()
}
}
}

if (SDK_INT in 21..23 && mediaCodecInfos.find { it.name.endsWith("secure") } == null) {
// Some devices don't list secure decoders on API 21 with a newer way of querying codecs,
// but potentially could also happen on API levels 22 and 23.
// In that case try the old way.
try {
@Suppress("DEPRECATION")
val oldCodecInfos = Array(MediaCodecList.getCodecCount())
{ i -> MediaCodecList.getCodecInfoAt(i) }.filter { it.name.endsWith("secure") }
mediaCodecInfos += oldCodecInfos
} catch (e: Exception) {}
}

if (SDK_INT in 22..25 && Build.DEVICE == "R9"
&& mediaCodecInfos.find { it.name == GOOGLE_RAW_DECODER } == null
&& mediaCodecInfos.find { it.name == MEDIATEK_RAW_DECODER } != null) {
// Oppo R9 does not list a generic raw audio decoder, yet it can be instantiated by name.
try {
val rawMediaCodec = MediaCodec.createByCodecName(GOOGLE_RAW_DECODER)
//noinspection NewApi
mediaCodecInfos += rawMediaCodec.codecInfo
} catch (e: Exception) {}
}

val showAliases = prefs.getBoolean("show_aliases", false)
val filteringOption = prefs.getString("filter_type", "2")!!.toInt()
var codecSimpleInfoList = ArrayList<CodecSimpleInfo>()
Expand Down Expand Up @@ -447,12 +476,12 @@ private fun adjustMaxInputChannelCount(codecId: String, codecName: String, maxCh
}
}

if (SDK_INT < 28) {
if (CAN_USE_REFLECTION_FOR_MCAPABILITIESINFO) {
/*
mCapabilitiesInfo, a private MediaFormat instance hidden in MediaCodecInfo,
can actually provide max input channel count (as well as other useful info).
Unfortunately, with P restricting non-API usage via reflection, I can only hope
that everything will work fine on newer versions.
Android 9.0 put it on a dark greylist, though, so it can't be easily accessed anymore
(although it is bypassed on a non-store mobile flavor). Newer versions are SOL here.
*/
try {
val capabilitiesInfo = capabilities::class.java.getDeclaredField("mCapabilitiesInfo")
Expand All @@ -462,8 +491,7 @@ private fun adjustMaxInputChannelCount(codecId: String, codecName: String, maxCh
if (mediaFormat.containsKey("max-channel-count")) {
return mediaFormat.getString("max-channel-count")!!.toInt()
}
} catch (e: Exception) {
}
} catch (e: Exception) {}
}

if (codecId.endsWith("flac") || codecId.endsWith("alac")) {
Expand Down Expand Up @@ -582,7 +610,7 @@ private fun addColorFormats(capabilities: MediaCodecInfo.CodecCapabilities, code
private fun getFormattedColorProfileString(context: Context, colorFormat: String, colorFormatInt: Int): String {
val prefs = PreferenceManager.getDefaultSharedPreferences(context)

return when (prefs.getString("known_values_color_profiles", "0")!!.toInt()) {
return when (prefs.getString("known_values_color_profiles", "1")!!.toInt()) {
0 -> colorFormat
1 -> "$colorFormat (${colorFormatInt.toHexHstring()})"
else -> "$colorFormat ($colorFormatInt)"
Expand All @@ -592,7 +620,7 @@ private fun getFormattedColorProfileString(context: Context, colorFormat: String
@RequiresApi(21)
private fun getMaxResolution(codecId: String, videoCapabilities: MediaCodecInfo.VideoCapabilities): IntArray {
val maxWidth = videoCapabilities.supportedWidths.upper
val maxHeight = videoCapabilities.getSupportedHeightsFor(maxWidth).upper
val maxHeight = videoCapabilities.supportedHeights.upper
val defaultResolution = intArrayOf(maxWidth, maxHeight)

return if (!areCapabilitiesUnknown(videoCapabilities)) {
Expand Down Expand Up @@ -803,7 +831,7 @@ private fun getProfileLevels(context: Context, codecId: String, codecName: Strin
private fun getFormattedProfileLevelString(context: Context, profile: String?, profileInt: Int,
level: String?, levelInt: Int): String {
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
val option = prefs.getString("known_values_profile_levels", "0")!!.toInt()
val option = prefs.getString("known_values_profile_levels", "1")!!.toInt()
val unknownString = context.getString(R.string.unknown)

val profileString = when (option) {
Expand Down Expand Up @@ -872,7 +900,7 @@ private fun getMaxVP9ProfileLevel(capabilities: MediaCodecInfo.CodecCapabilities
}

private fun isVendor(codecInfo: MediaCodecInfo): Boolean {
val codecName = codecInfo.name.toLowerCase(Locale.ENGLISH)
val codecName = codecInfo.name.lowercase(Locale.ENGLISH)
return (!codecName.startsWith("omx.google.")
&& !codecName.startsWith("c2.android.")
&& !codecName.startsWith("c2.google.")
Expand All @@ -885,7 +913,7 @@ private fun isSoftwareOnly(codecInfo: MediaCodecInfo): Boolean {
return codecInfo.isSoftwareOnly
}

val codecName = codecInfo.name.toLowerCase(Locale.ENGLISH)
val codecName = codecInfo.name.lowercase(Locale.ENGLISH)

// Broadcom codecs which specifically mention HW acceleration in their names
if (codecName.contains("omx.brcm.video", true) && codecName.contains("hw", true)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ enum class DrmVendor(val uuid: UUID,
R.string.drm_property_hdcp_level to "hdcpLevel",
R.string.drm_property_max_hdcp_level to "maxHdcpLevel",
R.string.drm_property_open_sessions to "numberOfOpenSessions",
R.string.drm_property_max_sessions to "maxNumberOfSessions"
R.string.drm_property_max_sessions to "maxNumberOfSessions",
R.string.drm_property_current_srm_version to "CurrentSRMVersion",
R.string.drm_property_srm_update_support to "SRMUpdateSupport"
)

val WIDEVINE_BYTE_ARRAY_PROPERTIES = mapOf(
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/java/com/parseus/codecinfo/utils/Extensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import android.media.MediaCodecInfo
import java.util.*

fun Context.isTv(): Boolean {
val uiModeManager = getSystemService(Context.UI_MODE_SERVICE) as UiModeManager
return uiModeManager.currentModeType == Configuration.UI_MODE_TYPE_TELEVISION
val uiModeManager = getSystemService(Context.UI_MODE_SERVICE) as? UiModeManager
return uiModeManager?.currentModeType == Configuration.UI_MODE_TYPE_TELEVISION
}

fun Int.toKiloHertz(): Float {
Expand All @@ -26,7 +26,7 @@ fun Int.toBytesPerSecond(): String {
}

fun Int.toHexHstring(): String {
return "0x${this.toString(16).toUpperCase(Locale.getDefault())}"
return "0x${this.toString(16).uppercase(Locale.getDefault())}"
}

fun ByteArray.toHexString(): String {
Expand Down
20 changes: 20 additions & 0 deletions app/src/main/res/raw/known_problems_list.json
Original file line number Diff line number Diff line change
Expand Up @@ -447,5 +447,25 @@
"https://github.com/google/ExoPlayer/issues/4519",
"https://github.com/google/ExoPlayer/pull/5216"
]
},
{
"id": 18,
"codec_name": "OMX.google.raw.decoder",
"description": "This device does not list a generic raw audio decoder, yet it can be instantiated by name.",
"versions": [
{
"op": "<",
"value": 26
}
],
"devices": [
{
"op": "equals",
"value": "R9"
}
],
"urls": [
"https://github.com/google/ExoPlayer/issues/5782"
]
}
]
2 changes: 1 addition & 1 deletion app/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

<dimen name="list_baseline_primary">28dp</dimen>
<dimen name="list_baseline_secondary">20dp</dimen>
<dimen name="list_content_padding">16dp</dimen>
<dimen name="list_content_horizontal_padding">16dp</dimen>

</resources>
Loading

0 comments on commit 6f383ab

Please sign in to comment.