Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

# Package Files #
*.jar
!gradle/wrapper/gradle-wrapper.jar
*.war
*.nar
*.ear
Expand Down
36 changes: 28 additions & 8 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
<uses-permission android:name="android.permission.SET_WALLPAPER" />

<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MICROPHONE" />

<application
android:name=".EssentialsApp"
android:allowBackup="true"
Expand Down Expand Up @@ -354,14 +357,6 @@
</intent-filter>
</activity>

<activity
android:name=".ShutUpShortcutActivity"
android:excludeFromRecents="true"
android:exported="true"
android:noHistory="true"
android:taskAffinity=""
android:theme="@style/Theme.Essentials.Translucent" />

<activity
android:name=".ui.activities.FlashlightIntensityActivity"
android:excludeFromRecents="true"
Expand Down Expand Up @@ -605,6 +600,10 @@
android:name="android.app.property.FOREGROUND_SERVICE_TYPE_SPECIAL_USE_DESCRIPTION"
android:value="Battery Notification Service" />
</service>
<service
android:name=".services.AudioRecordService"
android:exported="false"
android:foregroundServiceType="microphone" />
<service
android:name=".services.tiles.SoundModeTileService"
android:exported="true"
Expand Down Expand Up @@ -1275,6 +1274,27 @@
android:name="android.app.appfunctions.app_metadata"
android:resource="@xml/app_metadata" />

<activity
android:name=".ShutUpShortcutActivity"
android:exported="true"
android:excludeFromRecents="true"
android:noHistory="true"
android:theme="@style/Theme.Essentials.Translucent">
<intent-filter>
<action android:name="android.intent.action.CREATE_SHORTCUT" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>

<service
android:name=".services.ShutUpForegroundService"
android:enabled="true"
android:exported="false"
android:foregroundServiceType="specialUse">
<property android:name="android.app.property.FOREGROUND_SERVICE_TYPE_SPECIAL_USE_DESCRIPTION"
android:value="Shut-Up! background monitoring service" />
</service>

</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@ import com.sameerasw.essentials.domain.model.NotificationLightingSide
import com.sameerasw.essentials.domain.model.NotificationLightingStyle
import com.sameerasw.essentials.domain.model.NotificationLightingSweepPosition
import com.sameerasw.essentials.domain.model.ScaleAnimationsProfile

import com.sameerasw.essentials.domain.model.TrackedRepo
import com.sameerasw.essentials.domain.model.github.GitHubUser
import com.sameerasw.essentials.domain.model.ShutUpAppConfig

import com.sameerasw.essentials.utils.RootUtils
import com.sameerasw.essentials.utils.ShizukuUtils
import kotlinx.coroutines.channels.awaitClose
Expand All @@ -34,7 +37,7 @@ class SettingsRepository(private val context: Context) {

private val prefs: SharedPreferences =
context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE)
private val gson = Gson()
private val gson = com.google.gson.GsonBuilder().create()

init {
migrateUsageAccessKey()
Expand Down Expand Up @@ -275,14 +278,15 @@ class SettingsRepository(private val context: Context) {
const val LIVE_WALLPAPER_TRIGGER_UNLOCK = "unlock"
const val LIVE_WALLPAPER_TRIGGER_SCREEN_ON = "screen_on"

const val KEY_DISABLE_ROTATION_SUGGESTION = "disable_rotation_suggestion"

const val KEY_SHUT_UP_SELECTED_APPS = "shut_up_selected_apps"
const val KEY_SHUT_UP_ORIGINAL_SETTINGS = "shut_up_original_settings"
const val KEY_SHUT_UP_ATTEMPT_SHIZUKU_RESTART = "shut_up_attempt_shizuku_restart"
const val KEY_SHUT_UP_RESTORE_DELAY = "shut_up_restore_delay"
const val KEY_SHUT_UP_RESTORE_MODE = "shut_up_restore_mode"
const val KEY_SHIZUKU_AUTH_TOKEN = "shizuku_auth_token"
const val KEY_EDGE_LIGHTING_SWEEP_SELECTED_SHAPES = "edge_lighting_sweep_selected_shapes"
const val KEY_DISABLE_ROTATION_SUGGESTION = "disable_rotation_suggestion"
const val KEY_ALLOW_OVERLAYS_IN_SETTINGS = "allow_overlays_in_settings"
const val KEY_NETWORK_DOWNLOAD_RATE_LIMIT = "network_download_rate_limit"
const val KEY_MOBILE_DATA_ALWAYS_ON = "mobile_data_always_on"
Expand All @@ -306,6 +310,7 @@ class SettingsRepository(private val context: Context) {
const val KEY_PIXEL_SEARCHBAR_MUSIC_ARTIST = "pixel_searchbar_music_artist"
const val KEY_PIXEL_SEARCHBAR_MUSIC_PACKAGE = "pixel_searchbar_music_package"


const val KEY_LOCK_SCREEN_CLOCK_WEIGHT = "lock_screen_clock_weight"
const val KEY_LOCK_SCREEN_CLOCK_WIDTH = "lock_screen_clock_width"
const val KEY_LOCK_SCREEN_CLOCK_GRADE = "lock_screen_clock_grade"
Expand All @@ -321,8 +326,8 @@ class SettingsRepository(private val context: Context) {
const val KEY_POCKET_MODE_LOCK_SCREEN_ONLY = "pocket_mode_lock_screen_only"
const val KEY_KEEP_PREFS = "keep_prefs"
const val KEY_TRANSLATION_MODE_DO_NOT_SHOW_WARNING = "translation_mode_do_not_show_warning"

const val KEY_LOCKDOWN_MODE = "lockdown_mode"
const val KEY_SHUT_UP_SERVICE_ENABLED = "shutup_service_enabled"
}

/**
Expand Down Expand Up @@ -927,76 +932,8 @@ class SettingsRepository(private val context: Context) {
fun updatePocketModeExcludedAppSelection(packageName: String, enabled: Boolean) =
updateAppSelection(KEY_POCKET_MODE_EXCLUDED_APPS, packageName, enabled)

/**
* Executes the load shut up configs operation.
* @return The resulting List<com data.
*/
fun loadShutUpConfigs(): List<com.sameerasw.essentials.domain.model.ShutUpAppConfig> {
val json = prefs.getString(KEY_SHUT_UP_SELECTED_APPS, null)
return if (json != null) {
try {
gson.fromJson(
json,
Array<com.sameerasw.essentials.domain.model.ShutUpAppConfig>::class.java
).toList()
} catch (e: Exception) {
emptyList()
}
} else {
emptyList()
}
}

/**
* Executes the save shut up configs operation.
*
* @param configs [List<com.sameerasw.essentials.domain.model.ShutUpAppConfig>] Target configs.
*/
fun saveShutUpConfigs(configs: List<com.sameerasw.essentials.domain.model.ShutUpAppConfig>) {
val json = gson.toJson(configs)
putString(KEY_SHUT_UP_SELECTED_APPS, json)
}

/**
* Executes the update shut up config operation.
*
* @param config [com.sameerasw.essentials.domain.model.ShutUpAppConfig] Target config.
*/
fun updateShutUpConfig(config: com.sameerasw.essentials.domain.model.ShutUpAppConfig) {
val current = loadShutUpConfigs().toMutableList()
val index = current.indexOfFirst { it.packageName == config.packageName }
if (index != -1) {
current[index] = config
} else {
current.add(config)
}
saveShutUpConfigs(current)
}

/**
* Executes the save shut up original settings operation.
*
* @param settings [Map<String] Target settings.
* @param String> Target string.
*/
fun saveShutUpOriginalSettings(settings: Map<String, String>) {
val json = gson.toJson(settings)
putString(KEY_SHUT_UP_ORIGINAL_SETTINGS, json)
}

/**
* Executes the get shut up original settings operation.
* @return The resulting Map<String, String> data.
*/
fun getShutUpOriginalSettings(): Map<String, String> {
val json = prefs.getString(KEY_SHUT_UP_ORIGINAL_SETTINGS, null) ?: return emptyMap()
return try {
@Suppress("UNCHECKED_CAST")
gson.fromJson(json, Map::class.java) as Map<String, String>
} catch (e: Exception) {
emptyMap()
}
}

private fun updateAppSelection(key: String, packageName: String, enabled: Boolean) {
val current = loadAppSelection(key).toMutableList()
Expand Down Expand Up @@ -2820,5 +2757,60 @@ class SettingsRepository(private val context: Context) {
* @param value [Int] Target value.
*/
fun setLockScreenClockSeedColor(value: Int) = putInt(KEY_LOCK_SCREEN_CLOCK_SEED_COLOR, value)

fun loadShutUpConfigs(): List<ShutUpAppConfig> {
val json = prefs.getString(KEY_SHUT_UP_SELECTED_APPS, null)
return if (json != null) {
try {
gson.fromJson(
json,
Array<ShutUpAppConfig>::class.java
).toList()
} catch (e: Exception) {
emptyList()
}
} else {
emptyList()
}
}

fun saveShutUpConfigs(configs: List<ShutUpAppConfig>) {
val json = gson.toJson(configs)
putString(KEY_SHUT_UP_SELECTED_APPS, json)
}

fun updateShutUpConfig(config: ShutUpAppConfig) {
val current = loadShutUpConfigs().toMutableList()
val index = current.indexOfFirst { it.packageName == config.packageName }
if (index != -1) {
current[index] = config
} else {
current.add(config)
}
saveShutUpConfigs(current)
}

fun isShutUpServiceEnabled(): Boolean {
return prefs.getBoolean(KEY_SHUT_UP_SERVICE_ENABLED, false)
}

fun setShutUpServiceEnabled(enabled: Boolean) {
putBoolean(KEY_SHUT_UP_SERVICE_ENABLED, enabled)
}

fun saveShutUpOriginalSettings(settings: Map<String, String>) {
val json = gson.toJson(settings)
putString(KEY_SHUT_UP_ORIGINAL_SETTINGS, json)
}

fun getShutUpOriginalSettings(): Map<String, String> {
val json = prefs.getString(KEY_SHUT_UP_ORIGINAL_SETTINGS, null) ?: return emptyMap()
return try {
@Suppress("UNCHECKED_CAST")
gson.fromJson(json, Map::class.java) as Map<String, String>
} catch (e: Exception) {
emptyMap()
}
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.sameerasw.essentials.domain.model

data class AppSetting(
val enabled: Boolean = true,
val settingType: String, // "GLOBAL", "SECURE", "SYSTEM"
val key: String,
val valueOnLaunch: String,
val valueOnRevert: String,
val label: String
)
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ abstract class Feature(
@StringRes val aboutDescription: Int? = null,
@androidx.annotation.RawRes val animationRes: Int = 0
) {
val requiresAuth: Boolean = category == com.sameerasw.essentials.R.string.cat_protection
open val requiresAuth: Boolean
get() = category == com.sameerasw.essentials.R.string.cat_protection

abstract fun isEnabled(viewModel: MainViewModel): Boolean

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,65 @@ package com.sameerasw.essentials.domain.model
data class ShutUpAppConfig(
val packageName: String,
val isEnabled: Boolean = true,
val disableDevOptions: Boolean = true,
val disableUsbDebugging: Boolean = true,
val disableWirelessDebugging: Boolean = true,
val disableAccessibility: Boolean = false,
val settings: List<AppSetting> = emptyList(),
val attemptShizukuRestart: Boolean = false,
val autoArchive: Boolean = false
)

val ShutUpAppConfig.disableDevOptions: Boolean
get() = settings.any { it.key == "development_settings_enabled" && it.enabled }

val ShutUpAppConfig.disableUsbDebugging: Boolean
get() = settings.any { it.key == "adb_enabled" && it.enabled }

val ShutUpAppConfig.disableWirelessDebugging: Boolean
get() = settings.any { it.key == "adb_wifi_enabled" && it.enabled }

val ShutUpAppConfig.disableAccessibility: Boolean
get() = settings.any { it.key == "accessibility_enabled" && it.enabled }

fun ShutUpAppConfig.copy(
packageName: String = this.packageName,
isEnabled: Boolean = this.isEnabled,
attemptShizukuRestart: Boolean = this.attemptShizukuRestart,
autoArchive: Boolean = this.autoArchive,
disableDevOptions: Boolean = this.disableDevOptions,
disableUsbDebugging: Boolean = this.disableUsbDebugging,
disableWirelessDebugging: Boolean = this.disableWirelessDebugging,
disableAccessibility: Boolean = this.disableAccessibility
): ShutUpAppConfig {
val newList = settings.toMutableList()

fun updateKey(key: String, label: String, enabled: Boolean) {
val existing = newList.find { it.key == key }
if (existing != null) {
newList[newList.indexOf(existing)] = existing.copy(enabled = enabled)
} else if (enabled) {
val type = if (key == "accessibility_enabled") "SECURE" else "GLOBAL"
newList.add(
AppSetting(
label = label,
settingType = type,
key = key,
valueOnLaunch = "0",
valueOnRevert = "1",
enabled = true
)
)
}
}

updateKey("development_settings_enabled", "Hide Developer Options", disableDevOptions)
updateKey("adb_enabled", "Hide USB Debugging", disableUsbDebugging)
updateKey("adb_wifi_enabled", "Hide Wireless Debugging", disableWirelessDebugging)
updateKey("accessibility_enabled", "Hide Accessibility Services", disableAccessibility)

return ShutUpAppConfig(
packageName = packageName,
isEnabled = isEnabled,
settings = newList,
attemptShizukuRestart = attemptShizukuRestart,
autoArchive = autoArchive
)
}

Loading
Loading