38
38
public class ConsentMethodHandler implements MethodChannel .MethodCallHandler {
39
39
private static final String TAG = "ConsentMethodHandler" ;
40
40
private final Context context ;
41
- private Consent consentInfo ;
42
41
43
- public ConsentMethodHandler (final Context context , final Consent consentInfo ) {
42
+ public ConsentMethodHandler (final Context context ) {
44
43
this .context = context ;
45
- this .consentInfo = consentInfo ;
46
44
}
47
45
48
46
@ Override
@@ -77,28 +75,21 @@ public void onMethodCall(@NonNull final MethodCall call, @NonNull final Result r
77
75
78
76
private void getTestDeviceId (Result result ) {
79
77
HMSLogger .getInstance (context ).startMethodExecutionTimer ("getTestDeviceId" );
80
- if (consentInfo != null ) {
81
- result .success (consentInfo .getTestDeviceId ());
82
- HMSLogger .getInstance (context ).sendSingleEvent ("getTestDeviceId" );
83
- } else {
84
- result .error (ErrorCodes .INNER , "Consent instance is null. getTestDeviceId failed." , "" );
85
- HMSLogger .getInstance (context ).sendSingleEvent ("getTestDeviceId" , ErrorCodes .INNER );
86
- }
78
+ result .success (Consent .getInstance (context ).getTestDeviceId ());
79
+ HMSLogger .getInstance (context ).sendSingleEvent ("getTestDeviceId" );
87
80
}
88
81
89
82
private void addTestDeviceId (MethodCall call , MethodChannel .Result result ) {
90
83
HMSLogger .getInstance (context ).startMethodExecutionTimer ("addTestDeviceId" );
91
84
String deviceId = FromMap .toString ("deviceId" , call .argument ("deviceId" ));
92
- if (deviceId != null && consentInfo != null ) {
85
+ if (deviceId != null ) {
93
86
Log .i (TAG , "SDK addTestDeviceId begin" );
94
- consentInfo .addTestDeviceId (deviceId );
87
+ Consent . getInstance ( context ) .addTestDeviceId (deviceId );
95
88
Log .i (TAG , "SDK addTestDeviceId end" );
96
89
result .success (true );
97
90
HMSLogger .getInstance (context ).sendSingleEvent ("addTestDeviceId" );
98
91
} else {
99
- result .error (ErrorCodes .NULL_PARAM ,
100
- "Test deviceId is null? : " + (deviceId == null ) + ". | Consent initialized? : " + (consentInfo != null ) + ". addTestDevice failed." ,
101
- "" );
92
+ result .error (ErrorCodes .NULL_PARAM , "Test deviceId is null? : true. addTestDevice failed." , "" );
102
93
HMSLogger .getInstance (context ).sendSingleEvent ("addTestDeviceId" , ErrorCodes .NULL_PARAM );
103
94
}
104
95
}
@@ -109,7 +100,7 @@ private void setDebugNeedConsent(MethodCall call, MethodChannel.Result result) {
109
100
if (consentStr != null ) {
110
101
DebugNeedConsent needConsent = DebugNeedConsent .valueOf (consentStr );
111
102
Log .i (TAG , "SDK setDebugNeedConsent begin" );
112
- consentInfo .setDebugNeedConsent (needConsent );
103
+ Consent . getInstance ( context ) .setDebugNeedConsent (needConsent );
113
104
Log .i (TAG , "SDK setDebugNeedConsent end" );
114
105
result .success (true );
115
106
HMSLogger .getInstance (context ).sendSingleEvent ("setDebugNeedConsent" );
@@ -124,7 +115,7 @@ private void setDebugNeedConsent(MethodCall call, MethodChannel.Result result) {
124
115
private void setUnderAgeOfPromise (MethodCall call , MethodChannel .Result result ) {
125
116
HMSLogger .getInstance (context ).startMethodExecutionTimer ("setUnderAgeOfPromise" );
126
117
Boolean ageOfPromise = FromMap .toBoolean ("ageOfPromise" , call .argument ("ageOfPromise" ));
127
- consentInfo .setUnderAgeOfPromise (ageOfPromise );
118
+ Consent . getInstance ( context ) .setUnderAgeOfPromise (ageOfPromise );
128
119
result .success (true );
129
120
HMSLogger .getInstance (context ).sendSingleEvent ("setUnderAgeOfPromise" );
130
121
}
@@ -135,7 +126,7 @@ private void setConsentStatus(MethodCall call, MethodChannel.Result result) {
135
126
if (status != null ) {
136
127
ConsentStatus consentStatus = ConsentStatus .valueOf (status );
137
128
Log .i (TAG , "setConsentStatus begin" );
138
- consentInfo .setConsentStatus (consentStatus );
129
+ Consent . getInstance ( context ) .setConsentStatus (consentStatus );
139
130
Log .i (TAG , "setConsentStatus end" );
140
131
result .success (true );
141
132
HMSLogger .getInstance (context ).sendSingleEvent ("setConsentStatus" );
0 commit comments