Skip to content

Commit

Permalink
More linter warnings fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
d4rken committed Sep 14, 2024
1 parent d16c6fc commit 76cba65
Show file tree
Hide file tree
Showing 17 changed files with 27 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ fun PackageManager.getInstalledPackagesAsUser(
) = try {
val functions = PackageManager::class.memberFunctions.filter { it.name == "getInstalledPackagesAsUser" }
if (hasApiLevel(33)) {
@Suppress("NewApi")
@Suppress("NewApi", "UNCHECKED_CAST")
functions
.first {
val arg1 = it.parameters[1].type.jvmErasure
Expand All @@ -63,6 +63,7 @@ fun PackageManager.getInstalledPackagesAsUser(
}
.call(this, PackageInfoFlags.of(flags), userHandle.handleId) as List<PackageInfo>
} else {
@Suppress("UNCHECKED_CAST")
functions
.first {
val arg1 = it.parameters[1].type.jvmErasure
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ data class LibraryPkg(
return rawId.toPkgId()
}

@get:SuppressLint("NewApi")
@get:SuppressLint("NewApi", "DEPRECATION")
override val versionCode: Long
get() = if (hasApiLevel(28)) {
sharedLibraryInfo.longVersion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ private fun PackageInfo.getInstallerInfoApi30(packageManager: PackageManager): I

private fun PackageInfo.getInstallerInfoLegacy(packageManager: PackageManager): InstallerInfo {
val installingPkg = try {
@Suppress("DEPRECATION")
packageManager.getInstallerPackageName(packageName)
?.let { Pkg.Id(it) }
?.let { it.toKnownPkg() ?: it.toStub() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class RootServiceClient @Inject constructor(
log(TAG) { "Instantiating Root launcher..." }
if (rootSettings.useRoot.value() != true) throw RootUnavailableException("Root is not enabled")

val options = RootHostOptions(
val initialOptions = RootHostOptions(
isDebug = debugSettings.isDebugMode.value(),
isTrace = debugSettings.isTraceMode.value(),
isDryRun = debugSettings.isDryRunMode.value(),
Expand All @@ -55,7 +55,7 @@ class RootServiceClient @Inject constructor(

var lastInternal: RootConnection? = null
rootHostLauncher
.createHostConnection(options = options)
.createHostConnection(options = initialOptions)
.onEach { wrapper ->
lastInternal = wrapper.host
send(wrapper.service)
Expand All @@ -69,14 +69,14 @@ class RootServiceClient @Inject constructor(
debugSettings.recorderPath.flow
) { isDebug, isTrace, isDryRun, recorderPath ->
lastInternal?.let {
val options = RootHostOptions(
val dynamicOptions = RootHostOptions(
isDebug = isDebug,
isTrace = isTrace,
isDryRun = isDryRun,
recorderPath = recorderPath,
)
log(TAG) { "Updating debug settings: $options" }
it.updateHostOptions(options)
log(TAG) { "Updating debug settings: $dynamicOptions" }
it.updateHostOptions(dynamicOptions)
}
}.launchIn(this)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ import java.lang.reflect.Method
*/
@Parcelize
@TypeParceler<Any, AnyParceler>
class StorageVolumeX constructor(
class StorageVolumeX(
private val volumeObj: Any
) : Parcelable {
private val volumeClass: Class<*> = volumeObj.javaClass
private val volumeClass: Class<*>
get() = volumeObj.javaClass


private val volume: StorageVolume
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,12 @@ import java.nio.ByteBuffer
import java.util.BitSet

fun Byte.toHex(): String = String.format("%02X", this)
fun UByte.toHex(): String = this.toByte().toHex()

val Byte.upperNibble get() = (this.toInt() shr 4 and 0b1111).toShort()
val Byte.lowerNibble get() = (this.toInt() and 0b1111).toShort()
val UByte.upperNibble get() = (this.toInt() shr 4 and 0b1111).toUShort()
val UByte.lowerNibble get() = (this.toInt() and 0b1111).toUShort()

fun Byte.isBitSet(pos: Int): Boolean = BitSet.valueOf(arrayOf(this).toByteArray()).get(pos)
fun UByte.isBitSet(pos: Int): Boolean = this.toByte().isBitSet(pos)

fun Short.isBitSet(pos: Int): Boolean = this.toByte().isBitSet(pos)
fun UShort.isBitSet(pos: Int): Boolean = this.toShort().isBitSet(pos)

fun UShort.toBinaryString(): String = Integer.toBinaryString(this.toInt()).padStart(4, '0')
fun UByte.toBinaryString(): String = Integer.toBinaryString(this.toInt()).padStart(8, '0')

fun ByteArray.toHex(): String = this.joinToString(separator = "") { String.format("%02X", it) }
fun UByteArray.toHex(): String = this.joinToString(separator = "") { String.format("%02X", it.toByte()) }

fun Int.toByteArray(): ByteArray = ByteBuffer.allocate(Int.SIZE_BYTES).putInt(this).array()

fun Short.toByteArray(): ByteArray = ByteBuffer.allocate(Short.SIZE_BYTES).putShort(this).array()

fun Int.toUByteArray(): UByteArray = toByteArray().toUByteArray()

infix fun UShort.shl(bitCount: Int): UShort = (this.toUInt() shl bitCount).toUShort()
infix fun UShort.shr(bitCount: Int): UShort = (this.toUInt() shr bitCount).toUShort()

infix fun UByte.shl(bitCount: Int): UByte = (this.toUInt() shl bitCount).toUByte()
infix fun UByte.shr(bitCount: Int): UByte = (this.toUInt() shr bitCount).toUByte()

fun UByte.toBigEndianUShort(): UShort = this.toUShort() shl 8
fun UByte.toBigEndianUInt(): UInt = this.toUInt() shl 24

fun String.toByteString() = toByteArray().toByteString()
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class FragmentFactoryHolderViewModel : ViewModel() {
return ViewModelProvider(activity, FACTORY)[FragmentFactoryHolderViewModel::class.java]
}

@Suppress("UNCHECKED_CAST")
private val FACTORY: ViewModelProvider.Factory = object : ViewModelProvider.Factory {
override fun <T : ViewModel> create(modelClass: Class<T>): T {
return FragmentFactoryHolderViewModel() as T
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class PostProcessorModule @Inject constructor(

val after = before.copy(
expendables = before.expendables
.mapValues { (key, value) ->
.mapValues { (_, value) ->
value.distinctBy { it.path }
}
.filter { it.value.isNotEmpty() }
Expand Down Expand Up @@ -121,7 +121,7 @@ class PostProcessorModule @Inject constructor(
val exclusions = exclusionManager.pathExclusions(SDMTool.Type.APPCLEANER)

var after = before.copy(
expendables = before.expendables.mapValues { (type, paths) ->
expendables = before.expendables.mapValues { (_, paths) ->
exclusions.excludeNestedLookups(paths)
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ class AppControlListFragment : Fragment3(R.layout.appcontrol_list_fragment) {
}
FastScrollItemIndicator.Text(lbl ?: "?")
}
val showIndicator: (FastScrollItemIndicator, Int, Int) -> Boolean = { indicator, index, size ->
val showIndicator: (FastScrollItemIndicator, Int, Int) -> Boolean = { _, _, size ->
size in 2..32
}
fastscroller.setupWithRecyclerView(ui.list, itemLabler, showIndicator, true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class ExcludeActionVH(parent: ViewGroup) :
item: Item,
payloads: List<Any>
) -> Unit = binding { item ->
val appInfo = item.appInfo
if (item.exclusion == null) {
icon.setImageResource(R.drawable.ic_shield_24)
primary.text = getString(R.string.appcontrol_app_exclude_add_title)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package eu.darken.sdmse.appcontrol.ui.settings
import androidx.lifecycle.SavedStateHandle
import dagger.hilt.android.lifecycle.HiltViewModel
import eu.darken.sdmse.appcontrol.core.AppControl
import eu.darken.sdmse.appcontrol.core.AppControlSettings
import eu.darken.sdmse.common.coroutine.DispatcherProvider
import eu.darken.sdmse.common.debug.logging.logTag
import eu.darken.sdmse.common.uix.ViewModel3
Expand All @@ -18,7 +17,6 @@ class AppControlSettingsViewModel @Inject constructor(
private val handle: SavedStateHandle,
dispatcherProvider: DispatcherProvider,
appControl: AppControl,
settings: AppControlSettings,
upgradeRepo: UpgradeRepo,
) : ViewModel3(dispatcherProvider) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ open class NestedPackageMatcher(
})
}

override suspend fun getMarkerForLocation(location: DataArea.Type): Collection<Marker> {
return if (location === this.areaType) dynamicMarkers else emptyList()
override suspend fun getMarkerForLocation(areaType: DataArea.Type): Collection<Marker> {
return if (areaType === this.areaType) dynamicMarkers else emptyList()
}

override suspend fun match(areaType: DataArea.Type, prefixFreeBasePath: List<String>): Collection<Marker.Match> {
Expand All @@ -67,7 +67,7 @@ open class NestedPackageMatcher(
return markers
}

private class PackageMarker constructor(
private class PackageMarker(
override val areaType: DataArea.Type,
override val segments: Segments,
val pkgId: Pkg.Id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ abstract class BottomSheetDialogFragment2 : BottomSheetDialogFragment() {
super.onViewCreated(view, savedInstanceState)
}

@Deprecated("Deprecated in Java")
override fun onActivityCreated(savedInstanceState: Bundle?) {
log(tag, VERBOSE) { "onActivityCreated(savedInstanceState=$savedInstanceState)" }
super.onActivityCreated(savedInstanceState)
Expand Down Expand Up @@ -87,6 +88,7 @@ abstract class BottomSheetDialogFragment2 : BottomSheetDialogFragment() {
super.onDestroy()
}

@Deprecated("Deprecated in Java")
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
log(tag, VERBOSE) { "onActivityResult(requestCode=$requestCode, resultCode=$resultCode, data=$data)" }
super.onActivityResult(requestCode, resultCode, data)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ abstract class DialogFragment2(@LayoutRes val layoutRes: Int?) : DialogFragment(
super.onViewCreated(view, savedInstanceState)
}

@Deprecated("Deprecated in Java")
override fun onActivityCreated(savedInstanceState: Bundle?) {
log(tag, VERBOSE) { "onActivityCreated(savedInstanceState=$savedInstanceState)" }
super.onActivityCreated(savedInstanceState)
Expand Down Expand Up @@ -74,6 +75,7 @@ abstract class DialogFragment2(@LayoutRes val layoutRes: Int?) : DialogFragment(
super.onDestroy()
}

@Deprecated("Deprecated in Java")
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
log(tag, VERBOSE) { "onActivityResult(requestCode=$requestCode, resultCode=$resultCode, data=$data)" }
super.onActivityResult(requestCode, resultCode, data)
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/eu/darken/sdmse/common/uix/Fragment2.kt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ abstract class Fragment2(@LayoutRes val layoutRes: Int?) : Fragment(layoutRes ?:
super.onViewCreated(view, savedInstanceState)
}

@Deprecated("Deprecated in Java")
override fun onActivityCreated(savedInstanceState: Bundle?) {
log(tag, VERBOSE) { "onActivityCreated(savedInstanceState=$savedInstanceState)" }
super.onActivityCreated(savedInstanceState)
Expand Down Expand Up @@ -74,6 +75,7 @@ abstract class Fragment2(@LayoutRes val layoutRes: Int?) : Fragment(layoutRes ?:
super.onDestroy()
}

@Deprecated("Deprecated in Java")
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
log(tag, VERBOSE) { "onActivityResult(requestCode=$requestCode, resultCode=$resultCode, data=$data)" }
super.onActivityResult(requestCode, resultCode, data)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import eu.darken.sdmse.databinding.SchedulerManagerListScheduleItemBinding
import eu.darken.sdmse.scheduler.core.Schedule
import eu.darken.sdmse.scheduler.ui.manager.SchedulerAdapter
import java.time.Instant
import java.time.LocalTime
import java.time.format.DateTimeFormatter
import java.time.format.FormatStyle

Expand All @@ -36,8 +35,6 @@ class ScheduleRowVH(parent: ViewGroup) :
val days = schedule.repeatInterval.toDays()
val daysText = getQuantityString(R.plurals.scheduler_schedule_repeat_x_days, days.toInt())

val localTime = LocalTime.of(schedule.hour, schedule.minute)

val hourTxt = schedule.hour.toString().padStart(2, '0')
val minuteTxt = schedule.minute.toString().padStart(2, '0')
val time = "$hourTxt:$minuteTxt"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ class SafGrantPrimaryContract : ActivityResultContract<SAFSetupModule.Result.Pat

override fun createIntent(
context: Context,
data: SAFSetupModule.Result.PathAccess
): Intent = data.grantIntent
input: SAFSetupModule.Result.PathAccess
): Intent = input.grantIntent

override fun parseResult(resultCode: Int, intent: Intent?): Uri? = when (resultCode) {
Activity.RESULT_OK -> intent?.data
Expand Down

0 comments on commit 76cba65

Please sign in to comment.