-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f6ff132
Showing
100 changed files
with
3,000 additions
and
0 deletions.
There are no files selected for viewing
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,7 @@ | ||
.DS_Store | ||
.dart_tool/ | ||
|
||
.packages | ||
.pub/ | ||
|
||
build/ |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,10 @@ | ||
# This file tracks properties of this Flutter project. | ||
# Used by Flutter tool to assess capabilities and perform upgrades etc. | ||
# | ||
# This file should be version controlled and should not be manually edited. | ||
|
||
version: | ||
revision: 022b333a089afb81c471ec43d1f1f4f26305d876 | ||
channel: dev | ||
|
||
project_type: plugin |
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,19 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "carrier_info", | ||
"request": "launch", | ||
"type": "dart" | ||
}, | ||
{ | ||
"name": "example", | ||
"cwd": "example", | ||
"request": "launch", | ||
"type": "dart" | ||
} | ||
] | ||
} |
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,3 @@ | ||
## 0.0.1 | ||
|
||
* TODO: Describe initial release. |
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 @@ | ||
TODO: Add your license here. |
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,79 @@ | ||
# 📱 Carrier Info | ||
|
||
Carrier Info gets networkType, networkGeneration, mobileCountryCode, mobileCountryCode, e.t.c from both android and ios devices. It's a port from this [js project](https://github.com/react-native-webrtc/react-native-carrier-info) and an improvement on the existing [flt_telephony_info package](https://pub.dev/packages/flt_telephony_info). | ||
|
||
## 📸 Screen Shots | ||
|
||
<p float="left"> | ||
<img src="https://github.com/Zfinix/carrier_info/blob/main/1.png?raw=true" width="200"> | ||
</p> | ||
|
||
### allowsVOIP (iOS only) | ||
|
||
```dart | ||
bool carrierInfo = await CarrierInfo.allowsVOIP; // Indicates if the carrier allows VoIP calls to be made on its network. | ||
``` | ||
|
||
- If you configure a device for a carrier and then remove the SIM card, this property retains the Boolean value indicating the carrier’s policy regarding VoIP. | ||
- Always return `true` on Android. | ||
|
||
### carrierName | ||
|
||
```dart | ||
String carrierInfo = await CarrierInfo.carrierName; // The name of the user’s home cellular service provider. | ||
``` | ||
|
||
- This string is provided by the carrier and formatted for presentation to the user. The value does not change if the user is roaming; it always represents the provider with whom the user has an account. | ||
- If you configure a device for a carrier and then remove the SIM card, this property retains the name of the carrier. | ||
- The value for this property is 'nil' if the device was never configured for a carrier. | ||
|
||
### isoCountryCode | ||
|
||
```dart | ||
String carrierInfo = await CarrierInfo.isoCountryCode; // The ISO country code for the user’s cellular service provider. | ||
``` | ||
|
||
- This property uses the ISO 3166-1 country code representation. | ||
- The value for this property is 'nil' if any of the following apply: | ||
- The device is in Airplane mode. | ||
- There is no SIM card in the device. | ||
- The device is outside of cellular service range. | ||
|
||
### mobileCountryCode | ||
|
||
```dart | ||
String carrierInfo = await CarrierInfo.mobileCountryCode; //The mobile country code (MCC) for the user’s cellular service provider. | ||
``` | ||
|
||
- MCCs are defined by ITU-T Recommendation E.212, “List of Mobile Country or Geographical Area Codes.” | ||
- The value for this property is 'nil' if any of the following apply: | ||
- There is no SIM card in the device. | ||
- The device is outside of cellular service range. | ||
- The value may be 'nil' on hardware prior to iPhone 4S when in Airplane mode. | ||
|
||
### mobileNetworkCode | ||
|
||
```dart | ||
String carrierInfo = await CarrierInfo.mobileNetworkCode // The mobile network code (MNC) for the user’s cellular service provider. | ||
``` | ||
|
||
- The value for this property is 'nil' if any of the following apply: | ||
- There is no SIM card in the device. | ||
- The device is outside of cellular service range. | ||
- The value may be 'nil' on hardware prior to iPhone 4S when in Airplane mode. | ||
|
||
### networkGeneration | ||
|
||
```dart | ||
String carrierInfo = await CarrierInfo.networkGeneration // 5G, 4G ... 2G | ||
``` | ||
|
||
### radioType | ||
|
||
```dart | ||
String carrierInfo = await CarrierInfo.radioType // LTE, HSDPA, e.t.c | ||
``` | ||
|
||
## ✨ Contribution | ||
|
||
Lots of PR's would be needed to make this plugin standard, as for iOS there's a permanent limitation for getting the exact data usage, there's only one way arount it and it's super complex. |
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,8 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/workspace.xml | ||
/.idea/libraries | ||
.DS_Store | ||
/build | ||
/captures |
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,43 @@ | ||
group 'com.chizi.carrier_info' | ||
version '1.0-SNAPSHOT' | ||
|
||
buildscript { | ||
ext.kotlin_version = '1.3.50' | ||
repositories { | ||
google() | ||
jcenter() | ||
} | ||
|
||
dependencies { | ||
classpath 'com.android.tools.build:gradle:3.5.0' | ||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" | ||
} | ||
} | ||
|
||
rootProject.allprojects { | ||
repositories { | ||
google() | ||
jcenter() | ||
} | ||
} | ||
|
||
apply plugin: 'com.android.library' | ||
apply plugin: 'kotlin-android' | ||
|
||
android { | ||
compileSdkVersion 29 | ||
|
||
sourceSets { | ||
main.java.srcDirs += 'src/main/kotlin' | ||
} | ||
defaultConfig { | ||
minSdkVersion 16 | ||
} | ||
lintOptions { | ||
disable 'InvalidPackage' | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" | ||
} |
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,3 @@ | ||
org.gradle.jvmargs=-Xmx1536M | ||
android.useAndroidX=true | ||
android.enableJetifier=true |
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,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip |
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 @@ | ||
rootProject.name = 'carrier_info' |
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,5 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.chizi.carrier_info"> | ||
<uses-permission android:name="android.permission.READ_PHONE_STATE" /> | ||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> | ||
</manifest> |
67 changes: 67 additions & 0 deletions
67
android/src/main/kotlin/com/chizi/carrier_info/CarrierInfoPlugin.kt
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,67 @@ | ||
package com.chizi.carrier_info | ||
|
||
import androidx.annotation.NonNull | ||
import io.flutter.embedding.engine.plugins.FlutterPlugin | ||
import io.flutter.embedding.engine.plugins.activity.ActivityAware | ||
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding | ||
import io.flutter.plugin.common.MethodChannel | ||
import io.flutter.plugin.common.PluginRegistry | ||
|
||
|
||
/** CarrierInfoPlugin */ | ||
class CarrierInfoPlugin: FlutterPlugin, | ||
PluginRegistry.RequestPermissionsResultListener, ActivityAware { | ||
/// The MethodChannel that will the communication between Flutter and native Android | ||
/// | ||
/// This local reference serves to register the plugin with the Flutter Engine and unregister it | ||
/// when the Flutter Engine is detached from the Activity | ||
|
||
private var channel: MethodChannel? = null | ||
private val channelID = "plugins.chizi.tech/carrier_info" | ||
private var handler: MethodCallHandlerImpl? = null | ||
|
||
override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) { | ||
setupChannel(flutterPluginBinding) | ||
} | ||
|
||
override fun onDetachedFromEngine(@NonNull binding: FlutterPlugin.FlutterPluginBinding) { | ||
teardownChannel() | ||
} | ||
|
||
private fun setupChannel(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) { | ||
channel = MethodChannel(flutterPluginBinding.binaryMessenger, channelID) | ||
handler = MethodCallHandlerImpl(flutterPluginBinding.applicationContext, null) | ||
channel?.setMethodCallHandler(handler) | ||
} | ||
|
||
override fun onAttachedToActivity(binding: ActivityPluginBinding) { | ||
handler?.setActivity(binding.activity) | ||
} | ||
|
||
override fun onDetachedFromActivityForConfigChanges() { | ||
handler?.setActivity(null) | ||
} | ||
|
||
override fun onReattachedToActivityForConfigChanges(binding: ActivityPluginBinding) { | ||
onAttachedToActivity(binding) | ||
binding.addRequestPermissionsResultListener(this) | ||
} | ||
|
||
override fun onDetachedFromActivity() { | ||
onDetachedFromActivity() | ||
} | ||
|
||
|
||
|
||
|
||
private fun teardownChannel() { | ||
channel?.setMethodCallHandler(null) | ||
channel = null | ||
handler = null | ||
} | ||
|
||
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>?, grantResults: IntArray?): Boolean { | ||
handler?.onRequestPermissionsResult(requestCode,permissions, grantResults) | ||
return true | ||
} | ||
} |
Oops, something went wrong.