Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
permission_handler
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
songyanzhi
permission_handler
Commits
1a2365b4
Unverified
Commit
1a2365b4
authored
May 18, 2019
by
Sebastian Roth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a few more conditions for ServiceStatus (phone) on Android
parent
43f4ffc5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
1 deletions
+39
-1
android/src/main/java/com/baseflow/permissionhandler/PermissionHandlerPlugin.java
+27
-1
lib/src/permission_handler.dart
+12
-0
No files found.
android/src/main/java/com/baseflow/permissionhandler/PermissionHandlerPlugin.java
View file @
1a2365b4
...
...
@@ -7,9 +7,12 @@ import android.content.Context;
import
android.content.Intent
;
import
android.content.pm.PackageInfo
;
import
android.content.pm.PackageManager
;
import
android.content.pm.ResolveInfo
;
import
android.location.LocationManager
;
import
android.net.Uri
;
import
android.os.Build
;
import
android.provider.Settings
;
import
android.telephony.TelephonyManager
;
import
android.text.TextUtils
;
import
android.util.Log
;
...
...
@@ -283,7 +286,30 @@ public class PermissionHandlerPlugin implements MethodCallHandler {
if
(
permission
==
PERMISSION_GROUP_PHONE
)
{
PackageManager
pm
=
context
.
getPackageManager
();
return
pm
.
hasSystemFeature
(
PackageManager
.
FEATURE_TELEPHONY
)
?
SERVICE_STATUS_ENABLED
:
SERVICE_STATUS_NOT_APPLICABLE
;
if
(!
pm
.
hasSystemFeature
(
PackageManager
.
FEATURE_TELEPHONY
))
{
return
SERVICE_STATUS_NOT_APPLICABLE
;
}
TelephonyManager
telephonyManager
=
(
TelephonyManager
)
context
.
getSystemService
(
Context
.
TELEPHONY_SERVICE
);
if
(
telephonyManager
.
getPhoneType
()
==
TelephonyManager
.
PHONE_TYPE_NONE
)
{
return
SERVICE_STATUS_NOT_APPLICABLE
;
}
Intent
callIntent
=
new
Intent
(
Intent
.
ACTION_CALL
);
callIntent
.
setData
(
Uri
.
parse
(
"tel:123123"
));
List
<
ResolveInfo
>
callAppsList
=
pm
.
queryIntentActivities
(
callIntent
,
0
);
if
(
callAppsList
.
isEmpty
())
{
return
SERVICE_STATUS_NOT_APPLICABLE
;
}
if
(
telephonyManager
.
getSimState
()
!=
TelephonyManager
.
SIM_STATE_READY
)
{
return
SERVICE_STATUS_DISABLED
;
}
return
SERVICE_STATUS_ENABLED
;
}
return
SERVICE_STATUS_NOT_APPLICABLE
;
...
...
lib/src/permission_handler.dart
View file @
1a2365b4
...
...
@@ -40,6 +40,18 @@ class PermissionHandler {
/// Check current service status.
///
/// Returns a [Future] containing the current service status for the supplied [PermissionGroup].
///
/// Notes about specific PermissionGroups:
/// - **PermissionGroup.phone** on Android:
/// - The method will return [ServiceStatus.notApplicable] when:
/// 1. the device lacks the TELEPHONY feature
/// 1. TelephonyManager.getPhoneType() returns PHONE_TYPE_NONE
/// 1. when no Intents can be resolved to handle the `tel:` scheme
/// - The method will return [ServiceStatus.disabled] when:
/// 1. the SIM card is missing
/// - **PLEASE NOTE that this is still not a perfect indication** of the
/// devices' capability to place & connect phone calls
/// as it also depends on the network condition.
Future
<
ServiceStatus
>
checkServiceStatus
(
PermissionGroup
permission
)
async
{
final
int
status
=
await
_methodChannel
.
invokeMethod
(
'checkServiceStatus'
,
permission
.
value
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment