Your phone, on your command. Gotcha is world's first fully on-device AI copilot for Android that turns natural language into real device actions — safely.
feat(build): raise minSdk from 26 to 30 (Android 11)
Durganshuc8d5de127361
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex 7b8fd63..855a181 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -148,13 +148,10 @@ jobs:strategy:fail-fast: falsematrix:- # Mirrors the GMD "full" group in app/build.gradle.kts. API 27/30 use- # plain default images (no usable ATD image at those levels — see the- # notes in build.gradle.kts); 33/34 use ATD.+ # Mirrors the GMD "full" group in app/build.gradle.kts. API 30 (the+ # app's minSdk) uses the plain default image — no usable ATD image at+ # that level, see the notes in build.gradle.kts; 33/34 use ATD.include:- - api-level: 27- target: default- profile: pixel_2- api-level: 30target: defaultprofile: pixel_2diff --git a/RUNNING.md b/RUNNING.mdindex 0cd05cb..9420906 100644--- a/RUNNING.md+++ b/RUNNING.md@@ -11,7 +11,7 @@ A step-by-step guide to build, run, and configure the Gotcha Android app.| Android Studio | Hedgehog (2023.1) or newer — this project uses AGP 8.2.2 / Gradle 8.4 || JDK | 17 (bundled with recent Android Studio; the project targets Java 17) || Android SDK | Platform 34 (Android 14) installed via SDK Manager |-| A device | A physical phone **or** an emulator running **API 26 (Android 8.0) or higher** |+| A device | A physical phone **or** an emulator running **API 30 (Android 11) or higher** |The project already has a `local.properties` pointing at an SDK:```@@ -33,7 +33,7 @@ If sync succeeds, `app` appears as a run configuration in the toolbar.**Option A — Emulator (easiest):**1. **Tools → Device Manager → Create Device**.-2. Pick e.g. *Pixel 7*, then a system image with **API 26+** (API 34 recommended).+2. Pick e.g. *Pixel 7*, then a system image with **API 30+** (API 34 recommended).Prefer a **Google APIs / Play** image so the dialer, wallpaper, and other apps exist.3. Start the emulator (▶ in Device Manager).diff --git a/app/build.gradle.kts b/app/build.gradle.ktsindex 0d34cce..2ea3c38 100644--- a/app/build.gradle.kts+++ b/app/build.gradle.kts@@ -19,7 +19,7 @@ android {defaultConfig {applicationId = "com.gotcha"- minSdk = 26+ minSdk = 30targetSdk = 34versionCode = 1versionName = "0.1.0"@@ -91,20 +91,9 @@ android {animationsDisabled = truemanagedDevices {localDevices {- create("api27") {- device = "Pixel 2"- apiLevel = 27- systemImageSource = "aosp"- }- // Android 10 — no ATD image at this API level; falls back to full aosp.- create("api29") {- device = "Pixel 2"- apiLevel = 29- systemImageSource = "aosp"- }- // Android 11 — the aosp-atd x86 image for this API level appears to hang+ // Android 11 (minSdk) — the aosp-atd x86 image for this API level appears to hang// on boot on Windows/WHPX (confirmed: qemu process alive but memory flat,- // never progresses); the plain aosp x86 image (same as api29) boots fine.+ // never progresses); the plain aosp x86 image boots fine.create("api30") {device = "Pixel 2"apiLevel = 30@@ -147,15 +136,13 @@ android {targetDevices.add(allDevices["api34"])}create("full") {- targetDevices.add(allDevices["api27"])targetDevices.add(allDevices["api30"])targetDevices.add(allDevices["api33"])targetDevices.add(allDevices["api34"])}- // Android 10 through Android 16 — the range requested for manual- // multi-version verification. Excludes api27 (Android 8.1, minSdk-only).- create("android10to16") {- targetDevices.add(allDevices["api29"])+ // Android 11 (minSdk) through Android 16 — the range requested for manual+ // multi-version verification.+ create("android11to16") {targetDevices.add(allDevices["api30"])targetDevices.add(allDevices["api31"])targetDevices.add(allDevices["api33"])diff --git a/app/src/main/java/com/gotcha/MainActivity.kt b/app/src/main/java/com/gotcha/MainActivity.ktindex 6290c17..021216f 100644--- a/app/src/main/java/com/gotcha/MainActivity.kt+++ b/app/src/main/java/com/gotcha/MainActivity.kt@@ -115,9 +115,7 @@ class MainActivity : ComponentActivity() {lifecycleOwner = this// Some OEM skins (e.g. MIUI) force-dark light-themed apps even when the// theme opts out; disabling on the decorView covers those cases too.- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {- window.decorView.isForceDarkAllowed = false- }+ window.decorView.isForceDarkAllowed = falsesettingsRepository = SettingsRepository(this)samosaAuthManager = SamosaAuthManager(applicationContext, settingsRepository)openChatRequested = intent?.getBooleanExtra(EXTRA_OPEN_CHAT, false) == true@@ -156,12 +154,10 @@ class MainActivity : ComponentActivity() {if (ScreenPerception.mediaProjectionResultData == null &&!prefs.getBoolean(KEY_SUPPRESS_MEDIA_PROJECTION_PROMPT, false)) {- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {- val mpManager = getSystemService(- Context.MEDIA_PROJECTION_SERVICE- ) as android.media.projection.MediaProjectionManager- mediaProjectionLauncher.launch(mpManager.createScreenCaptureIntent())- }+ val mpManager = getSystemService(+ Context.MEDIA_PROJECTION_SERVICE+ ) as android.media.projection.MediaProjectionManager+ mediaProjectionLauncher.launch(mpManager.createScreenCaptureIntent())}}@@ -206,17 +202,10 @@ class MainActivity : ComponentActivity() {Intent(AndroidSettings.ACTION_NOTIFICATION_LISTENER_SETTINGS))ToolResult.ALL_FILES_ACCESS -> startActivity(- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {- Intent(- AndroidSettings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION,- Uri.parse("package:$packageName")- )- } else {- Intent(- AndroidSettings.ACTION_APPLICATION_DETAILS_SETTINGS,- Uri.parse("package:$packageName")- )- }+ Intent(+ AndroidSettings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION,+ Uri.parse("package:$packageName")+ ))ToolResult.OVERLAY_ACCESS -> startActivity(Intent(@@ -242,12 +231,10 @@ class MainActivity : ComponentActivity() {Toast.LENGTH_SHORT).show()"special:screenshot_consent" -> {- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {- val mpManager = getSystemService(- Context.MEDIA_PROJECTION_SERVICE- ) as android.media.projection.MediaProjectionManager- mediaProjectionLauncher.launch(mpManager.createScreenCaptureIntent())- }+ val mpManager = getSystemService(+ Context.MEDIA_PROJECTION_SERVICE+ ) as android.media.projection.MediaProjectionManager+ mediaProjectionLauncher.launch(mpManager.createScreenCaptureIntent())}ToolResult.HEALTH_CONNECT -> requestHealthConnect()// Runtime permissions are mapped in Settings → Permissions; skip here.@@ -588,10 +575,6 @@ class MainActivity : ComponentActivity() {add(android.Manifest.permission.WRITE_CONTACTS)add(android.Manifest.permission.READ_CALENDAR)add(android.Manifest.permission.WRITE_CALENDAR)- if (Build.VERSION.SDK_INT <= 29) {- add(android.Manifest.permission.READ_EXTERNAL_STORAGE)- add(android.Manifest.permission.WRITE_EXTERNAL_STORAGE)- }if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {add(android.Manifest.permission.READ_MEDIA_IMAGES)}diff --git a/app/src/main/java/com/gotcha/agent/ScreenSnapshot.kt b/app/src/main/java/com/gotcha/agent/ScreenSnapshot.ktindex 3799aa1..cf9498b 100644--- a/app/src/main/java/com/gotcha/agent/ScreenSnapshot.kt+++ b/app/src/main/java/com/gotcha/agent/ScreenSnapshot.kt@@ -1,7 +1,6 @@package com.gotcha.agentimport android.graphics.Bitmap-import android.os.Buildimport com.gotcha.service.GotchaAccessibilityServiceimport kotlinx.coroutines.Dispatchersimport kotlinx.coroutines.delay@@ -19,19 +18,17 @@ object ScreenSnapshot {private const val RATE_LIMIT_RETRY_DELAY_MS = 1100L/** True when the Gotcha accessibility service is enabled and bound. */- fun isAvailable(): Boolean =- Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && GotchaAccessibilityService.instance != null+ fun isAvailable(): Boolean = GotchaAccessibilityService.instance != null/*** Capture the current screen as a downscaled JPEG base64 string via the* accessibility screenshot API (API 30+). Returns null if unavailable- * (older API, service not bound, or capture failed).+ * (service not bound, or capture failed).** The accessibility screenshot API is rate-limited (roughly one call per second),* so a single failure is retried once after a short delay.*/suspend fun captureScreenBase64(): String? {- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) return nullval service = GotchaAccessibilityService.instance ?: return nullvar bitmap = service.takeScreenshotBitmap()if (bitmap == null) {diff --git a/app/src/main/java/com/gotcha/data/GotchaStorage.kt b/app/src/main/java/com/gotcha/data/GotchaStorage.ktindex 72cb73f..be9d891 100644--- a/app/src/main/java/com/gotcha/data/GotchaStorage.kt+++ b/app/src/main/java/com/gotcha/data/GotchaStorage.kt@@ -5,7 +5,6 @@ import android.content.Contextimport android.graphics.Bitmapimport android.media.MediaScannerConnectionimport android.net.Uri-import android.os.Buildimport android.os.Environmentimport android.os.ParcelFileDescriptorimport android.provider.MediaStore@@ -136,9 +135,7 @@ object GotchaStorage {val values = ContentValues().apply {put(MediaStore.MediaColumns.DISPLAY_NAME, fileName)put(MediaStore.MediaColumns.MIME_TYPE, "image/png")- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {- put(MediaStore.MediaColumns.RELATIVE_PATH, Environment.DIRECTORY_PICTURES + "/Gotcha")- }+ put(MediaStore.MediaColumns.RELATIVE_PATH, Environment.DIRECTORY_PICTURES + "/Gotcha")}val resolver = context.contentResolverval uri = resolver.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values)@@ -150,10 +147,10 @@ object GotchaStorage {}sealed class RecordingTarget {- /** Pre-Q direct filesystem path, or a caller-supplied [FileResolver] path. */+ /** A caller-supplied [FileResolver] path written to directly. */data class DirectFile(val file: File) : RecordingTarget()- /** Q+ MediaStore entry; [MediaRecorder] writes through the held fd. */+ /** MediaStore entry; [MediaRecorder] writes through the held fd. */data class MediaStoreEntry(val uri: Uri, val pfd: ParcelFileDescriptor, val displayPath: String) :RecordingTarget()}@@ -163,28 +160,23 @@ object GotchaStorage {* (visible to the system Recorder/Files apps), not the per-chat working* directory.*- * API 29+ has no direct filesystem access to public folders without "All+ * There is no direct filesystem access to public folders without "All* files access", so recordings go through a MediaStore insert + file* descriptor instead; [MediaRecorder.setOutputFile] accepts that fd directly.*/fun createRecordingTarget(context: Context, fileName: String): RecordingTarget {- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {- val values = ContentValues().apply {- put(MediaStore.MediaColumns.DISPLAY_NAME, fileName)- put(MediaStore.MediaColumns.MIME_TYPE, "audio/mp4")- put(MediaStore.MediaColumns.RELATIVE_PATH, "Recordings")- put(MediaStore.MediaColumns.IS_PENDING, 1)- }- val resolver = context.contentResolver- val uri = resolver.insert(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, values)- ?: throw IOException("Could not create $fileName in Recordings")- val pfd = resolver.openFileDescriptor(uri, "w")- ?: throw IOException("Could not open Recordings for writing")- return RecordingTarget.MediaStoreEntry(uri, pfd, "Recordings/$fileName")+ val values = ContentValues().apply {+ put(MediaStore.MediaColumns.DISPLAY_NAME, fileName)+ put(MediaStore.MediaColumns.MIME_TYPE, "audio/mp4")+ put(MediaStore.MediaColumns.RELATIVE_PATH, "Recordings")+ put(MediaStore.MediaColumns.IS_PENDING, 1)}- val dir = Environment.getExternalStoragePublicDirectory("Recordings")- dir.mkdirs()- return RecordingTarget.DirectFile(File(dir, fileName))+ val resolver = context.contentResolver+ val uri = resolver.insert(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, values)+ ?: throw IOException("Could not create $fileName in Recordings")+ val pfd = resolver.openFileDescriptor(uri, "w")+ ?: throw IOException("Could not open Recordings for writing")+ return RecordingTarget.MediaStoreEntry(uri, pfd, "Recordings/$fileName")}/** Clears the pending flag so other apps can see/play the finished recording. */diff --git a/app/src/main/java/com/gotcha/service/AssistiveBallService.kt b/app/src/main/java/com/gotcha/service/AssistiveBallService.ktindex 5bf802e..c238094 100644--- a/app/src/main/java/com/gotcha/service/AssistiveBallService.kt+++ b/app/src/main/java/com/gotcha/service/AssistiveBallService.kt@@ -750,10 +750,6 @@ class AssistiveBallService : Service() {private fun takeScreenshot() {scope.launch(Dispatchers.IO) {- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) {- withContext(Dispatchers.Main) { overlay.showError("Screenshot requires Android 11+") }- return@launch- }try {val service = GotchaAccessibilityService.instanceif (service == null) {@@ -839,29 +835,25 @@ class AssistiveBallService : Service() {ServiceInfo.FOREGROUND_SERVICE_TYPE_MICROPHONE orServiceInfo.FOREGROUND_SERVICE_TYPE_SPECIAL_USE)- } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {+ } else {startForeground(NOTIFICATION_ID,notification,ServiceInfo.FOREGROUND_SERVICE_TYPE_MICROPHONE)- } else {- startForeground(NOTIFICATION_ID, notification)}}private fun createChannel() {- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {- val manager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager- if (manager.getNotificationChannel(CHANNEL_ID) == null) {- manager.createNotificationChannel(- NotificationChannel(- CHANNEL_ID,- "Assistive ball",- NotificationManager.IMPORTANCE_LOW- ).apply { description = "Keeps the floating assistive ball running." }- )- }+ val manager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager+ if (manager.getNotificationChannel(CHANNEL_ID) == null) {+ manager.createNotificationChannel(+ NotificationChannel(+ CHANNEL_ID,+ "Assistive ball",+ NotificationManager.IMPORTANCE_LOW+ ).apply { description = "Keeps the floating assistive ball running." }+ )}}diff --git a/app/src/main/java/com/gotcha/service/CallSessionController.kt b/app/src/main/java/com/gotcha/service/CallSessionController.ktindex 0aa87fd..7095c9d 100644--- a/app/src/main/java/com/gotcha/service/CallSessionController.kt+++ b/app/src/main/java/com/gotcha/service/CallSessionController.kt@@ -2,7 +2,6 @@ package com.gotcha.serviceimport android.content.Contextimport android.content.pm.PackageManager-import android.os.Buildimport android.os.VibrationEffectimport android.os.Vibratorimport androidx.core.content.ContextCompat@@ -563,7 +562,6 @@ class CallSessionController()private fun triggerEndVibration() {- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) returnval vibrator = appContext.getSystemService(Context.VIBRATOR_SERVICE) as? Vibratorif (vibrator?.hasVibrator() == true) {vibrator.vibrate(@@ -577,7 +575,6 @@ class CallSessionController(/** Distinct (longer, triple-buzz) pattern so an error doesn't feel like a normal turn end. */private fun triggerErrorVibration() {- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) returnval vibrator = appContext.getSystemService(Context.VIBRATOR_SERVICE) as? Vibratorif (vibrator?.hasVibrator() == true) {vibrator.vibrate(diff --git a/app/src/main/java/com/gotcha/service/GotchaAccessibilityService.kt b/app/src/main/java/com/gotcha/service/GotchaAccessibilityService.ktindex ba7f5cc..7f1f25b 100644--- a/app/src/main/java/com/gotcha/service/GotchaAccessibilityService.kt+++ b/app/src/main/java/com/gotcha/service/GotchaAccessibilityService.kt@@ -158,7 +158,6 @@ class GotchaAccessibilityService : AccessibilityService() {*/@RequiresApi(Build.VERSION_CODES.R)suspend fun takeScreenshotBitmap(): Bitmap? {- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) return nullreturn suspendCancellableCoroutine { cont ->try {takeScreenshot(@@ -466,7 +465,6 @@ class GotchaAccessibilityService : AccessibilityService() {gesture(x1, y1, x2, y2, durationMs)private fun gesture(x1: Float, y1: Float, x2: Float, y2: Float, durationMs: Long): Boolean {- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) return falseval path = Path().apply {moveTo(x1, y1)lineTo(x2, y2)@@ -484,8 +482,7 @@ class GotchaAccessibilityService : AccessibilityService() {"recents", "recent_apps" -> GLOBAL_ACTION_RECENTS"notifications" -> GLOBAL_ACTION_NOTIFICATIONS"quick_settings" -> GLOBAL_ACTION_QUICK_SETTINGS- "lock_screen" ->- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) GLOBAL_ACTION_LOCK_SCREEN else -1+ "lock_screen" -> GLOBAL_ACTION_LOCK_SCREENelse -> -1}return if (code >= 0) performGlobalAction(code) else falsediff --git a/app/src/main/java/com/gotcha/service/MediaProjectionService.kt b/app/src/main/java/com/gotcha/service/MediaProjectionService.ktindex df8bdbc..b9f922e 100644--- a/app/src/main/java/com/gotcha/service/MediaProjectionService.kt+++ b/app/src/main/java/com/gotcha/service/MediaProjectionService.kt@@ -13,7 +13,6 @@ import android.hardware.display.VirtualDisplayimport android.media.ImageReaderimport android.media.projection.MediaProjectionimport android.media.projection.MediaProjectionManager-import android.os.Buildimport android.os.IBinderimport android.util.DisplayMetricsimport android.util.Log@@ -52,11 +51,7 @@ class MediaProjectionService : Service() {val serviceIntent = Intent(context, MediaProjectionService::class.java)try {- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {- context.startForegroundService(serviceIntent)- } else {- context.startService(serviceIntent)- }+ context.startForegroundService(serviceIntent)Log.d("ScreenCapture", "MediaProjectionService started")} catch (e: Exception) {Log.e("ScreenCapture", "Failed to start MediaProjectionService: ${e.message}")@@ -88,15 +83,11 @@ class MediaProjectionService : Service() {override fun onCreate() {super.onCreate()createNotificationChannel()- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {- startForeground(- NOTIFICATION_ID,- buildNotification(),- android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION- )- } else {- startForeground(NOTIFICATION_ID, buildNotification())- }+ startForeground(+ NOTIFICATION_ID,+ buildNotification(),+ android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION+ )}override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {@@ -239,15 +230,13 @@ class MediaProjectionService : Service() {}private fun createNotificationChannel() {- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {- val channel = NotificationChannel(- CHANNEL_ID,- "Screenshot Capture",- NotificationManager.IMPORTANCE_LOW- ).apply { description = "One-shot screen capture" }- val nm = getSystemService(NotificationManager::class.java)- nm.createNotificationChannel(channel)- }+ val channel = NotificationChannel(+ CHANNEL_ID,+ "Screenshot Capture",+ NotificationManager.IMPORTANCE_LOW+ ).apply { description = "One-shot screen capture" }+ val nm = getSystemService(NotificationManager::class.java)+ nm.createNotificationChannel(channel)}private fun buildNotification(): Notification {diff --git a/app/src/main/java/com/gotcha/service/ScreenCompanionController.kt b/app/src/main/java/com/gotcha/service/ScreenCompanionController.ktindex 7f21929..83fa334 100644--- a/app/src/main/java/com/gotcha/service/ScreenCompanionController.kt+++ b/app/src/main/java/com/gotcha/service/ScreenCompanionController.kt@@ -6,7 +6,6 @@ import android.content.Intentimport android.content.IntentFilterimport android.database.ContentObserverimport android.net.Uri-import android.os.Buildimport android.os.Handlerimport android.os.Looperimport android.provider.MediaStore@@ -132,9 +131,7 @@ class ScreenCompanionController(if (screenText.isNotEmpty()) lastScreenTextHash = currentHashval visualQrEntities = try {- val bitmap = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {- GotchaAccessibilityService.instance?.takeScreenshotBitmap()- } else { null }+ val bitmap = GotchaAccessibilityService.instance?.takeScreenshotBitmap()if (bitmap != null) {val scanned = QrCodeScanner.scanBitmap(bitmap)bitmap.recycle()diff --git a/app/src/main/java/com/gotcha/service/ScreenLensController.kt b/app/src/main/java/com/gotcha/service/ScreenLensController.ktindex 4cdbbcd..12bac42 100644--- a/app/src/main/java/com/gotcha/service/ScreenLensController.kt+++ b/app/src/main/java/com/gotcha/service/ScreenLensController.kt@@ -5,7 +5,6 @@ import android.content.Contextimport android.graphics.Bitmapimport android.graphics.PixelFormatimport android.graphics.Rect-import android.os.Buildimport android.os.Handlerimport android.os.Looperimport android.view.Gravity@@ -40,10 +39,6 @@ class ScreenLensController(/** Begin a Lens capture: add the full-screen crop overlay and auto-annotate UI elements. */fun start() {- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) {- onError("Lens mode requires Android 11+")- return- }mainHandler.post {removeActionMenu()removeCropOverlay()@@ -519,13 +514,7 @@ class ScreenLensController(return android.util.Base64.encodeToString(baos.toByteArray(), android.util.Base64.NO_WRAP)}- private fun overlayType(): Int =- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {- WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY- } else {- @Suppress("DEPRECATION")- WindowManager.LayoutParams.TYPE_PHONE- }+ private fun overlayType(): Int = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAYprivate companion object {const val MIN_SELECTION_DP = 24diff --git a/app/src/main/java/com/gotcha/tools/AlarmReceiver.kt b/app/src/main/java/com/gotcha/tools/AlarmReceiver.ktindex 56e6c2e..4e91511 100644--- a/app/src/main/java/com/gotcha/tools/AlarmReceiver.kt+++ b/app/src/main/java/com/gotcha/tools/AlarmReceiver.kt@@ -5,7 +5,6 @@ import android.app.NotificationManagerimport android.content.BroadcastReceiverimport android.content.Contextimport android.content.Intent-import android.os.Buildimport androidx.core.app.NotificationCompatclass AlarmReceiver : BroadcastReceiver() {@@ -52,23 +51,21 @@ class AlarmReceiver : BroadcastReceiver() {}private fun createChannels(context: Context) {- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {- val nm = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager- nm.createNotificationChannel(- NotificationChannel(CHANNEL_ID, "Alarms & Timers", NotificationManager.IMPORTANCE_HIGH).apply {- enableVibration(true)- }- )- nm.createNotificationChannel(- NotificationChannel(- CHANNEL_ID_SILENT,- "Alarms & Timers (no vibration)",- NotificationManager.IMPORTANCE_HIGH- ).apply {- enableVibration(false)- }- )- }+ val nm = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager+ nm.createNotificationChannel(+ NotificationChannel(CHANNEL_ID, "Alarms & Timers", NotificationManager.IMPORTANCE_HIGH).apply {+ enableVibration(true)+ }+ )+ nm.createNotificationChannel(+ NotificationChannel(+ CHANNEL_ID_SILENT,+ "Alarms & Timers (no vibration)",+ NotificationManager.IMPORTANCE_HIGH+ ).apply {+ enableVibration(false)+ }+ )}companion object {diff --git a/app/src/main/java/com/gotcha/tools/AppsTool.kt b/app/src/main/java/com/gotcha/tools/AppsTool.ktindex 45f63c3..6360c8f 100644--- a/app/src/main/java/com/gotcha/tools/AppsTool.kt+++ b/app/src/main/java/com/gotcha/tools/AppsTool.kt@@ -8,7 +8,6 @@ import android.content.Intentimport android.content.pm.ApplicationInfoimport android.net.ConnectivityManagerimport android.net.Uri-import android.os.Buildimport android.os.Processimport android.util.Log@@ -229,20 +228,11 @@ class AppsTool(private val context: Context) {private fun hasUsageAccess(): Boolean {return try {val appOps = context.getSystemService(Context.APP_OPS_SERVICE) as AppOpsManager- val mode = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {- appOps.unsafeCheckOpNoThrow(- AppOpsManager.OPSTR_GET_USAGE_STATS,- Process.myUid(),- context.packageName- )- } else {- @Suppress("DEPRECATION")- appOps.checkOpNoThrow(- AppOpsManager.OPSTR_GET_USAGE_STATS,- Process.myUid(),- context.packageName- )- }+ val mode = appOps.unsafeCheckOpNoThrow(+ AppOpsManager.OPSTR_GET_USAGE_STATS,+ Process.myUid(),+ context.packageName+ )mode == AppOpsManager.MODE_ALLOWED} catch (_: Exception) {falsediff --git a/app/src/main/java/com/gotcha/tools/FileResolver.kt b/app/src/main/java/com/gotcha/tools/FileResolver.ktindex 90dd12d..89bd416 100644--- a/app/src/main/java/com/gotcha/tools/FileResolver.kt+++ b/app/src/main/java/com/gotcha/tools/FileResolver.kt@@ -1,9 +1,7 @@package com.gotcha.toolsimport android.content.Context-import android.os.Buildimport android.os.Environment-import androidx.core.content.ContextCompatimport java.io.File/**@@ -30,14 +28,6 @@ class FileResolver(private val context: Context) {"This operation needs \"All files access\" to read or write outside the app sandbox. " +"Go to Settings → Permissions → All Files Access and enable it, then ask again."- private const val READ_STORAGE_GUIDE =- "This operation needs storage read permission. " +- "Go to Settings → Permissions → Storage Read and grant it, then ask again."-- private const val WRITE_STORAGE_GUIDE =- "This operation needs storage write permission. " +- "Go to Settings → Permissions → Storage Write and grant it, then ask again."-private var workingDirOverride: String? = null/**@@ -82,8 +72,8 @@ class FileResolver(private val context: Context) {val canonical = canonicalPath(path, cwd)if (isInAppSandbox(canonical)) return ResolveResult.Ok(File(canonical))return when {- // API 30+: need MANAGE_EXTERNAL_STORAGE for broad shared-storage read- Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && !Environment.isExternalStorageManager() -> {+ // Need MANAGE_EXTERNAL_STORAGE for broad shared-storage read+ !Environment.isExternalStorageManager() -> {if (isBelowExternalStorage(canonical)) {ResolveResult.PermissionNeeded(ToolResult.permissionNeeded(ToolResult.ALL_FILES_ACCESS, ALL_FILES_ACCESS_GUIDE)@@ -92,20 +82,6 @@ class FileResolver(private val context: Context) {ResolveResult.Ok(File(canonical))}}- // API 23-29: need READ_EXTERNAL_STORAGE for shared-storage read- Build.VERSION.SDK_INT in 23..29 -> {- val has = hasPermission(android.Manifest.permission.READ_EXTERNAL_STORAGE)- if (!has && isBelowExternalStorage(canonical)) {- ResolveResult.PermissionNeeded(- ToolResult.permissionNeeded(- android.Manifest.permission.READ_EXTERNAL_STORAGE,- READ_STORAGE_GUIDE- )- )- } else {- ResolveResult.Ok(File(canonical))- }- }else -> ResolveResult.Ok(File(canonical))}}@@ -114,26 +90,12 @@ class FileResolver(private val context: Context) {val canonical = canonicalPath(path, cwd)if (isInAppSandbox(canonical)) return ResolveResult.Ok(File(canonical))return when {- // API 30+: need MANAGE_EXTERNAL_STORAGE for shared-storage write- Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && !Environment.isExternalStorageManager() -> {+ // Need MANAGE_EXTERNAL_STORAGE for shared-storage write+ !Environment.isExternalStorageManager() -> {ResolveResult.PermissionNeeded(ToolResult.permissionNeeded(ToolResult.ALL_FILES_ACCESS, ALL_FILES_ACCESS_GUIDE))}- // API 23-29: need WRITE_EXTERNAL_STORAGE for shared-storage write- Build.VERSION.SDK_INT in 23..29 -> {- val has = hasPermission(android.Manifest.permission.WRITE_EXTERNAL_STORAGE)- if (!has && isBelowExternalStorage(canonical)) {- ResolveResult.PermissionNeeded(- ToolResult.permissionNeeded(- android.Manifest.permission.WRITE_EXTERNAL_STORAGE,- WRITE_STORAGE_GUIDE- )- )- } else {- ResolveResult.Ok(File(canonical))- }- }else -> ResolveResult.Ok(File(canonical))}}@@ -141,14 +103,8 @@ class FileResolver(private val context: Context) {fun checkReadPermission(file: File): ToolResult? {val canonical = file.canonicalPathif (isInAppSandbox(canonical)) return null- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && !Environment.isExternalStorageManager()) {- if (isBelowExternalStorage(canonical)) {- return ToolResult.permissionNeeded(ToolResult.ALL_FILES_ACCESS, ALL_FILES_ACCESS_GUIDE)- }- }- if (Build.VERSION.SDK_INT in 23..29 && isBelowExternalStorage(canonical)) {- val perm = android.Manifest.permission.READ_EXTERNAL_STORAGE- if (!hasPermission(perm)) return ToolResult.permissionNeeded(perm, READ_STORAGE_GUIDE)+ if (!Environment.isExternalStorageManager() && isBelowExternalStorage(canonical)) {+ return ToolResult.permissionNeeded(ToolResult.ALL_FILES_ACCESS, ALL_FILES_ACCESS_GUIDE)}return null}@@ -156,13 +112,9 @@ class FileResolver(private val context: Context) {fun checkWritePermission(file: File): ToolResult? {val canonical = file.canonicalPathif (isInAppSandbox(canonical)) return null- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && !Environment.isExternalStorageManager()) {+ if (!Environment.isExternalStorageManager()) {return ToolResult.permissionNeeded(ToolResult.ALL_FILES_ACCESS, ALL_FILES_ACCESS_GUIDE)}- if (Build.VERSION.SDK_INT in 23..29 && isBelowExternalStorage(canonical)) {- val perm = android.Manifest.permission.WRITE_EXTERNAL_STORAGE- if (!hasPermission(perm)) return ToolResult.permissionNeeded(perm, WRITE_STORAGE_GUIDE)- }return null}@@ -203,10 +155,6 @@ class FileResolver(private val context: Context) {): Boolean = mime == "application/zip" || mime == "application/x-rar-compressed" || mime == "application/gzip"fun isDocumentMime(mime: String): Boolean = mime == "application/pdf"- private fun hasPermission(permission: String): Boolean =- ContextCompat.checkSelfPermission(context, permission) ==- android.content.pm.PackageManager.PERMISSION_GRANTED-private fun isInAppSandbox(canonical: String): Boolean {return appSandboxPaths.any { canonical.startsWith(it) }}diff --git a/app/src/main/java/com/gotcha/tools/MediaCaptureTool.kt b/app/src/main/java/com/gotcha/tools/MediaCaptureTool.ktindex 201ce4c..b4d9f96 100644--- a/app/src/main/java/com/gotcha/tools/MediaCaptureTool.kt+++ b/app/src/main/java/com/gotcha/tools/MediaCaptureTool.kt@@ -310,9 +310,6 @@ class MediaCaptureTool(private val context: Context) {"Recording is already paused. You may resume it with resume_audio_recording or stop it with stop_audio_recording.")}- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {- return ToolResult.error("Pause/resume requires Android 7.0+ (API 24).")- }return try {rec.pause()recordingPaused = true@@ -332,9 +329,6 @@ class MediaCaptureTool(private val context: Context) {"Recording is not paused. Use pause_audio_recording first, or stop the recording with stop_audio_recording.")}- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {- return ToolResult.error("Pause/resume requires Android 7.0+ (API 24).")- }return try {rec.resume()recordingPaused = falsediff --git a/app/src/main/java/com/gotcha/tools/OverlayTool.kt b/app/src/main/java/com/gotcha/tools/OverlayTool.ktindex 5a96397..3c93c5c 100644--- a/app/src/main/java/com/gotcha/tools/OverlayTool.kt+++ b/app/src/main/java/com/gotcha/tools/OverlayTool.kt@@ -3,7 +3,6 @@ package com.gotcha.toolsimport android.content.Contextimport android.graphics.Colorimport android.graphics.PixelFormat-import android.os.Buildimport android.os.Handlerimport android.os.Looperimport android.provider.Settings@@ -80,12 +79,7 @@ class OverlayTool(private val context: Context) {}private fun layoutParams(): WindowManager.LayoutParams {- val type = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {- WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY- } else {- @Suppress("DEPRECATION")- WindowManager.LayoutParams.TYPE_PHONE- }+ val type = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAYreturn WindowManager.LayoutParams(WindowManager.LayoutParams.WRAP_CONTENT,WindowManager.LayoutParams.WRAP_CONTENT,@@ -99,8 +93,7 @@ class OverlayTool(private val context: Context) {}}- private fun canDrawOverlays(): Boolean =- Build.VERSION.SDK_INT < Build.VERSION_CODES.M || Settings.canDrawOverlays(context)+ private fun canDrawOverlays(): Boolean = Settings.canDrawOverlays(context)private fun notEnabled() = ToolResult.permissionNeeded(ToolResult.OVERLAY_ACCESS,diff --git a/app/src/main/java/com/gotcha/tools/ScreenPerception.kt b/app/src/main/java/com/gotcha/tools/ScreenPerception.ktindex 5c3ea1d..721f65c 100644--- a/app/src/main/java/com/gotcha/tools/ScreenPerception.kt+++ b/app/src/main/java/com/gotcha/tools/ScreenPerception.kt@@ -6,7 +6,6 @@ import android.graphics.Canvasimport android.graphics.Colorimport android.graphics.Paintimport android.graphics.Rect-import android.os.Buildimport android.util.Base64import android.util.Logimport android.view.accessibility.AccessibilityNodeInfo@@ -133,7 +132,6 @@ object ScreenPerception {fun buildUiHierarchyText(maxElements: Int = 100): String {return try {val service = GotchaAccessibilityService.instance ?: return "(accessibility service not available)"- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) return "(requires API 18+)"val root = service.rootInActiveWindow ?: return "(no active window)"val elements = mutableListOf<UiElement>()collectElements(root, elements, maxElements)@@ -314,28 +312,26 @@ object ScreenPerception {private suspend fun captureRawBytes(): ByteArray? {// Path 1: AccessibilityService.takeScreenshot() — API 30+, no special perms.- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {- val service = GotchaAccessibilityService.instance- Log.d("ScreenCapture", "Path1: API>=30, service=${service != null}")- if (service != null) {- for (attempt in 1..2) {- Log.d("ScreenCapture", "Path1: takeScreenshotBitmap attempt $attempt")- val bitmap = service.takeScreenshotBitmap()- Log.d("ScreenCapture", "Path1: takeScreenshotBitmap returned ${bitmap != null}")- if (bitmap != null) {- val bytes = withContext(Dispatchers.Default) {- val stream = ByteArrayOutputStream()- bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream)- bitmap.recycle()- stream.toByteArray()- }- Log.d("ScreenCapture", "Path1: compressed to ${bytes.size} bytes")- if (bytes.isNotEmpty()) return bytes+ val service = GotchaAccessibilityService.instance+ Log.d("ScreenCapture", "Path1: service=${service != null}")+ if (service != null) {+ for (attempt in 1..2) {+ Log.d("ScreenCapture", "Path1: takeScreenshotBitmap attempt $attempt")+ val bitmap = service.takeScreenshotBitmap()+ Log.d("ScreenCapture", "Path1: takeScreenshotBitmap returned ${bitmap != null}")+ if (bitmap != null) {+ val bytes = withContext(Dispatchers.Default) {+ val stream = ByteArrayOutputStream()+ bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream)+ bitmap.recycle()+ stream.toByteArray()}- if (attempt < 2) delay(1100)+ Log.d("ScreenCapture", "Path1: compressed to ${bytes.size} bytes")+ if (bytes.isNotEmpty()) return bytes}- Log.w("ScreenCapture", "Path1: both attempts failed")+ if (attempt < 2) delay(1100)}+ Log.w("ScreenCapture", "Path1: both attempts failed")}// Path 2: MediaProjection — works on all devices if user granted consent.val projectionData = mediaProjectionResultDatadiff --git a/app/src/main/java/com/gotcha/tools/SystemTool.kt b/app/src/main/java/com/gotcha/tools/SystemTool.ktindex 5107557..4b35207 100644--- a/app/src/main/java/com/gotcha/tools/SystemTool.kt+++ b/app/src/main/java/com/gotcha/tools/SystemTool.kt@@ -5,7 +5,6 @@ import android.content.Intentimport android.content.IntentFilterimport android.net.wifi.WifiManagerimport android.os.BatteryManager-import android.os.Buildimport android.provider.Settingsclass SystemTool(private val context: Context) {@@ -110,11 +109,8 @@ class SystemTool(private val context: Context) {private fun openWifiSettings(): ToolResult {return try {- val intent = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {- Intent(Settings.Panel.ACTION_WIFI)- } else {- Intent(Settings.ACTION_WIFI_SETTINGS)- }.apply { addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) }+ val intent = Intent(Settings.Panel.ACTION_WIFI)+ .apply { addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) }context.startActivity(intent)ToolResult.ok("Opened the Wi-Fi settings panel so the user can toggle Wi-Fi.")} catch (e: Exception) {diff --git a/app/src/main/java/com/gotcha/ui/AssistiveBallOverlay.kt b/app/src/main/java/com/gotcha/ui/AssistiveBallOverlay.ktindex e7e7258..7470f33 100644--- a/app/src/main/java/com/gotcha/ui/AssistiveBallOverlay.kt+++ b/app/src/main/java/com/gotcha/ui/AssistiveBallOverlay.kt@@ -7,7 +7,6 @@ import android.graphics.Colorimport android.graphics.PixelFormatimport android.graphics.Typefaceimport android.graphics.drawable.GradientDrawable-import android.os.Buildimport android.os.Handlerimport android.os.Looperimport android.provider.Settings@@ -117,8 +116,7 @@ class AssistiveBallOverlay(context: Context) {)}- fun canShow(): Boolean =- Build.VERSION.SDK_INT < Build.VERSION_CODES.M || Settings.canDrawOverlays(appContext)+ fun canShow(): Boolean = Settings.canDrawOverlays(appContext)/*** Ball/ring/menu (and optionally the error/info card) visibility toggle.@@ -780,13 +778,7 @@ class AssistiveBallOverlay(context: Context) {} catch (_: Exception) { }}- private fun overlayType(): Int =- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {- WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY- } else {- @Suppress("DEPRECATION")- WindowManager.LayoutParams.TYPE_PHONE- }+ private fun overlayType(): Int = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAYprivate fun ballLayoutParams(): WindowManager.LayoutParams =WindowManager.LayoutParams(diff --git a/app/src/main/java/com/gotcha/ui/CallChatWindow.kt b/app/src/main/java/com/gotcha/ui/CallChatWindow.ktindex 55ed3dc..1fc69d8 100644--- a/app/src/main/java/com/gotcha/ui/CallChatWindow.kt+++ b/app/src/main/java/com/gotcha/ui/CallChatWindow.kt@@ -7,7 +7,6 @@ import android.content.Contextimport android.graphics.Colorimport android.graphics.PixelFormatimport android.graphics.drawable.GradientDrawable-import android.os.Buildimport android.os.Handlerimport android.os.Looperimport android.view.Gravity@@ -384,12 +383,7 @@ class CallChatWindow(context: Context) {val cx = (rootParams?.x ?: 0) + paddingPx + btnPx + marginPx + btnPx / 2val cy = (rootParams?.y ?: 0) + btnPx / 2- val type = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {- WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY- } else {- @Suppress("DEPRECATION")- WindowManager.LayoutParams.TYPE_PHONE- }+ val type = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAYval params = WindowManager.LayoutParams(ringSize,ringSize,@@ -476,12 +470,7 @@ class CallChatWindow(context: Context) {actionRingDrawable = drawableval view = View(appContext).apply { background = drawable }- val type = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {- WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY- } else {- @Suppress("DEPRECATION")- WindowManager.LayoutParams.TYPE_PHONE- }+ val type = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAYval params = WindowManager.LayoutParams(ringSize,ringSize,@@ -755,12 +744,7 @@ class CallChatWindow(context: Context) {// ---- Layout ----private fun layoutParams(): WindowManager.LayoutParams {- val type = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {- WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY- } else {- @Suppress("DEPRECATION")- WindowManager.LayoutParams.TYPE_PHONE- }+ val type = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAYval metrics = appContext.resources.displayMetricsreturn WindowManager.LayoutParams(WindowManager.LayoutParams.WRAP_CONTENT,diff --git a/app/src/main/java/com/gotcha/ui/ConfirmationOverlay.kt b/app/src/main/java/com/gotcha/ui/ConfirmationOverlay.ktindex 9f0687c..8b585e4 100644--- a/app/src/main/java/com/gotcha/ui/ConfirmationOverlay.kt+++ b/app/src/main/java/com/gotcha/ui/ConfirmationOverlay.kt@@ -4,7 +4,6 @@ import android.content.Contextimport android.graphics.Colorimport android.graphics.PixelFormatimport android.graphics.drawable.GradientDrawable-import android.os.Buildimport android.os.Handlerimport android.os.Looperimport android.provider.Settings@@ -35,8 +34,7 @@ class ConfirmationOverlay(context: Context) {private var view: View? = null/** Whether we currently hold the "Display over other apps" permission. */- fun canShow(): Boolean =- Build.VERSION.SDK_INT < Build.VERSION_CODES.M || Settings.canDrawOverlays(appContext)+ fun canShow(): Boolean = Settings.canDrawOverlays(appContext)fun show(summary: String, onAllow: () -> Unit, onDeny: () -> Unit) {mainHandler.post {@@ -113,12 +111,7 @@ class ConfirmationOverlay(context: Context) {}private fun layoutParams(): WindowManager.LayoutParams {- val type = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {- WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY- } else {- @Suppress("DEPRECATION")- WindowManager.LayoutParams.TYPE_PHONE- }+ val type = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY// FLAG_NOT_FOCUSABLE keeps us from stealing the keyboard, but the window still// receives touch events, so the Allow/Deny buttons remain tappable.return WindowManager.LayoutParams(diff --git a/app/src/main/java/com/gotcha/ui/PermissionItems.kt b/app/src/main/java/com/gotcha/ui/PermissionItems.ktindex 1570a15..0345a0a 100644--- a/app/src/main/java/com/gotcha/ui/PermissionItems.kt+++ b/app/src/main/java/com/gotcha/ui/PermissionItems.kt@@ -136,26 +136,15 @@ fun allPermissionGroups(): List<PermissionGroup> = listOf("Write files to shared storage",android.Manifest.permission.WRITE_EXTERNAL_STORAGE,null,- { c ->- if (Build.VERSION.SDK_INT <= 29) {- checkPerm(c, android.Manifest.permission.WRITE_EXTERNAL_STORAGE)- } else {- true // API 30+ uses MANAGE_EXTERNAL_STORAGE- }- }+ // API 30+ uses MANAGE_EXTERNAL_STORAGE instead; nothing to request here.+ { true }),PermissionItem("All Files Access","Full access to all files on device",null,"special:all_files_access",- { c ->- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {- Environment.isExternalStorageManager()- } else {- checkPerm(c, android.Manifest.permission.READ_EXTERNAL_STORAGE)- }- }+ { Environment.isExternalStorageManager() }))),@@ -197,15 +186,11 @@ fun allPermissionGroups(): List<PermissionGroup> = listOf(null,"special:usage_access",{ c ->- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {- val appOps = c.getSystemService(Context.APP_OPS_SERVICE) as? AppOpsManager- appOps?.checkOpNoThrow(- AppOpsManager.OPSTR_GET_USAGE_STATS,- android.os.Process.myUid(), c.packageName- ) == AppOpsManager.MODE_ALLOWED- } else {- true- }+ val appOps = c.getSystemService(Context.APP_OPS_SERVICE) as? AppOpsManager+ appOps?.unsafeCheckOpNoThrow(+ AppOpsManager.OPSTR_GET_USAGE_STATS,+ android.os.Process.myUid(), c.packageName+ ) == AppOpsManager.MODE_ALLOWED}),PermissionItem(diff --git a/app/src/main/java/com/gotcha/ui/PermissionsSection.kt b/app/src/main/java/com/gotcha/ui/PermissionsSection.ktindex 2b7b4d3..75f8421 100644--- a/app/src/main/java/com/gotcha/ui/PermissionsSection.kt+++ b/app/src/main/java/com/gotcha/ui/PermissionsSection.kt@@ -5,7 +5,6 @@ import android.content.ComponentNameimport android.content.Intentimport android.net.Uriimport android.net.VpnService-import android.os.Buildimport android.widget.Toastimport androidx.activity.compose.rememberLauncherForActivityResultimport androidx.activity.result.contract.ActivityResultContracts@@ -162,11 +161,8 @@ private fun openSpecialAccess(context: android.content.Context, marker: String,ToolResult.DND_ACCESS -> Intent(AndroidSettings.ACTION_NOTIFICATION_POLICY_ACCESS_SETTINGS)ToolResult.ACCESSIBILITY_ACCESS -> Intent(AndroidSettings.ACTION_ACCESSIBILITY_SETTINGS)ToolResult.NOTIFICATION_LISTENER_ACCESS -> Intent(AndroidSettings.ACTION_NOTIFICATION_LISTENER_SETTINGS)- ToolResult.ALL_FILES_ACCESS -> if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {+ ToolResult.ALL_FILES_ACCESS ->Intent(AndroidSettings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION, Uri.parse("package:$packageName"))- } else {- Intent(AndroidSettings.ACTION_APPLICATION_DETAILS_SETTINGS, Uri.parse("package:$packageName"))- }ToolResult.OVERLAY_ACCESS -> Intent(AndroidSettings.ACTION_MANAGE_OVERLAY_PERMISSION,Uri.parse("package:$packageName")diff --git a/app/src/main/java/com/gotcha/ui/ScreenCompanionPanelOverlay.kt b/app/src/main/java/com/gotcha/ui/ScreenCompanionPanelOverlay.ktindex d3e13e5..5c2dbc4 100644--- a/app/src/main/java/com/gotcha/ui/ScreenCompanionPanelOverlay.kt+++ b/app/src/main/java/com/gotcha/ui/ScreenCompanionPanelOverlay.kt@@ -6,7 +6,6 @@ import android.graphics.Colorimport android.graphics.PixelFormatimport android.graphics.Typefaceimport android.graphics.drawable.GradientDrawable-import android.os.Buildimport android.os.Handlerimport android.os.Looperimport android.view.Gravity@@ -239,11 +238,7 @@ class ScreenCompanionPanelOverlay(private val context: Context) {val params = WindowManager.LayoutParams(dp(320),dp(400),- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {- WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY- } else {- WindowManager.LayoutParams.TYPE_PHONE- },+ WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY,WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE orWindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH,PixelFormat.TRANSLUCENTdiff --git a/docs/RUNNING_TESTS.md b/docs/RUNNING_TESTS.mdindex 3a0ad9d..f28b242 100644--- a/docs/RUNNING_TESTS.md+++ b/docs/RUNNING_TESTS.md@@ -1,7 +1,7 @@# Running the Test SuiteOperational guide: environment setup, every way to run the tests, and every-gotcha hit while getting Android 10–16 (API 29–36) coverage working on this+gotcha hit while getting Android 11–16 (API 30–36) coverage working on thismachine (Windows, SDK at `%LOCALAPPDATA%\Android\Sdk`). For *why* this suitewas built the way it was, see [`TESTING_PLAN.md`](TESTING_PLAN.md).@@ -49,8 +49,7 @@ window ever appears. This is what CI uses.**Single Android version:**```bash-./gradlew :app:api29DebugAndroidTest # Android 10-./gradlew :app:api30DebugAndroidTest # Android 11+./gradlew :app:api30DebugAndroidTest # Android 11 (minSdk)./gradlew :app:api31DebugAndroidTest # Android 12./gradlew :app:api33DebugAndroidTest # Android 13./gradlew :app:api34DebugAndroidTest # Android 14@@ -58,14 +57,14 @@ window ever appears. This is what CI uses../gradlew :app:api36DebugAndroidTest # Android 16```-**All of Android 10–16 in one command:**+**All of Android 11–16 in one command:**```bash-./gradlew :app:android10to16GroupDebugAndroidTest+./gradlew :app:android11to16GroupDebugAndroidTest```**Other predefined groups** (in `app/build.gradle.kts` → `testOptions.managedDevices`):- `smokeGroupDebugAndroidTest` — just `api34`, for a fast PR-level check.-- `fullGroupDebugAndroidTest` — `api27` (Android 8.1, the app's `minSdk`), `api30`, `api33`, `api34`.+- `fullGroupDebugAndroidTest` — `api30` (Android 11, the app's `minSdk`), `api33`, `api34`.**Reports** land at `app/build/reports/androidTests/managedDevice/debug/<device>/index.html`per device (a combined summary too, if you ran a group).@@ -126,15 +125,16 @@ making a visible AVD from it):|---|---|---|| `LicenceNotAcceptedException` for a specific ATD package | That package's license isn't in `$SDK/licenses/` yet — most are covered by the generic `android-sdk-license`, but some ATD packages ship under a separate license id | `sdkmanager --licenses` (§1 step 3) || `api36Setup` fails: "System Image specified by api36 does not exist" | No `aosp-atd` image published for API 36 yet | Already fixed in `build.gradle.kts` — `api36` uses `systemImageSource = "google"` |-| `api30` hangs at ~96% for 10+ minutes, `adb devices` shows it `offline`, a real `qemu-system-x86_64-headless.exe` process is running but its memory usage is flat (not climbing) | The `aosp-atd` **32-bit x86** image for API 30 appears to hang on boot under Windows/WHPX. (API 31+ ATD images are all 64-bit and don't have this problem; API 29/30's plain `aosp` 32-bit images boot fine — it's specific to this one ATD package.) | Already fixed — `api30` uses `systemImageSource = "aosp"` instead of `"aosp-atd"` |-| Downloading the whole `android10to16Group` for the first time silently corrupts 2–3 of the images (missing `system.img` entirely, confirmed by inspecting the files on disk) | `maxConcurrentDevices` only throttles concurrent *emulator execution* — the SDK **download/setup phase still runs all devices in parallel**, and that concurrent download race corrupts some of them | Run `--max-workers=1` on the very first full-matrix run to force serial downloads, or (safer) run each `apiNN...` task individually once to populate the cache before ever using the combined group task |+| `api30` hangs at ~96% for 10+ minutes, `adb devices` shows it `offline`, a real `qemu-system-x86_64-headless.exe` process is running but its memory usage is flat (not climbing) | The `aosp-atd` **32-bit x86** image for API 30 appears to hang on boot under Windows/WHPX. (API 31+ ATD images are all 64-bit and don't have this problem; API 30's plain `aosp` 32-bit image boots fine — it's specific to this one ATD package.) | Already fixed — `api30` uses `systemImageSource = "aosp"` instead of `"aosp-atd"` |+| Downloading the whole `android11to16Group` for the first time silently corrupts 2–3 of the images (missing `system.img` entirely, confirmed by inspecting the files on disk) | `maxConcurrentDevices` only throttles concurrent *emulator execution* — the SDK **download/setup phase still runs all devices in parallel**, and that concurrent download race corrupts some of them | Run `--max-workers=1` on the very first full-matrix run to force serial downloads, or (safer) run each `apiNN...` task individually once to populate the cache before ever using the combined group task || `AccessibilityServiceTest.enablingViaSecureSettings_connectsService` fails, every API level, even waiting 45s | Confirmed structural, not timing: `GotchaAccessibilityService` cannot reliably self-bind while the app is under active instrumentation, even with the process pre-warmed and confirmed not in Android's "stopped" state. The identical sequence binds in 0–5s via plain `adb shell` outside instrumentation. This is a platform-level rough edge with `AccessibilityManagerService` + self-instrumented processes, not a bug in the app. Full writeup is in the test file's doc comment. | The whole class is now `@Ignore`'d, so runs report it as skipped rather than failed — a clean `BUILD SUCCESSFUL` with 5 passed / 1 skipped is the expected result. Don't re-investigate or un-ignore without addressing the platform limitation |## 6. Other test-suite paths (less exercised — verify before relying on them)-- **`scripts/test_matrix.sh`** — the local full-matrix script (Phase 5),- needed for API 26 (`minSdk`) coverage since GMD only supports API 27+.- Boots real AVDs serially via `adb`/`emulator` directly. Not run end-to-end+- **`scripts/test_matrix.sh`** — the local full-matrix script (Phase 5).+ Boots real AVDs serially via `adb`/`emulator` directly. GMD covers the+ whole supported range (API 30+) now that `minSdk` is 30, so this is a+ convenience path rather than a required one. Not run end-to-endin this session — check it works before depending on it.- **`scripts/maestro_run.sh`** + **`.maestro/flows/*.yaml`** — the Maestrosmoke layer. Requires Maestro installed separately (see