@@ -218,13 +218,11 @@ public void initializeTelecomManager() {
218
218
219
219
@ ReactMethod
220
220
public void setSettings (ReadableMap options ) {
221
+ Log .d (TAG , "[RNCallKeepModule] setSettings : " + options );
221
222
if (options == null ) {
222
223
return ;
223
224
}
224
- Log .d (TAG , "[RNCallKeepModule] setSettings: " + options );
225
- storeSettings (options );
226
-
227
- _settings = getSettings (null );
225
+ _settings = storeSettings (options );
228
226
}
229
227
230
228
@ ReactMethod
@@ -239,7 +237,7 @@ public void removeListeners(Integer count) {
239
237
240
238
@ ReactMethod
241
239
public void setup (ReadableMap options ) {
242
- Log .d (TAG , "[RNCallKeepModule] setup" );
240
+ Log .d (TAG , "[RNCallKeepModule] setup : " + options );
243
241
244
242
VoiceConnectionService .setAvailable (false );
245
243
VoiceConnectionService .setInitialized (true );
@@ -270,7 +268,7 @@ public void setup(ReadableMap options) {
270
268
271
269
@ ReactMethod
272
270
public void registerPhoneAccount (ReadableMap options ) {
273
- storeSettings (options );
271
+ setSettings (options );
274
272
275
273
if (!isConnectionServiceAvailable ()) {
276
274
Log .w (TAG , "[RNCallKeepModule] registerPhoneAccount ignored due to no ConnectionService" );
@@ -806,7 +804,7 @@ public void setForegroundServiceSettings(ReadableMap foregroundServerSettings) {
806
804
settings .putMap ("foregroundService" , MapUtils .readableToWritableMap (foregroundServerSettings ));
807
805
}
808
806
809
- storeSettings (settings );
807
+ setSettings (settings );
810
808
}
811
809
812
810
@ ReactMethod
@@ -1056,11 +1054,11 @@ private Context getAppContext() {
1056
1054
}
1057
1055
1058
1056
// Store all callkeep settings in JSON
1059
- private void storeSettings (ReadableMap options ) {
1060
- Context context = getInstance ( null , false ). getAppContext ();
1057
+ private WritableMap storeSettings (ReadableMap options ) {
1058
+ Context context = getAppContext ();
1061
1059
if (context == null ) {
1062
1060
Log .w (TAG , "[RNCallKeepModule][storeSettings] no react context found." );
1063
- return ;
1061
+ return MapUtils . readableToWritableMap ( options ) ;
1064
1062
}
1065
1063
1066
1064
SharedPreferences sharedPref = context .getSharedPreferences ("rn-callkeep" , Context .MODE_PRIVATE );
@@ -1069,15 +1067,17 @@ private void storeSettings(ReadableMap options) {
1069
1067
String jsonString = jsonObject .toString ();
1070
1068
sharedPref .edit ().putString ("settings" , jsonString ).apply ();
1071
1069
} catch (JSONException e ) {
1070
+ Log .w (TAG , "[RNCallKeepModule][storeSettings] exception: " + e );
1072
1071
}
1072
+ return MapUtils .readableToWritableMap (options );
1073
1073
}
1074
1074
1075
1075
private static void fetchStoredSettings (@ Nullable Context fromContext ) {
1076
- if (instance == null && fromContext == null ) {
1076
+ Context context = fromContext != null ? fromContext : instance .getAppContext ();
1077
+ if (instance == null && context == null ) {
1077
1078
Log .w (TAG , "[RNCallKeepModule][fetchStoredSettings] no instance nor fromContext." );
1078
1079
return ;
1079
1080
}
1080
- Context context = fromContext != null ? fromContext : instance .getAppContext ();
1081
1081
_settings = new WritableNativeMap ();
1082
1082
if (context == null ) {
1083
1083
Log .w (TAG , "[RNCallKeepModule][fetchStoredSettings] no react context found." );
0 commit comments