Skip to content

Commit

Permalink
feat: show warning on A15 about new screenrecord restrictions & moder…
Browse files Browse the repository at this point in the history
…nize code base
  • Loading branch information
timschneeb committed Dec 6, 2024
1 parent a565624 commit 79c05c7
Show file tree
Hide file tree
Showing 11 changed files with 103 additions and 22 deletions.
13 changes: 12 additions & 1 deletion .idea/gradle.xml

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

7 changes: 4 additions & 3 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ android {
targetSdk = AndroidConfig.targetSdk
versionCode = AndroidConfig.versionCode
versionName = AndroidConfig.versionName
ndkVersion = "23.1.7779620"

manifestPlaceholders["label"] = "RootlessJamesDSP"

Expand Down Expand Up @@ -137,12 +138,12 @@ android {
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

kotlinOptions {
jvmTarget = "11"
jvmTarget = "17"
}

buildFeatures {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,23 @@ package me.timschneeberger.rootlessjamesdsp.activity

import android.Manifest
import android.annotation.SuppressLint
import android.content.*
import android.content.ActivityNotFoundException
import android.content.BroadcastReceiver
import android.content.ComponentName
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.content.ServiceConnection
import android.content.SharedPreferences
import android.media.projection.MediaProjectionManager
import android.net.Uri
import android.os.*
import android.os.Build
import android.os.Bundle
import android.os.IBinder
import android.os.PersistableBundle
import android.view.HapticFeedbackConstants
import android.widget.CheckBox
import android.widget.LinearLayout
import androidx.activity.result.ActivityResultLauncher
import androidx.activity.result.contract.ActivityResultContracts
import androidx.annotation.RequiresApi
Expand Down Expand Up @@ -68,7 +80,7 @@ import me.timschneeberger.rootlessjamesdsp.view.FloatingToggleButton
import org.koin.core.component.inject
import timber.log.Timber
import java.io.File
import java.util.*
import java.util.Timer
import kotlin.concurrent.schedule


Expand Down Expand Up @@ -370,6 +382,10 @@ class MainActivity : BaseActivity() {
}
}

if (isRootless() && SdkCheck.isVanillaIceCream) {
showAndroid15Alert()
}

dspFragment.setUpdateCardOnClick { updateManager.installUpdate(this) }
dspFragment.setUpdateCardOnCloseClick(::dismissUpdate)
checkForUpdates()
Expand Down Expand Up @@ -437,6 +453,36 @@ class MainActivity : BaseActivity() {
binding.powerToggle.isToggled = processorService != null
}

private fun showAndroid15Alert() {
if(prefsVar.get<Boolean>(R.string.key_android15_screenrecord_restriction_seen))
return

val checkBox = CheckBox(this).apply {
text = getString(R.string.never_show_warning_again)
isChecked = false
}

MaterialAlertDialogBuilder(this)
.setTitle(R.string.android_15_screenshare_warning_title)
.setMessage(R.string.android_15_screenshare_warning)
.setView(
LinearLayout(this).apply {
orientation = LinearLayout.VERTICAL
setPadding(16, 16, 16, 16)
addView(checkBox)
}
)
.setPositiveButton(R.string.tutorial) { dialog, _ ->
prefsVar.set(R.string.key_android15_screenrecord_restriction_seen, checkBox.isChecked)
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("https://youtu.be/rVM13aY2rwU?t=31")))
}
.setNegativeButton(R.string.close) { dialog, _ ->
prefsVar.set(R.string.key_android15_screenrecord_restriction_seen, checkBox.isChecked)
dialog.dismiss()
}
.show()
}

private fun checkForUpdates() {
if(!isRoot() ||
prefsVar.get<Long>(R.string.key_update_check_timeout) > (System.currentTimeMillis() / 1000L)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ class RootlessAudioProcessorService : BaseAudioProcessorService() {
}
}

private fun loadFromPreferences(key: String){
private fun loadFromPreferences(key: String?){
when (key) {
getString(R.string.key_powersave_suspend) -> {
suspendOnIdle = preferences.get<Boolean>(R.string.key_powersave_suspend)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import me.timschneeberger.rootlessjamesdsp.BuildConfig
import me.timschneeberger.rootlessjamesdsp.R
import me.timschneeberger.rootlessjamesdsp.session.dump.data.ISessionInfoDump
import me.timschneeberger.rootlessjamesdsp.session.dump.data.ISessionPolicyInfoDump
import me.timschneeberger.rootlessjamesdsp.session.dump.provider.*
import me.timschneeberger.rootlessjamesdsp.session.dump.provider.AudioFlingerServiceDumpProvider
import me.timschneeberger.rootlessjamesdsp.session.dump.provider.AudioPolicyServiceDumpProvider
import me.timschneeberger.rootlessjamesdsp.session.dump.provider.AudioServiceDumpProvider
import me.timschneeberger.rootlessjamesdsp.utils.preferences.Preferences
import org.koin.core.component.KoinComponent
import org.koin.core.component.inject
Expand Down Expand Up @@ -94,7 +96,7 @@ class DumpManager constructor(val context: Context): KoinComponent {
return dump
}

private fun loadFromPreferences(key: String){
private fun loadFromPreferences(key: String?){
when (key) {
context.getString(R.string.key_session_detection_method) -> {
val method = R.string.key_session_detection_method.let {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,33 @@
package me.timschneeberger.rootlessjamesdsp.session.shared

import android.annotation.SuppressLint
import android.content.*
import android.content.BroadcastReceiver
import android.content.ComponentName
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.content.SharedPreferences
import android.media.AudioManager
import android.media.AudioPlaybackConfiguration
import android.media.audiofx.AudioEffect
import android.media.session.MediaController
import android.media.session.MediaSessionHidden
import android.media.session.MediaSessionManager
import android.os.*
import android.os.Handler
import android.os.Looper
import androidx.annotation.CallSuper
import androidx.core.app.NotificationManagerCompat
import androidx.core.content.getSystemService
import dev.rikka.tools.refine.Refine
import kotlinx.coroutines.*
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock
import me.timschneeberger.rootlessjamesdsp.R
import me.timschneeberger.rootlessjamesdsp.session.dump.DumpManager
import me.timschneeberger.rootlessjamesdsp.model.preference.SessionUpdateMode
import me.timschneeberger.rootlessjamesdsp.service.NotificationListenerService
import me.timschneeberger.rootlessjamesdsp.session.dump.DumpManager
import me.timschneeberger.rootlessjamesdsp.session.dump.data.ISessionInfoDump
import me.timschneeberger.rootlessjamesdsp.utils.Constants
import me.timschneeberger.rootlessjamesdsp.utils.extensions.ContextExtensions.registerLocalReceiver
Expand Down Expand Up @@ -105,7 +113,7 @@ abstract class BaseSessionManager(protected val context: Context) : DumpManager.
context.unregisterLocalReceiver(this)
}

private fun loadFromPreferences(key: String){
private fun loadFromPreferences(key: String?){
when (key) {
context.getString(R.string.key_session_continuous_polling) -> {
sessionUpdateMode =
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/keys.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<!-- Internal -->
<string name="key_first_boot" translatable="false">first_boot</string>
<string name="key_snooze_translation_notice" translatable="false">snooze_translation_notice</string>
<string name="key_android15_screenrecord_restriction_seen" translatable="false">android15_screenrecord_restriction_seen</string>
<string name="key_update_check_timeout" translatable="false">update_check_timeout</string>
<string name="key_update_check_skip" translatable="false">update_check_skip</string>
<string name="key_reset_proc_mode_fix_applied" translatable="false">reset_proc_mode_fix_applied</string>
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
<string name="success">Success</string>
<string name="open">Open</string>
<string name="close">Close</string>
<string name="tutorial">Tutorial</string>
<string name="never_show_warning_again">Never show this warning again</string>
<string name="delete">Delete</string>
<string name="copy">Copy</string>
<string name="paste">Paste</string>
Expand Down Expand Up @@ -650,4 +652,12 @@
<string name="version_mismatch_root_description">The JamesDSP magisk package installed on your device is outdated and not supported by this app anymore.\n\nPlease retrieve the latest JamesDSP magisk package ZIP and install it via Magisk.\nNote that the magisk package may replace this app with the official JamesDSP app.\n\nDo you want to visit the download website for the Magisk packages now?</string>
<string name="version_mismatch_root_toast">Failed to start. The installed JamesDSP magisk package is too old and not supported by this app anymore.</string>

<!-- Android 15 screenshare restriction warning -->
<string name="android_15_screenshare_warning_title">Android 15 compatibility notice</string>
<string name="android_15_screenshare_warning">Android 15 introduces a new screen recording restriction that will redact all sensitive information (e.g. in your notifications) while an app is using the screen record permission.
Even though this app only records system audio, it is still affected by this restriction.

To workaround this issue, you can enable \'Disable screen share protections\' in the system developer settings.
Tap on \'Tutorial\' below for detailed instructions.</string>

</resources>
6 changes: 3 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ buildscript {
maven("https://jitpack.io")
}
dependencies {
classpath("com.android.tools.build:gradle:7.4.2")
classpath("com.android.tools.build:gradle:8.7.3")
classpath("com.google.gms:google-services:4.3.15")
classpath("com.google.firebase:firebase-crashlytics-gradle:2.9.4")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.10")
}
}

plugins {
id("com.android.application") version "7.4.2" apply false
id("com.android.library") version "7.4.2" apply false
id("com.android.application") version "8.7.3" apply false
id("com.android.library") version "8.7.3" apply false
id("org.jetbrains.kotlin.android") version "1.8.10" apply false
}

Expand Down
4 changes: 3 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@ kotlin.code.style=official
# resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library
android.nonTransitiveRClass=true
android.enableJetifier=false
android.enableJetifier=false
android.defaults.buildfeatures.buildconfig=true
android.nonFinalResIds=false
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Tue Sep 20 21:31:15 CEST 2022
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME

0 comments on commit 79c05c7

Please sign in to comment.