|
27 | 27 | import android.content.pm.ApplicationInfo;
|
28 | 28 | import android.content.pm.PackageManager;
|
29 | 29 | import android.net.Uri;
|
30 |
| -import android.util.Log; |
31 | 30 | import android.os.Build;
|
32 | 31 | import android.os.Bundle;
|
33 | 32 | import android.support.annotation.Nullable;
|
|
39 | 38 | import android.telecom.PhoneAccount;
|
40 | 39 | import android.telecom.PhoneAccountHandle;
|
41 | 40 | import android.telecom.TelecomManager;
|
| 41 | +import android.telephony.TelephonyManager; |
| 42 | +import android.util.Log; |
42 | 43 |
|
43 | 44 | import com.facebook.react.bridge.Arguments;
|
44 | 45 | import com.facebook.react.bridge.Promise;
|
@@ -71,6 +72,7 @@ public class RNCallKeepModule extends ReactContextBaseJavaModule {
|
71 | 72 |
|
72 | 73 | private static final String TAG = "RNCallKeepModule";
|
73 | 74 | private static TelecomManager telecomManager;
|
| 75 | + private static TelephonyManager telephonyManager; |
74 | 76 | private static Promise hasPhoneAccountPromise;
|
75 | 77 | private ReactApplicationContext reactContext;
|
76 | 78 | private static PhoneAccountHandle handle;
|
@@ -197,7 +199,10 @@ public void checkDefaultPhoneAccount(Promise promise) {
|
197 | 199 | return;
|
198 | 200 | }
|
199 | 201 |
|
200 |
| - promise.resolve(telecomManager.getDefaultOutgoingPhoneAccount("tel") != null); |
| 202 | + boolean hasSim = telephonyManager.getSimState() != TelephonyManager.SIM_STATE_ABSENT; |
| 203 | + boolean hasDefaultAccount = telecomManager.getDefaultOutgoingPhoneAccount("tel") != null; |
| 204 | + |
| 205 | + promise.resolve(!hasSim || hasDefaultAccount); |
201 | 206 | }
|
202 | 207 |
|
203 | 208 | @ReactMethod
|
@@ -287,7 +292,9 @@ private void registerPhoneAccount(Context appContext) {
|
287 | 292 | .setCapabilities(PhoneAccount.CAPABILITY_CALL_PROVIDER)
|
288 | 293 | .build();
|
289 | 294 |
|
290 |
| - telecomManager = (TelecomManager) this.getAppContext().getSystemService(this.getAppContext().TELECOM_SERVICE); |
| 295 | + telephonyManager = (TelephonyManager) this.getAppContext().getSystemService(Context.TELEPHONY_SERVICE); |
| 296 | + telecomManager = (TelecomManager) this.getAppContext().getSystemService(Context.TELECOM_SERVICE); |
| 297 | + |
291 | 298 | telecomManager.registerPhoneAccount(account);
|
292 | 299 | }
|
293 | 300 |
|
|
0 commit comments