forked from odemolliens/react-native-sim-cards-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request odemolliens#83 from MargusSalk/develop
Fix crashing on android < sdk 28
- Loading branch information
Showing
2 changed files
with
45 additions
and
26 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
android/src/main/java/com/reactnativesimcardsmanager/EsimModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.reactnativesimcardsmanager; | ||
|
||
import static android.content.Context.EUICC_SERVICE; | ||
|
||
import android.os.Build; | ||
import android.telephony.euicc.EuiccManager; | ||
|
||
import androidx.annotation.RequiresApi; | ||
|
||
import com.facebook.react.bridge.ReactContext; | ||
|
||
public class EsimModule { | ||
@RequiresApi(api = Build.VERSION_CODES.P) | ||
private EuiccManager mgr; | ||
private final ReactContext mReactContext; | ||
|
||
EsimModule(ReactContext reactContext) { | ||
mReactContext = reactContext; | ||
} | ||
|
||
@RequiresApi(api = Build.VERSION_CODES.P) | ||
public EuiccManager getMgr() { | ||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) { | ||
return null; | ||
} | ||
|
||
if (mgr != null) { | ||
return mgr; | ||
} | ||
|
||
mgr = (EuiccManager) mReactContext.getSystemService(EUICC_SERVICE); | ||
return mgr; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters