|
30 | 30 | import android.graphics.drawable.BitmapDrawable;
|
31 | 31 | import android.graphics.drawable.Icon;
|
32 | 32 | import android.net.Uri;
|
33 |
| -import android.util.Log; |
34 | 33 | import android.os.Build;
|
35 | 34 | import android.os.Bundle;
|
36 | 35 | import android.support.annotation.NonNull;
|
|
44 | 43 | import android.telecom.PhoneAccount;
|
45 | 44 | import android.telecom.PhoneAccountHandle;
|
46 | 45 | import android.telecom.TelecomManager;
|
| 46 | +import android.telephony.TelephonyManager; |
| 47 | +import android.util.Log; |
47 | 48 |
|
48 | 49 | import com.facebook.react.bridge.Arguments;
|
49 | 50 | import com.facebook.react.bridge.Dynamic;
|
@@ -92,6 +93,7 @@ public class RNCallKeepModule extends ReactContextBaseJavaModule {
|
92 | 93 |
|
93 | 94 | private static final String TAG = "RNCallKeepModule";
|
94 | 95 | private static TelecomManager telecomManager;
|
| 96 | + private static TelephonyManager telephonyManager; |
95 | 97 | private static Promise hasPhoneAccountPromise;
|
96 | 98 | private ReactApplicationContext reactContext;
|
97 | 99 | public static PhoneAccountHandle handle;
|
@@ -251,7 +253,10 @@ public void checkDefaultPhoneAccount(Promise promise) {
|
251 | 253 | return;
|
252 | 254 | }
|
253 | 255 |
|
254 |
| - promise.resolve(telecomManager.getDefaultOutgoingPhoneAccount("tel") != null); |
| 256 | + boolean hasSim = telephonyManager.getSimState() != TelephonyManager.SIM_STATE_ABSENT; |
| 257 | + boolean hasDefaultAccount = telecomManager.getDefaultOutgoingPhoneAccount("tel") != null; |
| 258 | + |
| 259 | + promise.resolve(!hasSim || hasDefaultAccount); |
255 | 260 | }
|
256 | 261 |
|
257 | 262 | @ReactMethod
|
@@ -435,7 +440,9 @@ private void registerPhoneAccount(Context appContext) {
|
435 | 440 |
|
436 | 441 | PhoneAccount account = builder.build();
|
437 | 442 |
|
438 |
| - telecomManager = (TelecomManager) this.getAppContext().getSystemService(this.getAppContext().TELECOM_SERVICE); |
| 443 | + telephonyManager = (TelephonyManager) this.getAppContext().getSystemService(Context.TELEPHONY_SERVICE); |
| 444 | + telecomManager = (TelecomManager) this.getAppContext().getSystemService(Context.TELECOM_SERVICE); |
| 445 | + |
439 | 446 | telecomManager.registerPhoneAccount(account);
|
440 | 447 | }
|
441 | 448 |
|
|
0 commit comments