Skip to content

Commit

Permalink
Remove DevicesManager
Browse files Browse the repository at this point in the history
  • Loading branch information
mklkj committed May 17, 2020
1 parent 0060b7a commit 965fcb9
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 42 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.thelittlefireman.appkillermanager.managers

import android.content.Context
import android.content.Intent
import com.thelittlefireman.appkillermanager.devices.Device
import com.thelittlefireman.appkillermanager.devices.*
import com.thelittlefireman.appkillermanager.utils.ActionsUtils
import com.thelittlefireman.appkillermanager.utils.SystemUtils
import timber.log.Timber
Expand All @@ -15,16 +15,38 @@ object KillerManager {
ACTION_NOTIFICATIONS
}

private val devices = listOf(
Asus(),
Huawei(),
Letv(),
Meizu(),
OnePlus(),
HTC(),
Samsung(),
Xiaomi(),
ZTE()
)

@JvmStatic
val device: Device?
get() = DevicesManager.getDevice()
fun isDeviceSupported() = getDevice() != null

@JvmStatic
val isDeviceSupported: Boolean
get() = DevicesManager.getDevice() != null
fun getDevice(): Device? {
val currentDevice = devices.filter { it.isThatRom }

if (currentDevice.size > 1) {
val logDevices = currentDevice.joinToString(", ") {
it.manufacturer.toString()
}

Timber.w("More than one corresponding device: %s. Debug info: %s", logDevices, SystemUtils.getDefaultDebugInformation())
}

return currentDevice.firstOrNull()
}

@JvmStatic
fun isActionAvailable(context: Context, action: Action?) = DevicesManager.getDevice()?.let {
fun isActionAvailable(context: Context, action: Action?) = getDevice()?.let {
when (action) {
Action.ACTION_AUTO_START -> it.isActionAutoStartAvailable(context)
Action.ACTION_POWER_SAVING -> it.isActionPowerSavingAvailable(context)
Expand Down Expand Up @@ -84,7 +106,7 @@ object KillerManager {
* @return the intent
*/
private fun getIntentFromAction(context: Context, action: Action): Intent? {
val sDevice = DevicesManager.getDevice()
val sDevice = getDevice()
return if (sDevice != null) {
val intent = when (action) {
Action.ACTION_AUTO_START -> sDevice.getActionAutoStart(context)
Expand Down

0 comments on commit 965fcb9

Please sign in to comment.