universal7885: parts: Disable display settings on non-supported models

* Also, update copyright header
This commit is contained in:
roynatech2544 2022-04-12 17:09:50 +09:00
commit bfcbd0d355
No known key found for this signature in database
GPG key ID: 50ABF73F0D19445D
16 changed files with 102 additions and 63 deletions

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2020 The Xiaomi-SM6250 Project * Copyright (C) 2022 Eureka Team
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -17,6 +17,7 @@ package com.eurekateam.samsungextras
import android.content.Intent import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.os.Build
import android.widget.Toast import android.widget.Toast
import androidx.preference.Preference import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat import androidx.preference.PreferenceFragmentCompat
@ -47,8 +48,10 @@ class DeviceSettings : PreferenceFragmentCompat(), Preference.OnPreferenceChange
mFpsInfo.onPreferenceChangeListener = this mFpsInfo.onPreferenceChangeListener = this
val mDT2W = findPreference<SwitchPreference>(PREF_DOUBLE_TAP)!! val mDT2W = findPreference<SwitchPreference>(PREF_DOUBLE_TAP)!!
mDT2W.onPreferenceChangeListener = this mDT2W.onPreferenceChangeListener = this
mDT2W.isEnabled = !(Build.PRODUCT == "a10" || Build.PRODUCT == "a20e")
val mGloveMode = findPreference<SwitchPreference>(PREF_GLOVE_MODE)!! val mGloveMode = findPreference<SwitchPreference>(PREF_GLOVE_MODE)!!
mGloveMode.onPreferenceChangeListener = this mGloveMode.onPreferenceChangeListener = this
mGloveMode.isEnabled = !(Build.PRODUCT == "a10" || Build.PRODUCT == "a20e")
val mFlashLight = findPreference<Preference>(PREF_FLASHLIGHT)!! val mFlashLight = findPreference<Preference>(PREF_FLASHLIGHT)!!
mFlashLight.onPreferenceClickListener = mFlashLight.onPreferenceClickListener =
Preference.OnPreferenceClickListener { Preference.OnPreferenceClickListener {
@ -79,10 +82,12 @@ class DeviceSettings : PreferenceFragmentCompat(), Preference.OnPreferenceChange
PREF_DOUBLE_TAP -> { PREF_DOUBLE_TAP -> {
DT2W = value as Boolean DT2W = value as Boolean
} }
PREF_GLOVE_MODE -> { PREF_GLOVE_MODE -> {
GloveMode = value as Boolean GloveMode = value as Boolean
} }
else -> {} else -> {
return false
}
} }
return true return true
} }
@ -92,7 +97,7 @@ class DeviceSettings : PreferenceFragmentCompat(), Preference.OnPreferenceChange
private const val PREF_CLEAR_SPEAKER = "clear_speaker_settings" private const val PREF_CLEAR_SPEAKER = "clear_speaker_settings"
private const val PREF_FLASHLIGHT = "flashlight_settings" private const val PREF_FLASHLIGHT = "flashlight_settings"
const val PREF_DOUBLE_TAP = "dt2w_settings" const val PREF_DOUBLE_TAP = "dt2w_settings"
const val PREF_GLOVE_MODE = "glove_mode_settings" const val PREF_GLOVE_MODE = "glove_mode_settings"
const val PREF_BATTERY = "battery_settings" const val PREF_BATTERY = "battery_settings"
} }
} }

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2020 The Xiaomi-SM6250 Project * Copyright (C) 2022 Eureka Team
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View file

@ -1,10 +1,24 @@
/*
* Copyright (C) 2022 Eureka Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.eurekateam.samsungextras package com.eurekateam.samsungextras
object GlobalConstants { object GlobalConstants {
/** /**
* Global Variables * Global Variables
*/ */
const val FLASHLIGHT_SYSFS = "/sys/class/camera/flash/" + const val FLASHLIGHT_SYSFS = "/sys/class/camera/flash/torch_brightness_lvl"
"torch_brightness_lvl"
const val TAG = "SamsungExtras" const val TAG = "SamsungExtras"
} }

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2020 Paranoid Android * Copyright (C) 2022 Eureka Team
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2020 Paranoid Android * Copyright (C) 2022 Eureka Team
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2020 Paranoid Android * Copyright (C) 2022 Eureka Team
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2020 Paranoid Android * Copyright (C) 2022 Eureka Team
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,13 +16,13 @@
package com.eurekateam.samsungextras.flashlight package com.eurekateam.samsungextras.flashlight
import android.os.Bundle import android.os.Bundle
import android.os.Build
import androidx.preference.Preference import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat import androidx.preference.PreferenceFragmentCompat
import com.eurekateam.samsungextras.GlobalConstants import com.eurekateam.samsungextras.GlobalConstants
import com.eurekateam.samsungextras.R import com.eurekateam.samsungextras.R
import com.eurekateam.samsungextras.interfaces.Flashlight import com.eurekateam.samsungextras.interfaces.Flashlight
import com.eurekateam.samsungextras.preferences.CustomSeekBarPreference import com.eurekateam.samsungextras.preferences.CustomSeekBarPreference
import com.eurekateam.samsungextras.utils.SystemProperties
import java.io.File import java.io.File
class FlashLightFragment : PreferenceFragmentCompat(), Preference.OnPreferenceChangeListener { class FlashLightFragment : PreferenceFragmentCompat(), Preference.OnPreferenceChangeListener {
@ -37,7 +37,7 @@ class FlashLightFragment : PreferenceFragmentCompat(), Preference.OnPreferenceCh
} }
mFlashLightPref!!.setMax(10) mFlashLightPref!!.setMax(10)
mFlashLightPref!!.setMin(1) mFlashLightPref!!.setMin(1)
val isa10 = SystemProperties.read("ro.product.device") == "a10" val isa10 = Build.DEVICE == "a10"
mFlashLightPref!!.value = Flashlight.getFlash(if (isa10) 1 else 0) mFlashLightPref!!.value = Flashlight.getFlash(if (isa10) 1 else 0)
} }

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2020 The Xiaomi-SM6250 Project * Copyright (C) 2022 Eureka Team
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2020 Xiaomi-SM6250 Project * Copyright (C) 2022 Eureka Team
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View file

@ -1,3 +1,18 @@
/*
* Copyright (C) 2022 Eureka Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.eurekateam.samsungextras.interfaces package com.eurekateam.samsungextras.interfaces
object Battery { object Battery {

View file

@ -1,3 +1,19 @@
/*
* Copyright (C) 2022 Eureka Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.eurekateam.samsungextras.interfaces package com.eurekateam.samsungextras.interfaces
object Display { object Display {
@ -5,5 +21,5 @@ object Display {
external set external set
var GloveMode: Boolean = false var GloveMode: Boolean = false
external set external set
} }

View file

@ -1,3 +1,19 @@
/*
* Copyright (C) 2022 Eureka Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.eurekateam.samsungextras.interfaces package com.eurekateam.samsungextras.interfaces
object Flashlight { object Flashlight {

View file

@ -1,3 +1,19 @@
/*
* Copyright (C) 2022 Eureka Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.eurekateam.samsungextras.preferences package com.eurekateam.samsungextras.preferences
import android.content.Context import android.content.Context

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2020 Paranoid Android * Copyright (C) 2022 Eureka Team
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2020 Paranoid Android * Copyright (C) 2022 Eureka Team
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View file

@ -1,43 +0,0 @@
package com.eurekateam.samsungextras.utils
import android.util.Log
import com.eurekateam.samsungextras.GlobalConstants
import java.io.BufferedReader
import java.io.IOException
import java.io.InputStreamReader
object SystemProperties {
/**
* To read a prop using getprop
* @param propName the prop name to get
* @return the prop's value, empty string is not found
*/
fun read(propName: String): String {
var process: Process? = null
var bufferedReader: BufferedReader? = null
val TAG = GlobalConstants.TAG
return try {
val GETPROP_EXECUTABLE_PATH = "/system/bin/getprop"
process = ProcessBuilder().command(GETPROP_EXECUTABLE_PATH, propName)
.redirectErrorStream(true).start()
bufferedReader = BufferedReader(InputStreamReader(process.inputStream))
var line = bufferedReader.readLine()
if (line == null) {
line = "" //prop not set
}
Log.i(TAG, "read System Property: $propName=$line")
line
} catch (e: Exception) {
Log.e(TAG, "Failed to read System Property $propName", e)
""
} finally {
if (bufferedReader != null) {
try {
bufferedReader.close()
} catch (ignored: IOException) {
}
}
process?.destroy()
}
}
}