File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed
app/src/main/kotlin/cn/lyric/getter Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change 1
1
package cn.lyric.getter.tool
2
2
3
+ import android.annotation.SuppressLint
3
4
import android.content.Context
4
5
import android.content.pm.PackageInfo
5
6
import android.os.Build
@@ -10,6 +11,18 @@ import java.io.DataOutputStream
10
11
object Tools {
11
12
var xpActivation: Boolean = false
12
13
14
+ val getPhoneName by lazy {
15
+ val marketName = getSystemProperties(" ro.product.marketname" )
16
+ if (marketName.isNotEmpty()) bigtextone(marketName) else bigtextone(Build .BRAND ) + " " + Build .MODEL
17
+ }
18
+
19
+ fun bigtextone (st : String ): String {
20
+ val formattedBrand = st.replaceFirstChar {
21
+ if (it.isLowerCase()) it.titlecase() else it.toString()
22
+ }
23
+ return formattedBrand
24
+ }
25
+
13
26
fun restartTheScopedSoftware (context : Context ) {
14
27
var s = " "
15
28
context.resources.getStringArray(R .array.need_module).forEach {
@@ -44,4 +57,16 @@ object Tools {
44
57
@Suppress(" DEPRECATION" )
45
58
versionCode
46
59
}
60
+
61
+ @SuppressLint(" PrivateApi" )
62
+ fun getSystemProperties (key : String ): String {
63
+ val ret: String = try {
64
+ Class .forName(" android.os.SystemProperties" ).getDeclaredMethod(" get" , String ::class .java).invoke(null , key) as String
65
+ } catch (iAE: IllegalArgumentException ) {
66
+ throw iAE
67
+ } catch (e: Exception ) {
68
+ " "
69
+ }
70
+ return ret
71
+ }
47
72
}
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ import cn.lyric.getter.databinding.FragmentHomeBinding
19
19
import cn.lyric.getter.tool.ActivityTools.getAppRules
20
20
import cn.lyric.getter.tool.BackupTools
21
21
import cn.lyric.getter.tool.ConfigTools.config
22
+ import cn.lyric.getter.tool.Tools.getPhoneName
22
23
import cn.lyric.getter.tool.Tools.restartTheScopedSoftware
23
24
import cn.lyric.getter.ui.adapter.NoticeAdapter
24
25
import cn.lyric.getter.ui.viewmodel.HomeViewModel
@@ -149,7 +150,7 @@ class HomeFragment : Fragment() {
149
150
}
150
151
}
151
152
}
152
- deviceValue.text = " ${ Build . BRAND } ${Build .MODEL } Android${Build .VERSION .RELEASE } "
153
+ deviceValue.text = " $getPhoneName ( ${Build .DEVICE } ) Android ${Build .VERSION .RELEASE } "
153
154
versionLabelValue.text = BuildConfig .VERSION_NAME
154
155
versionCodeValue.text = BuildConfig .VERSION_CODE .toString()
155
156
versionTypeValue.text = BuildConfig .BUILD_TYPE .toUpperFirstCaseAndLowerOthers()
You can’t perform that action at this time.
0 commit comments