Skip to content

Commit ac1c3dc

Browse files
committed
[feat]
1. deviceutils 내 유심 정보 simutils로 뷴리
1 parent 9414719 commit ac1c3dc

File tree

5 files changed

+172
-136
lines changed

5 files changed

+172
-136
lines changed

app/src/main/java/ch/lock/mobile/android/deviceinfo/di/UtilsModule.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
package ch.lock.mobile.android.deviceinfo.di
22

3-
import ch.lock.mobile.android.deviceinfo.utils.DeviceUtils
4-
import ch.lock.mobile.android.deviceinfo.utils.PermissionUtils
5-
import ch.lock.mobile.android.deviceinfo.utils.ResourceProvider
6-
import ch.lock.mobile.android.deviceinfo.utils.ResourceProviderImpl
3+
import ch.lock.mobile.android.deviceinfo.utils.*
74
import org.koin.core.module.Module
85
import org.koin.dsl.bind
96
import org.koin.dsl.module
@@ -24,6 +21,11 @@ object UtilsModule {
2421
get()
2522
)
2623
} bind ResourceProvider::class
24+
single {
25+
SimUtils(
26+
get()
27+
)
28+
}
2729
}
2830

2931
}

app/src/main/java/ch/lock/mobile/android/deviceinfo/ui/main/usiminfo/UsimInfoViewModel.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ package ch.lock.mobile.android.deviceinfo.ui.main.usiminfo
33
import androidx.lifecycle.LiveData
44
import androidx.lifecycle.MutableLiveData
55
import androidx.lifecycle.ViewModel
6-
import ch.lock.mobile.android.deviceinfo.utils.DeviceUtils
6+
import ch.lock.mobile.android.deviceinfo.utils.SimUtils
77

88
class UsimInfoViewModel(
9-
deviceUtils: DeviceUtils
9+
simUtils: SimUtils
1010
) : ViewModel() {
1111

1212
companion object {
@@ -16,19 +16,19 @@ class UsimInfoViewModel(
1616
/**
1717
* 전화번호
1818
*/
19-
private val _phoneNumber: MutableLiveData<String> = MutableLiveData(deviceUtils.phoneNumber)
19+
private val _phoneNumber: MutableLiveData<String> = MutableLiveData(simUtils.phoneNumber)
2020
val phoneNumber: LiveData<String> = _phoneNumber
2121

2222
/**
2323
* 통신사
2424
*/
25-
private val _telecom: MutableLiveData<String> = MutableLiveData(deviceUtils.telecom)
25+
private val _telecom: MutableLiveData<String> = MutableLiveData(simUtils.telecom)
2626
val telecom: LiveData<String> = _telecom
2727

2828
/**
2929
* SIM Serial 번호
3030
*/
31-
private val _simNumber: MutableLiveData<String> = MutableLiveData(deviceUtils.simNumber)
31+
private val _simNumber: MutableLiveData<String> = MutableLiveData(simUtils.simNumber)
3232
val simNumber: LiveData<String> = _simNumber
3333

3434
}

app/src/main/java/ch/lock/mobile/android/deviceinfo/utils/DeviceUtils.kt

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import java.io.BufferedReader
1212
import java.io.InputStream
1313
import java.io.InputStreamReader
1414

15-
1615
@SuppressLint("MissingPermission", "HardwareIds")
1716
open class DeviceUtils(
1817
private val applicationContext: Context
@@ -64,21 +63,6 @@ open class DeviceUtils(
6463
""
6564
}
6665

67-
/**
68-
* @return 디바이스 SIM Serial Number
69-
*/
70-
open val simNumber: String
71-
get() = try {
72-
when {
73-
Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1 ->
74-
subscriptionManager.activeSubscriptionInfoList?.firstOrNull()?.iccId ?: ""
75-
76-
else -> telephonyManager.simSerialNumber ?: ""
77-
}
78-
} catch (e: Exception) {
79-
""
80-
}
81-
8266
/**
8367
* 안드로이드 ~7: 영구 유지
8468
* 안드로이드 8~: 공장 초기화하면 재설정
@@ -89,26 +73,6 @@ open class DeviceUtils(
8973
applicationContext.contentResolver, Settings.Secure.ANDROID_ID
9074
)
9175

92-
/**
93-
* @return 통신사 정보
94-
*/
95-
open val telecom: String
96-
get() = try {
97-
telephonyManager.networkOperatorName ?: ""
98-
} catch (e: Exception) {
99-
""
100-
}
101-
102-
/**
103-
* @return 디바이스 전화번호
104-
*/
105-
open val phoneNumber: String
106-
get() = try {
107-
telephonyManager.line1Number ?: ""
108-
} catch (e: Exception) {
109-
""
110-
}
111-
11276
/**
11377
* @return 커널
11478
*/
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package ch.lock.mobile.android.deviceinfo.utils
2+
3+
import android.annotation.SuppressLint
4+
import android.content.Context
5+
import android.os.Build
6+
import android.telephony.SubscriptionManager
7+
import android.telephony.TelephonyManager
8+
import androidx.annotation.RequiresApi
9+
10+
@SuppressLint("MissingPermission", "HardwareIds")
11+
open class SimUtils(
12+
private val applicationContext: Context
13+
) {
14+
15+
companion object {
16+
const val TAG: String = "SimUtils"
17+
}
18+
19+
private val telephonyManager: TelephonyManager by lazy {
20+
applicationContext.getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager
21+
}
22+
23+
private val subscriptionManager: SubscriptionManager
24+
@RequiresApi(value = Build.VERSION_CODES.LOLLIPOP_MR1)
25+
get() = applicationContext.getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE) as SubscriptionManager
26+
27+
/**
28+
* @return 디바이스 SIM Serial Number
29+
*/
30+
open val simNumber: String
31+
get() = try {
32+
when {
33+
Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1 ->
34+
subscriptionManager.activeSubscriptionInfoList?.firstOrNull()?.iccId ?: ""
35+
36+
else -> telephonyManager.simSerialNumber ?: ""
37+
}
38+
} catch (e: Exception) {
39+
""
40+
}
41+
42+
/**
43+
* @return 통신사 정보
44+
*/
45+
open val telecom: String
46+
get() = try {
47+
telephonyManager.networkOperatorName ?: ""
48+
} catch (e: Exception) {
49+
""
50+
}
51+
52+
/**
53+
* @return 디바이스 전화번호
54+
*/
55+
open val phoneNumber: String
56+
get() = try {
57+
telephonyManager.line1Number ?: ""
58+
} catch (e: Exception) {
59+
""
60+
}
61+
62+
}
Lines changed: 99 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<layout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto"
34
xmlns:tools="http://schemas.android.com/tools">
45

56
<data>
@@ -9,100 +10,107 @@
910
type="ch.lock.mobile.android.deviceinfo.ui.main.usiminfo.UsimInfoViewModel" />
1011
</data>
1112

12-
<LinearLayout
13-
android:id="@+id/drawer"
13+
<androidx.constraintlayout.widget.ConstraintLayout
1414
android:layout_width="match_parent"
1515
android:layout_height="match_parent"
16-
android:layout_gravity="start"
17-
android:clickable="false"
18-
android:focusable="false"
19-
android:orientation="vertical"
20-
android:padding="15dp">
21-
22-
<!-- 전화번호 -->
23-
<ch.lock.mobile.android.deviceinfo.ui.view.BaseTextView
24-
android:layout_width="wrap_content"
25-
android:layout_height="wrap_content"
26-
android:text="@string/phone_number"
27-
android:textColor="@color/black"
28-
android:textSize="16sp"
29-
android:textStyle="bold" />
30-
31-
<ch.lock.mobile.android.deviceinfo.ui.view.BaseTextView
32-
android:id="@+id/phoneNumber_TextView"
33-
android:layout_width="match_parent"
34-
android:layout_height="wrap_content"
35-
android:layout_marginTop="5dp"
36-
android:text="@{viewModel.phoneNumber}"
37-
android:textColor="@color/black"
38-
android:textIsSelectable="true"
39-
android:textSize="14sp"
40-
tools:text="@string/sample_phone_number" />
41-
42-
<View
43-
android:id="@+id/contour_phoneNumber"
44-
android:layout_width="match_parent"
45-
android:layout_height="1dp"
46-
android:layout_marginTop="10dp"
47-
android:layout_marginBottom="10dp"
48-
android:background="@color/black" />
49-
50-
<!-- 통신사 -->
51-
<ch.lock.mobile.android.deviceinfo.ui.view.BaseTextView
52-
android:layout_width="wrap_content"
53-
android:layout_height="wrap_content"
54-
android:text="@string/telecom"
55-
android:textColor="@color/black"
56-
android:textSize="16sp"
57-
android:textStyle="bold" />
58-
59-
<ch.lock.mobile.android.deviceinfo.ui.view.BaseTextView
60-
android:id="@+id/telecom_TextView"
61-
android:layout_width="match_parent"
62-
android:layout_height="wrap_content"
63-
android:layout_marginTop="5dp"
64-
android:text="@{viewModel.telecom}"
65-
android:textColor="@color/black"
66-
android:textIsSelectable="true"
67-
android:textSize="14sp"
68-
tools:text="@string/sample_telecom" />
69-
70-
<View
71-
android:id="@+id/contour_telecom"
72-
android:layout_width="match_parent"
73-
android:layout_height="1dp"
74-
android:layout_marginTop="10dp"
75-
android:layout_marginBottom="10dp"
76-
android:background="@color/black" />
77-
78-
<!-- usim 시리얼 번호 -->
79-
<ch.lock.mobile.android.deviceinfo.ui.view.BaseTextView
80-
android:layout_width="wrap_content"
81-
android:layout_height="wrap_content"
82-
android:text="@string/usim_serial_number"
83-
android:textColor="@color/black"
84-
android:textSize="16sp"
85-
android:textStyle="bold" />
86-
87-
<ch.lock.mobile.android.deviceinfo.ui.view.BaseTextView
88-
android:id="@+id/usimNumber_TextView"
89-
android:layout_width="match_parent"
90-
android:layout_height="wrap_content"
91-
android:layout_marginTop="5dp"
92-
android:text="@{viewModel.simNumber}"
93-
android:textColor="@color/black"
94-
android:textIsSelectable="true"
95-
android:textSize="14sp"
96-
tools:text="@string/sample_imei" />
97-
98-
<View
99-
android:id="@+id/contour_usimNumber"
16+
android:background="@color/white">
17+
18+
<LinearLayout
19+
android:id="@+id/drawer"
10020
android:layout_width="match_parent"
101-
android:layout_height="1dp"
102-
android:layout_marginTop="10dp"
103-
android:layout_marginBottom="10dp"
104-
android:background="@color/black" />
21+
android:layout_height="match_parent"
22+
android:layout_gravity="start"
23+
android:clickable="false"
24+
android:focusable="false"
25+
android:orientation="vertical"
26+
android:padding="15dp">
27+
28+
<!-- 전화번호 -->
29+
<ch.lock.mobile.android.deviceinfo.ui.view.BaseTextView
30+
android:layout_width="wrap_content"
31+
android:layout_height="wrap_content"
32+
android:text="@string/phone_number"
33+
android:textColor="@color/black"
34+
android:textSize="16sp"
35+
android:textStyle="bold" />
36+
37+
<ch.lock.mobile.android.deviceinfo.ui.view.BaseTextView
38+
android:id="@+id/phoneNumber_TextView"
39+
android:layout_width="match_parent"
40+
android:layout_height="wrap_content"
41+
android:layout_marginTop="5dp"
42+
android:text="@{viewModel.phoneNumber}"
43+
android:textColor="@color/black"
44+
android:textIsSelectable="true"
45+
android:textSize="14sp"
46+
tools:text="@string/sample_phone_number" />
47+
48+
<View
49+
android:id="@+id/contour_phoneNumber"
50+
android:layout_width="match_parent"
51+
android:layout_height="1dp"
52+
android:layout_marginTop="10dp"
53+
android:layout_marginBottom="10dp"
54+
android:background="@color/black" />
55+
56+
<!-- 통신사 -->
57+
<ch.lock.mobile.android.deviceinfo.ui.view.BaseTextView
58+
android:layout_width="wrap_content"
59+
android:layout_height="wrap_content"
60+
android:text="@string/telecom"
61+
android:textColor="@color/black"
62+
android:textSize="16sp"
63+
android:textStyle="bold" />
64+
65+
<ch.lock.mobile.android.deviceinfo.ui.view.BaseTextView
66+
android:id="@+id/telecom_TextView"
67+
android:layout_width="match_parent"
68+
android:layout_height="wrap_content"
69+
android:layout_marginTop="5dp"
70+
android:text="@{viewModel.telecom}"
71+
android:textColor="@color/black"
72+
android:textIsSelectable="true"
73+
android:textSize="14sp"
74+
tools:text="@string/sample_telecom" />
75+
76+
<View
77+
android:id="@+id/contour_telecom"
78+
android:layout_width="match_parent"
79+
android:layout_height="1dp"
80+
android:layout_marginTop="10dp"
81+
android:layout_marginBottom="10dp"
82+
android:background="@color/black" />
83+
84+
<!-- usim 시리얼 번호 -->
85+
<ch.lock.mobile.android.deviceinfo.ui.view.BaseTextView
86+
android:layout_width="wrap_content"
87+
android:layout_height="wrap_content"
88+
android:text="@string/usim_serial_number"
89+
android:textColor="@color/black"
90+
android:textSize="16sp"
91+
android:textStyle="bold" />
92+
93+
<ch.lock.mobile.android.deviceinfo.ui.view.BaseTextView
94+
android:id="@+id/usimNumber_TextView"
95+
android:layout_width="match_parent"
96+
android:layout_height="wrap_content"
97+
android:layout_marginTop="5dp"
98+
android:text="@{viewModel.simNumber}"
99+
android:textColor="@color/black"
100+
android:textIsSelectable="true"
101+
android:textSize="14sp"
102+
tools:text="@string/sample_imei" />
103+
104+
<View
105+
android:id="@+id/contour_usimNumber"
106+
android:layout_width="match_parent"
107+
android:layout_height="1dp"
108+
android:layout_marginTop="10dp"
109+
android:layout_marginBottom="10dp"
110+
android:background="@color/black" />
111+
112+
</LinearLayout>
105113

106-
</LinearLayout>
114+
</androidx.constraintlayout.widget.ConstraintLayout>
107115

108116
</layout>

0 commit comments

Comments
 (0)