diff --git a/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/BluetoothAdapterFlutterApiImpl.java b/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/BluetoothAdapterFlutterApiImpl.java
new file mode 100644
index 000000000..f2eb0c8eb
--- /dev/null
+++ b/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/BluetoothAdapterFlutterApiImpl.java
@@ -0,0 +1,61 @@
+package com.baseflow.permissionhandler;
+
+import android.bluetooth.BluetoothAdapter;
+
+import androidx.annotation.NonNull;
+
+import com.baseflow.instancemanager.InstanceManager;
+import com.baseflow.permissionhandler.PermissionHandlerPigeon.BluetoothAdapterFlutterApi;
+
+import java.util.UUID;
+
+import io.flutter.plugin.common.BinaryMessenger;
+
+/**
+ * Flutter API implementation for `BluetoothAdapter`.
+ *
+ *
This class may handle adding native instances that are attached to a Dart instance or passing
+ * arguments of callbacks methods to a Dart instance.
+ */
+public class BluetoothAdapterFlutterApiImpl {
+ private final InstanceManager instanceManager;
+
+ private final BluetoothAdapterFlutterApi api;
+
+ /**
+ * Constructs a {@link BluetoothAdapterFlutterApiImpl}.
+ *
+ * @param binaryMessenger used to communicate with Dart over asynchronous messages
+ * @param instanceManager maintains instances stored to communicate with attached Dart objects
+ */
+ public BluetoothAdapterFlutterApiImpl(
+ @NonNull BinaryMessenger binaryMessenger,
+ @NonNull InstanceManager instanceManager
+ ) {
+ this.instanceManager = instanceManager;
+ api = new BluetoothAdapterFlutterApi(binaryMessenger);
+ }
+
+ /**
+ * Stores the `BluetoothAdapter` instance and notifies Dart to create and store a new
+ * `BluetoothAdapter` instance that is attached to this one. If `instance` has already been
+ * added, this method does nothing.
+ */
+ public void create(@NonNull BluetoothAdapter instance) {
+ if (!instanceManager.containsInstance(instance)) {
+ final UUID bluetoothAdapterInstanceUuid = instanceManager.addHostCreatedInstance(instance);
+ api.create(bluetoothAdapterInstanceUuid.toString(), reply -> {});
+ }
+ }
+
+ /**
+ * Disposes of the `BluetoothAdapter` instance in the instance manager and notifies Dart to do
+ * the same. If `instance` was already disposed, this method does nothing.
+ */
+ public void dispose(BluetoothAdapter instance) {
+ final UUID bluetoothAdapterInstanceUuid = instanceManager.getIdentifierForStrongReference(instance);
+ if (bluetoothAdapterInstanceUuid != null) {
+ api.dispose(bluetoothAdapterInstanceUuid.toString(), reply -> {});
+ }
+ }
+}
diff --git a/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/BluetoothAdapterHostApiImpl.java b/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/BluetoothAdapterHostApiImpl.java
new file mode 100644
index 000000000..866b7e49e
--- /dev/null
+++ b/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/BluetoothAdapterHostApiImpl.java
@@ -0,0 +1,53 @@
+package com.baseflow.permissionhandler;
+
+
+import android.bluetooth.BluetoothAdapter;
+
+import androidx.annotation.NonNull;
+
+import com.baseflow.instancemanager.InstanceManager;
+import com.baseflow.permissionhandler.PermissionHandlerPigeon.BluetoothAdapterHostApi;
+
+import java.util.UUID;
+
+/**
+ * Host API implementation for `BluetoothAdapter`.
+ *
+ *
This class may handle instantiating and adding native object instances that are attached to a
+ * Dart instance or handle method calls on the associated native class or an instance of the class.
+ */
+public class BluetoothAdapterHostApiImpl implements BluetoothAdapterHostApi {
+ private final InstanceManager instanceManager;
+
+ private final BluetoothAdapterFlutterApiImpl bluetoothAdapterFlutterApi;
+
+ /**
+ * Constructs an {@link BluetoothAdapterHostApiImpl}.
+ *
+ * @param instanceManager maintains instances stored to communicate with attached Dart objects
+ */
+ public BluetoothAdapterHostApiImpl(
+ @NonNull BluetoothAdapterFlutterApiImpl bluetoothAdapterFlutterApi,
+ @NonNull InstanceManager instanceManager
+ ) {
+ this.bluetoothAdapterFlutterApi = bluetoothAdapterFlutterApi;
+ this.instanceManager = instanceManager;
+ }
+
+ @Deprecated
+ @NonNull
+ @Override
+ public String getDefaultAdapter() {
+ final BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
+ bluetoothAdapterFlutterApi.create(bluetoothAdapter);
+ return instanceManager.getIdentifierForStrongReference(bluetoothAdapter).toString();
+ }
+
+ @NonNull
+ @Override
+ public Boolean isEnabled(@NonNull String instanceId) {
+ final UUID instanceUuid = UUID.fromString(instanceId);
+ final BluetoothAdapter bluetoothAdapter = instanceManager.getInstance(instanceUuid);
+ return bluetoothAdapter.isEnabled();
+ }
+}
diff --git a/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/BluetoothManagerFlutterApiImpl.java b/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/BluetoothManagerFlutterApiImpl.java
new file mode 100644
index 000000000..bbef4a182
--- /dev/null
+++ b/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/BluetoothManagerFlutterApiImpl.java
@@ -0,0 +1,61 @@
+package com.baseflow.permissionhandler;
+
+import android.bluetooth.BluetoothManager;
+
+import androidx.annotation.NonNull;
+
+import com.baseflow.instancemanager.InstanceManager;
+import com.baseflow.permissionhandler.PermissionHandlerPigeon.BluetoothManagerFlutterApi;
+
+import java.util.UUID;
+
+import io.flutter.plugin.common.BinaryMessenger;
+
+/**
+ * Flutter API implementation for `BluetoothManager`.
+ *
+ *
This class may handle adding native instances that are attached to a Dart instance or passing
+ * arguments of callbacks methods to a Dart instance.
+ */
+public class BluetoothManagerFlutterApiImpl {
+ private final InstanceManager instanceManager;
+
+ private final BluetoothManagerFlutterApi api;
+
+ /**
+ * Constructs a {@link BluetoothManagerFlutterApiImpl}.
+ *
+ * @param binaryMessenger used to communicate with Dart over asynchronous messages
+ * @param instanceManager maintains instances stored to communicate with attached Dart objects
+ */
+ public BluetoothManagerFlutterApiImpl(
+ @NonNull BinaryMessenger binaryMessenger,
+ @NonNull InstanceManager instanceManager
+ ) {
+ this.instanceManager = instanceManager;
+ api = new BluetoothManagerFlutterApi(binaryMessenger);
+ }
+
+ /**
+ * Stores the `BluetoothManager` instance and notifies Dart to create and store a new
+ * `BluetoothManager` instance that is attached to this one. If `instance` has already been
+ * added, this method does nothing.
+ */
+ public void create(@NonNull BluetoothManager instance) {
+ if (!instanceManager.containsInstance(instance)) {
+ final UUID bluetoothManagerInstanceUuid = instanceManager.addHostCreatedInstance(instance);
+ api.create(bluetoothManagerInstanceUuid.toString(), reply -> {});
+ }
+ }
+
+ /**
+ * Disposes of the `BluetoothManager` instance in the instance manager and notifies Dart to do
+ * the same. If `instance` was already disposed, this method does nothing.
+ */
+ public void dispose(BluetoothManager instance) {
+ final UUID bluetoothManagerInstanceUuid = instanceManager.getIdentifierForStrongReference(instance);
+ if (bluetoothManagerInstanceUuid != null) {
+ api.dispose(bluetoothManagerInstanceUuid.toString(), reply -> {});
+ }
+ }
+}
diff --git a/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/BluetoothManagerHostApiImpl.java b/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/BluetoothManagerHostApiImpl.java
new file mode 100644
index 000000000..bf11ff480
--- /dev/null
+++ b/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/BluetoothManagerHostApiImpl.java
@@ -0,0 +1,52 @@
+package com.baseflow.permissionhandler;
+
+
+import android.bluetooth.BluetoothAdapter;
+import android.bluetooth.BluetoothManager;
+import android.os.Build;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.RequiresApi;
+
+import com.baseflow.instancemanager.InstanceManager;
+import com.baseflow.permissionhandler.PermissionHandlerPigeon.BluetoothManagerHostApi;
+
+import java.util.UUID;
+
+/**
+ * Host API implementation for `BluetoothManager`.
+ *
+ *
This class may handle instantiating and adding native object instances that are attached to a
+ * Dart instance or handle method calls on the associated native class or an instance of the class.
+ */
+public class BluetoothManagerHostApiImpl implements BluetoothManagerHostApi {
+ private final InstanceManager instanceManager;
+
+ private final BluetoothAdapterFlutterApiImpl bluetoothAdapterFlutterApi;
+
+ /**
+ * Constructs an {@link BluetoothManagerHostApiImpl}.
+ *
+ * @param instanceManager maintains instances stored to communicate with attached Dart objects
+ */
+ public BluetoothManagerHostApiImpl(
+ @NonNull BluetoothAdapterFlutterApiImpl bluetoothAdapterFlutterApi,
+ @NonNull InstanceManager instanceManager
+ ) {
+ this.bluetoothAdapterFlutterApi = bluetoothAdapterFlutterApi;
+ this.instanceManager = instanceManager;
+ }
+
+ @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR2)
+ @NonNull
+ @Override
+ public String getAdapter(@NonNull String instanceId) {
+ final UUID instanceUuid = UUID.fromString(instanceId);
+ final BluetoothManager bluetoothManager = instanceManager.getInstance(instanceUuid);
+ final BluetoothAdapter bluetoothAdapter = bluetoothManager.getAdapter();
+
+ bluetoothAdapterFlutterApi.create(bluetoothAdapter);
+
+ return instanceManager.getIdentifierForStrongReference(bluetoothAdapter).toString();
+ }
+}
diff --git a/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/ContentResolverFlutterApiImpl.java b/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/ContentResolverFlutterApiImpl.java
new file mode 100644
index 000000000..8e13986d4
--- /dev/null
+++ b/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/ContentResolverFlutterApiImpl.java
@@ -0,0 +1,61 @@
+package com.baseflow.permissionhandler;
+
+import android.content.ContentResolver;
+
+import androidx.annotation.NonNull;
+
+import com.baseflow.instancemanager.InstanceManager;
+import com.baseflow.permissionhandler.PermissionHandlerPigeon.ContentResolverFlutterApi;
+
+import java.util.UUID;
+
+import io.flutter.plugin.common.BinaryMessenger;
+
+/**
+ * Flutter API implementation for `ContentResolver`.
+ *
+ *
This class may handle adding native instances that are attached to a Dart instance or passing
+ * arguments of callbacks methods to a Dart instance.
+ */
+public class ContentResolverFlutterApiImpl {
+ private final InstanceManager instanceManager;
+
+ private final ContentResolverFlutterApi api;
+
+ /**
+ * Constructs a {@link ContentResolverFlutterApiImpl}.
+ *
+ * @param binaryMessenger used to communicate with Dart over asynchronous messages
+ * @param instanceManager maintains instances stored to communicate with attached Dart objects
+ */
+ public ContentResolverFlutterApiImpl(
+ @NonNull BinaryMessenger binaryMessenger,
+ @NonNull InstanceManager instanceManager
+ ) {
+ this.instanceManager = instanceManager;
+ api = new ContentResolverFlutterApi(binaryMessenger);
+ }
+
+ /**
+ * Stores the `ContentResolver` instance and notifies Dart to create and store a new
+ * `ContentResolver` instance that is attached to this one. If `instance` has already been
+ * added, this method does nothing.
+ */
+ public void create(@NonNull ContentResolver instance) {
+ if (!instanceManager.containsInstance(instance)) {
+ final UUID contentResolverInstanceUuid = instanceManager.addHostCreatedInstance(instance);
+ api.create(contentResolverInstanceUuid.toString(), reply -> {});
+ }
+ }
+
+ /**
+ * Disposes of the `ContentResolver` instance in the instance manager and notifies Dart to do
+ * the same. If `instance` was already disposed, this method does nothing.
+ */
+ public void dispose(ContentResolver instance) {
+ final UUID contentResolverInstanceUuid = instanceManager.getIdentifierForStrongReference(instance);
+ if (contentResolverInstanceUuid != null) {
+ api.dispose(contentResolverInstanceUuid.toString(), reply -> {});
+ }
+ }
+}
diff --git a/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/ContextHostApiImpl.java b/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/ContextHostApiImpl.java
index b38254024..c301dd663 100644
--- a/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/ContextHostApiImpl.java
+++ b/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/ContextHostApiImpl.java
@@ -2,10 +2,15 @@
import android.app.AlarmManager;
import android.app.NotificationManager;
+import android.bluetooth.BluetoothManager;
+import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
+import android.location.LocationManager;
+import android.os.Build;
import android.os.PowerManager;
+import android.telephony.TelephonyManager;
import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;
@@ -32,6 +37,14 @@ public class ContextHostApiImpl implements ContextHostApi {
private final NotificationManagerFlutterApiImpl notificationManagerFlutterApi;
+ private final TelephonyManagerFlutterApiImpl telephonyManagerFlutterApi;
+
+ private final LocationManagerFlutterApiImpl locationManagerFlutterApi;
+
+ private final BluetoothManagerFlutterApiImpl bluetoothManagerFlutterApi;
+
+ private final ContentResolverFlutterApiImpl contentResolverFlutterApi;
+
/**
* Constructs an {@link ContextHostApiImpl}.
*
@@ -42,12 +55,20 @@ public ContextHostApiImpl(
@NonNull AlarmManagerFlutterApiImpl alarmManagerFlutterApi,
@NonNull PackageManagerFlutterApiImpl packageManagerFlutterApi,
@NonNull NotificationManagerFlutterApiImpl notificationManagerFlutterApi,
+ @NonNull TelephonyManagerFlutterApiImpl telephonyManagerFlutterApi,
+ @NonNull LocationManagerFlutterApiImpl locationManagerFlutterApi,
+ @NonNull BluetoothManagerFlutterApiImpl bluetoothManagerFlutterApi,
+ @NonNull ContentResolverFlutterApiImpl contentResolverFlutterApi,
@NonNull InstanceManager instanceManager
) {
this.powerManagerFlutterApi = powerManagerFlutterApi;
this.alarmManagerFlutterApi = alarmManagerFlutterApi;
this.packageManagerFlutterApi = packageManagerFlutterApi;
this.notificationManagerFlutterApi = notificationManagerFlutterApi;
+ this.telephonyManagerFlutterApi = telephonyManagerFlutterApi;
+ this.locationManagerFlutterApi = locationManagerFlutterApi;
+ this.bluetoothManagerFlutterApi = bluetoothManagerFlutterApi;
+ this.contentResolverFlutterApi = contentResolverFlutterApi;
this.instanceManager = instanceManager;
}
@@ -87,7 +108,7 @@ public void startActivity(
}
@Override
- @NonNull public String getSystemService(
+ public String getSystemService(
@NonNull String instanceId,
@NonNull String name
) {
@@ -102,9 +123,21 @@ public void startActivity(
alarmManagerFlutterApi.create((AlarmManager) systemService);
} else if (systemService instanceof NotificationManager) {
notificationManagerFlutterApi.create((NotificationManager) systemService);
+ } else if (systemService instanceof TelephonyManager) {
+ telephonyManagerFlutterApi.create((TelephonyManager) systemService);
+ } else if (systemService instanceof LocationManager) {
+ locationManagerFlutterApi.create((LocationManager) systemService);
+ } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
+ if (systemService instanceof BluetoothManager) {
+ bluetoothManagerFlutterApi.create((BluetoothManager) systemService);
+ }
}
final UUID systemServiceUuid = instanceManager.getIdentifierForStrongReference(systemService);
+
+ if (systemServiceUuid == null) {
+ return null;
+ }
return systemServiceUuid.toString();
}
@@ -122,4 +155,19 @@ public void startActivity(
final UUID packageManagerUuid = instanceManager.getIdentifierForStrongReference(packageManager);
return packageManagerUuid.toString();
}
+
+ @Override
+ @NonNull public String getContentResolver(
+ @NonNull String instanceId
+ ) {
+ final UUID instanceUuid = UUID.fromString(instanceId);
+ final Context context = instanceManager.getInstance(instanceUuid);
+
+ final ContentResolver contentResolver = context.getContentResolver();
+
+ contentResolverFlutterApi.create(contentResolver);
+
+ final UUID contentResolverUuid = instanceManager.getIdentifierForStrongReference(contentResolver);
+ return contentResolverUuid.toString();
+ }
}
diff --git a/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/FeatureInfoFlutterApiImpl.java b/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/FeatureInfoFlutterApiImpl.java
new file mode 100644
index 000000000..c1658c113
--- /dev/null
+++ b/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/FeatureInfoFlutterApiImpl.java
@@ -0,0 +1,61 @@
+package com.baseflow.permissionhandler;
+
+import android.content.pm.FeatureInfo;
+
+import androidx.annotation.NonNull;
+
+import com.baseflow.instancemanager.InstanceManager;
+import com.baseflow.permissionhandler.PermissionHandlerPigeon.FeatureInfoFlutterApi;
+
+import java.util.UUID;
+
+import io.flutter.plugin.common.BinaryMessenger;
+
+/**
+ * Flutter API implementation for `FeatureInfo`.
+ *
+ *
This class may handle adding native instances that are attached to a Dart instance or passing
+ * arguments of callbacks methods to a Dart instance.
+ */
+public class FeatureInfoFlutterApiImpl {
+ private final InstanceManager instanceManager;
+
+ private final FeatureInfoFlutterApi api;
+
+ /**
+ * Constructs a {@link FeatureInfoFlutterApiImpl}.
+ *
+ * @param binaryMessenger used to communicate with Dart over asynchronous messages
+ * @param instanceManager maintains instances stored to communicate with attached Dart objects
+ */
+ public FeatureInfoFlutterApiImpl(
+ @NonNull BinaryMessenger binaryMessenger,
+ @NonNull InstanceManager instanceManager
+ ) {
+ this.instanceManager = instanceManager;
+ api = new FeatureInfoFlutterApi(binaryMessenger);
+ }
+
+ /**
+ * Stores the `FeatureInfo` instance and notifies Dart to create and store a new `FeatureInfo`
+ * instance that is attached to this one. If `instance` has already been added, this method does
+ * nothing.
+ */
+ public void create(@NonNull FeatureInfo instance) {
+ if (!instanceManager.containsInstance(instance)) {
+ final UUID featureInfoInstanceUuid = instanceManager.addHostCreatedInstance(instance);
+ api.create(featureInfoInstanceUuid.toString(), reply -> {});
+ }
+ }
+
+ /**
+ * Disposes of the `FeatureInfo` instance in the instance manager and notifies Dart to do the
+ * same. If `instance` was already disposed, this method does nothing.
+ */
+ public void dispose(FeatureInfo instance) {
+ final UUID featureInfoInstanceUuid = instanceManager.getIdentifierForStrongReference(instance);
+ if (featureInfoInstanceUuid != null) {
+ api.dispose(featureInfoInstanceUuid.toString(), reply -> {});
+ }
+ }
+}
diff --git a/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/LocationManagerFlutterApiImpl.java b/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/LocationManagerFlutterApiImpl.java
new file mode 100644
index 000000000..adb04443d
--- /dev/null
+++ b/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/LocationManagerFlutterApiImpl.java
@@ -0,0 +1,61 @@
+package com.baseflow.permissionhandler;
+
+import android.location.LocationManager;
+
+import androidx.annotation.NonNull;
+
+import com.baseflow.instancemanager.InstanceManager;
+import com.baseflow.permissionhandler.PermissionHandlerPigeon.LocationManagerFlutterApi;
+
+import java.util.UUID;
+
+import io.flutter.plugin.common.BinaryMessenger;
+
+/**
+ * Flutter API implementation for `LocationManager`.
+ *
+ *
This class may handle adding native instances that are attached to a Dart instance or passing
+ * arguments of callbacks methods to a Dart instance.
+ */
+public class LocationManagerFlutterApiImpl {
+ private final InstanceManager instanceManager;
+
+ private final LocationManagerFlutterApi api;
+
+ /**
+ * Constructs a {@link LocationManagerFlutterApiImpl}.
+ *
+ * @param binaryMessenger used to communicate with Dart over asynchronous messages
+ * @param instanceManager maintains instances stored to communicate with attached Dart objects
+ */
+ public LocationManagerFlutterApiImpl(
+ @NonNull BinaryMessenger binaryMessenger,
+ @NonNull InstanceManager instanceManager
+ ) {
+ this.instanceManager = instanceManager;
+ api = new LocationManagerFlutterApi(binaryMessenger);
+ }
+
+ /**
+ * Stores the `LocationManager` instance and notifies Dart to create and store a new
+ * `LocationManager` instance that is attached to this one. If `instance` has already been
+ * added, this method does nothing.
+ */
+ public void create(@NonNull LocationManager instance) {
+ if (!instanceManager.containsInstance(instance)) {
+ final UUID locationManagerInstanceUuid = instanceManager.addHostCreatedInstance(instance);
+ api.create(locationManagerInstanceUuid.toString(), reply -> {});
+ }
+ }
+
+ /**
+ * Disposes of the `LocationManager` instance in the instance manager and notifies Dart to do
+ * the same. If `instance` was already disposed, this method does nothing.
+ */
+ public void dispose(LocationManager instance) {
+ final UUID locationManagerInstanceUuid = instanceManager.getIdentifierForStrongReference(instance);
+ if (locationManagerInstanceUuid != null) {
+ api.dispose(locationManagerInstanceUuid.toString(), reply -> {});
+ }
+ }
+}
diff --git a/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/LocationManagerHostApiImpl.java b/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/LocationManagerHostApiImpl.java
new file mode 100644
index 000000000..7e2932754
--- /dev/null
+++ b/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/LocationManagerHostApiImpl.java
@@ -0,0 +1,40 @@
+package com.baseflow.permissionhandler;
+
+import android.location.LocationManager;
+
+import androidx.annotation.NonNull;
+import androidx.core.location.LocationManagerCompat;
+
+import com.baseflow.instancemanager.InstanceManager;
+import com.baseflow.permissionhandler.PermissionHandlerPigeon.LocationManagerHostApi;
+
+import java.util.UUID;
+
+/**
+ * Host API implementation for `LocationManager`.
+ *
+ *
This class may handle instantiating and adding native object instances that are attached to a
+ * Dart instance or handle method calls on the associated native class or an instance of the class.
+ */
+public class LocationManagerHostApiImpl implements LocationManagerHostApi {
+ private final InstanceManager instanceManager;
+
+ /**
+ * Constructs an {@link LocationManagerHostApiImpl}.
+ *
+ * @param instanceManager maintains instances stored to communicate with attached Dart objects
+ */
+ public LocationManagerHostApiImpl(
+ @NonNull InstanceManager instanceManager
+ ) {
+ this.instanceManager = instanceManager;
+ }
+
+ @NonNull
+ @Override
+ public Boolean isLocationEnabled(@NonNull String instanceId) {
+ final UUID instanceUuid = UUID.fromString(instanceId);
+ final LocationManager locationManager = instanceManager.getInstance(instanceUuid);
+ return LocationManagerCompat.isLocationEnabled(locationManager);
+ }
+}
diff --git a/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/PackageManagerHostApiImpl.java b/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/PackageManagerHostApiImpl.java
index dd07fa7f9..45bc703a7 100644
--- a/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/PackageManagerHostApiImpl.java
+++ b/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/PackageManagerHostApiImpl.java
@@ -1,6 +1,7 @@
package com.baseflow.permissionhandler;
import android.content.Intent;
+import android.content.pm.FeatureInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.PackageInfoFlags;
@@ -30,6 +31,8 @@ public class PackageManagerHostApiImpl implements PackageManagerHostApi {
private final ResolveInfoFlutterApiImpl resolveInfoFlutterApi;
+ private final FeatureInfoFlutterApiImpl featureInfoFlutterApi;
+
/**
* Constructs an {@link PackageManagerHostApiImpl}.
*
@@ -38,10 +41,12 @@ public class PackageManagerHostApiImpl implements PackageManagerHostApi {
public PackageManagerHostApiImpl(
@NonNull PackageInfoFlutterApiImpl packageInfoFlutterApi,
@NonNull ResolveInfoFlutterApiImpl resolveInfoFlutterApi,
+ @NonNull FeatureInfoFlutterApiImpl featureInfoFlutterApi,
@NonNull InstanceManager instanceManager
) {
this.packageInfoFlutterApi = packageInfoFlutterApi;
this.resolveInfoFlutterApi = resolveInfoFlutterApi;
+ this.featureInfoFlutterApi = featureInfoFlutterApi;
this.instanceManager = instanceManager;
}
@@ -163,4 +168,22 @@ public List queryIntentActivitiesWithInfoFlags(
return resolveInfoInstanceList;
}
+
+ @NonNull
+ @Override
+ public List getSystemAvailableFeatures(@NonNull String instanceId) {
+ final UUID instanceUuid = UUID.fromString(instanceId);
+ final PackageManager packageManager = instanceManager.getInstance(instanceUuid);
+
+ final FeatureInfo[] featureInfoList = packageManager.getSystemAvailableFeatures();
+ final List featureInfoInstanceList = new ArrayList<>();
+
+ for (FeatureInfo featureInfo : featureInfoList) {
+ featureInfoFlutterApi.create(featureInfo);
+ final UUID featureInfoUuid = instanceManager.getIdentifierForStrongReference(featureInfo);
+ featureInfoInstanceList.add(featureInfoUuid.toString());
+ }
+
+ return featureInfoInstanceList;
+ }
}
diff --git a/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/PermissionHandlerPigeon.java b/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/PermissionHandlerPigeon.java
index 0c55b447f..912cd9a53 100644
--- a/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/PermissionHandlerPigeon.java
+++ b/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/PermissionHandlerPigeon.java
@@ -509,7 +509,7 @@ public interface ContextHostApi {
*
* See https://developer.android.com/reference/android/content/Context#getSystemService(java.lang.String).
*/
- @NonNull
+ @Nullable
String getSystemService(@NonNull String instanceId, @NonNull String name);
/**
* Returns the instance ID of a PackageManager instance to find global package information.
@@ -518,6 +518,13 @@ public interface ContextHostApi {
*/
@NonNull
String getPackageManager(@NonNull String instanceId);
+ /**
+ * Return a ContentResolver instance for your application's package.
+ *
+ * See https://developer.android.com/reference/android/content/Context#getContentResolver().
+ */
+ @NonNull
+ String getContentResolver(@NonNull String instanceId);
/** The codec used by ContextHostApi. */
static @NonNull MessageCodec getCodec() {
@@ -638,6 +645,30 @@ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable ContextHos
String output = api.getPackageManager(instanceIdArg);
wrapped.add(0, output);
}
+ catch (Throwable exception) {
+ ArrayList wrappedError = wrapError(exception);
+ wrapped = wrappedError;
+ }
+ reply.reply(wrapped);
+ });
+ } else {
+ channel.setMessageHandler(null);
+ }
+ }
+ {
+ BasicMessageChannel channel =
+ new BasicMessageChannel<>(
+ binaryMessenger, "dev.flutter.pigeon.permission_handler_android.ContextHostApi.getContentResolver", getCodec());
+ if (api != null) {
+ channel.setMessageHandler(
+ (message, reply) -> {
+ ArrayList wrapped = new ArrayList();
+ ArrayList args = (ArrayList) message;
+ String instanceIdArg = (String) args.get(0);
+ try {
+ String output = api.getContentResolver(instanceIdArg);
+ wrapped.add(0, output);
+ }
catch (Throwable exception) {
ArrayList wrappedError = wrapError(exception);
wrapped = wrappedError;
@@ -1326,6 +1357,13 @@ public interface PackageManagerHostApi {
*/
@NonNull
List queryIntentActivitiesWithInfoFlags(@NonNull String instanceId, @NonNull String intentInstanceId, @NonNull String flagsInstanceId);
+ /**
+ * Get a list of features that are available on the system.
+ *
+ * See https://developer.android.com/reference/android/content/pm/PackageManager#getSystemAvailableFeatures().
+ */
+ @NonNull
+ List getSystemAvailableFeatures(@NonNull String instanceId);
/** The codec used by PackageManagerHostApi. */
static @NonNull MessageCodec getCodec() {
@@ -1476,6 +1514,30 @@ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable PackageMan
List output = api.queryIntentActivitiesWithInfoFlags(instanceIdArg, intentInstanceIdArg, flagsInstanceIdArg);
wrapped.add(0, output);
}
+ catch (Throwable exception) {
+ ArrayList wrappedError = wrapError(exception);
+ wrapped = wrappedError;
+ }
+ reply.reply(wrapped);
+ });
+ } else {
+ channel.setMessageHandler(null);
+ }
+ }
+ {
+ BasicMessageChannel channel =
+ new BasicMessageChannel<>(
+ binaryMessenger, "dev.flutter.pigeon.permission_handler_android.PackageManagerHostApi.getSystemAvailableFeatures", getCodec());
+ if (api != null) {
+ channel.setMessageHandler(
+ (message, reply) -> {
+ ArrayList wrapped = new ArrayList();
+ ArrayList args = (ArrayList) message;
+ String instanceIdArg = (String) args.get(0);
+ try {
+ List output = api.getSystemAvailableFeatures(instanceIdArg);
+ wrapped.add(0, output);
+ }
catch (Throwable exception) {
ArrayList wrappedError = wrapError(exception);
wrapped = wrappedError;
@@ -2306,4 +2368,683 @@ public void dispose(@NonNull String instanceIdArg, @NonNull Reply callback
channelReply -> callback.reply(null));
}
}
+ /**
+ * Flutter API for `FeatureInfo`.
+ *
+ * This class may handle instantiating and adding Dart instances that are
+ * attached to a native instance or receiving callback methods from an
+ * overridden native class.
+ *
+ * See https://developer.android.com/reference/android/content/pm/FeatureInfo.
+ *
+ * Generated class from Pigeon that represents Flutter messages that can be called from Java.
+ */
+ public static class FeatureInfoFlutterApi {
+ private final @NonNull BinaryMessenger binaryMessenger;
+
+ public FeatureInfoFlutterApi(@NonNull BinaryMessenger argBinaryMessenger) {
+ this.binaryMessenger = argBinaryMessenger;
+ }
+
+ /** Public interface for sending reply. */
+ @SuppressWarnings("UnknownNullness")
+ public interface Reply {
+ void reply(T reply);
+ }
+ /** The codec used by FeatureInfoFlutterApi. */
+ static @NonNull MessageCodec getCodec() {
+ return new StandardMessageCodec();
+ }
+ /** Create a new Dart instance and add it to the `InstanceManager`. */
+ public void create(@NonNull String instanceIdArg, @NonNull Reply callback) {
+ BasicMessageChannel channel =
+ new BasicMessageChannel<>(
+ binaryMessenger, "dev.flutter.pigeon.permission_handler_android.FeatureInfoFlutterApi.create", getCodec());
+ channel.send(
+ new ArrayList(Collections.singletonList(instanceIdArg)),
+ channelReply -> callback.reply(null));
+ }
+ /** Dispose of the Dart instance and remove it from the `InstanceManager`. */
+ public void dispose(@NonNull String instanceIdArg, @NonNull Reply callback) {
+ BasicMessageChannel channel =
+ new BasicMessageChannel<>(
+ binaryMessenger, "dev.flutter.pigeon.permission_handler_android.FeatureInfoFlutterApi.dispose", getCodec());
+ channel.send(
+ new ArrayList(Collections.singletonList(instanceIdArg)),
+ channelReply -> callback.reply(null));
+ }
+ }
+ /**
+ * Host API for `TelephonyManager`.
+ *
+ * This class may handle instantiating and adding native object instances that
+ * are attached to a Dart instance or handle method calls on the associated
+ * native class or an instance of the class.
+ *
+ * See https://developer.android.com/reference/android/telephony/TelephonyManager.
+ *
+ * Generated interface from Pigeon that represents a handler of messages from Flutter.
+ */
+ public interface TelephonyManagerHostApi {
+ /**
+ * Returns a constant indicating the device phone type. This indicates the type of radio used to transmit voice calls.
+ *
+ * Requires the [PackageManager.featureTelephony] feature which can be
+ * detected using [PackageManager.hasSystemFeature].
+ *
+ * See https://developer.android.com/reference/android/telephony/TelephonyManager#getPhoneType().
+ */
+ @NonNull
+ Long getPhoneType(@NonNull String instanceId);
+ /**
+ * Returns a constant indicating the state of the default SIM card.
+ *
+ * Requires the [PackageManager.featureTelephonySubscription] feature which
+ * can be detected using [PackageManager.hasSystemFeature].
+ *
+ * See https://developer.android.com/reference/android/telephony/TelephonyManager#getSimState(int).
+ */
+ @NonNull
+ Long getSimState(@NonNull String instanceId);
+
+ /** The codec used by TelephonyManagerHostApi. */
+ static @NonNull MessageCodec getCodec() {
+ return new StandardMessageCodec();
+ }
+ /**Sets up an instance of `TelephonyManagerHostApi` to handle messages through the `binaryMessenger`. */
+ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable TelephonyManagerHostApi api) {
+ {
+ BasicMessageChannel channel =
+ new BasicMessageChannel<>(
+ binaryMessenger, "dev.flutter.pigeon.permission_handler_android.TelephonyManagerHostApi.getPhoneType", getCodec());
+ if (api != null) {
+ channel.setMessageHandler(
+ (message, reply) -> {
+ ArrayList wrapped = new ArrayList();
+ ArrayList args = (ArrayList) message;
+ String instanceIdArg = (String) args.get(0);
+ try {
+ Long output = api.getPhoneType(instanceIdArg);
+ wrapped.add(0, output);
+ }
+ catch (Throwable exception) {
+ ArrayList wrappedError = wrapError(exception);
+ wrapped = wrappedError;
+ }
+ reply.reply(wrapped);
+ });
+ } else {
+ channel.setMessageHandler(null);
+ }
+ }
+ {
+ BasicMessageChannel channel =
+ new BasicMessageChannel<>(
+ binaryMessenger, "dev.flutter.pigeon.permission_handler_android.TelephonyManagerHostApi.getSimState", getCodec());
+ if (api != null) {
+ channel.setMessageHandler(
+ (message, reply) -> {
+ ArrayList wrapped = new ArrayList();
+ ArrayList args = (ArrayList) message;
+ String instanceIdArg = (String) args.get(0);
+ try {
+ Long output = api.getSimState(instanceIdArg);
+ wrapped.add(0, output);
+ }
+ catch (Throwable exception) {
+ ArrayList wrappedError = wrapError(exception);
+ wrapped = wrappedError;
+ }
+ reply.reply(wrapped);
+ });
+ } else {
+ channel.setMessageHandler(null);
+ }
+ }
+ }
+ }
+ /**
+ * Flutter API for `TelephonyManager`.
+ *
+ * This class may handle instantiating and adding Dart instances that are
+ * attached to a native instance or receiving callback methods from an
+ * overridden native class.
+ *
+ * See https://developer.android.com/reference/android/telephony/TelephonyManager.
+ *
+ * Generated class from Pigeon that represents Flutter messages that can be called from Java.
+ */
+ public static class TelephonyManagerFlutterApi {
+ private final @NonNull BinaryMessenger binaryMessenger;
+
+ public TelephonyManagerFlutterApi(@NonNull BinaryMessenger argBinaryMessenger) {
+ this.binaryMessenger = argBinaryMessenger;
+ }
+
+ /** Public interface for sending reply. */
+ @SuppressWarnings("UnknownNullness")
+ public interface Reply {
+ void reply(T reply);
+ }
+ /** The codec used by TelephonyManagerFlutterApi. */
+ static @NonNull MessageCodec getCodec() {
+ return new StandardMessageCodec();
+ }
+ /** Create a new Dart instance and add it to the `InstanceManager`. */
+ public void create(@NonNull String instanceIdArg, @NonNull Reply callback) {
+ BasicMessageChannel channel =
+ new BasicMessageChannel<>(
+ binaryMessenger, "dev.flutter.pigeon.permission_handler_android.TelephonyManagerFlutterApi.create", getCodec());
+ channel.send(
+ new ArrayList(Collections.singletonList(instanceIdArg)),
+ channelReply -> callback.reply(null));
+ }
+ /** Dispose of the Dart instance and remove it from the `InstanceManager`. */
+ public void dispose(@NonNull String instanceIdArg, @NonNull Reply callback) {
+ BasicMessageChannel channel =
+ new BasicMessageChannel<>(
+ binaryMessenger, "dev.flutter.pigeon.permission_handler_android.TelephonyManagerFlutterApi.dispose", getCodec());
+ channel.send(
+ new ArrayList(Collections.singletonList(instanceIdArg)),
+ channelReply -> callback.reply(null));
+ }
+ }
+ /**
+ * Host API for `LocationManager`.
+ *
+ * This class may handle instantiating and adding native object instances that
+ * are attached to a Dart instance or handle method calls on the associated
+ * native class or an instance of the class.
+ *
+ * See https://developer.android.com/reference/android/location/LocationManager.
+ *
+ * Generated interface from Pigeon that represents a handler of messages from Flutter.
+ */
+ public interface LocationManagerHostApi {
+ /**
+ * Returns the current enabled/disabled status of location updates.
+ *
+ * See https://developer.android.com/reference/android/location/LocationManager#isLocationEnabled().
+ */
+ @NonNull
+ Boolean isLocationEnabled(@NonNull String instanceId);
+
+ /** The codec used by LocationManagerHostApi. */
+ static @NonNull MessageCodec getCodec() {
+ return new StandardMessageCodec();
+ }
+ /**Sets up an instance of `LocationManagerHostApi` to handle messages through the `binaryMessenger`. */
+ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable LocationManagerHostApi api) {
+ {
+ BasicMessageChannel channel =
+ new BasicMessageChannel<>(
+ binaryMessenger, "dev.flutter.pigeon.permission_handler_android.LocationManagerHostApi.isLocationEnabled", getCodec());
+ if (api != null) {
+ channel.setMessageHandler(
+ (message, reply) -> {
+ ArrayList wrapped = new ArrayList();
+ ArrayList args = (ArrayList) message;
+ String instanceIdArg = (String) args.get(0);
+ try {
+ Boolean output = api.isLocationEnabled(instanceIdArg);
+ wrapped.add(0, output);
+ }
+ catch (Throwable exception) {
+ ArrayList wrappedError = wrapError(exception);
+ wrapped = wrappedError;
+ }
+ reply.reply(wrapped);
+ });
+ } else {
+ channel.setMessageHandler(null);
+ }
+ }
+ }
+ }
+ /**
+ * Flutter API for `LocationManager`.
+ *
+ * This class may handle instantiating and adding Dart instances that are
+ * attached to a native instance or receiving callback methods from an
+ * overridden native class.
+ *
+ * See https://developer.android.com/reference/android/location/LocationManager.
+ *
+ * Generated class from Pigeon that represents Flutter messages that can be called from Java.
+ */
+ public static class LocationManagerFlutterApi {
+ private final @NonNull BinaryMessenger binaryMessenger;
+
+ public LocationManagerFlutterApi(@NonNull BinaryMessenger argBinaryMessenger) {
+ this.binaryMessenger = argBinaryMessenger;
+ }
+
+ /** Public interface for sending reply. */
+ @SuppressWarnings("UnknownNullness")
+ public interface Reply {
+ void reply(T reply);
+ }
+ /** The codec used by LocationManagerFlutterApi. */
+ static @NonNull MessageCodec getCodec() {
+ return new StandardMessageCodec();
+ }
+ /** Create a new Dart instance and add it to the `InstanceManager`. */
+ public void create(@NonNull String instanceIdArg, @NonNull Reply callback) {
+ BasicMessageChannel channel =
+ new BasicMessageChannel<>(
+ binaryMessenger, "dev.flutter.pigeon.permission_handler_android.LocationManagerFlutterApi.create", getCodec());
+ channel.send(
+ new ArrayList(Collections.singletonList(instanceIdArg)),
+ channelReply -> callback.reply(null));
+ }
+ /** Dispose of the Dart instance and remove it from the `InstanceManager`. */
+ public void dispose(@NonNull String instanceIdArg, @NonNull Reply callback) {
+ BasicMessageChannel channel =
+ new BasicMessageChannel<>(
+ binaryMessenger, "dev.flutter.pigeon.permission_handler_android.LocationManagerFlutterApi.dispose", getCodec());
+ channel.send(
+ new ArrayList(Collections.singletonList(instanceIdArg)),
+ channelReply -> callback.reply(null));
+ }
+ }
+ /**
+ * Host API for `BluetoothAdapter`.
+ *
+ * This class may handle instantiating and adding native object instances that
+ * are attached to a Dart instance or handle method calls on the associated
+ * native class or an instance of the class.
+ *
+ * See https://developer.android.com/reference/android/bluetooth/BluetoothAdapter.
+ *
+ * Generated interface from Pigeon that represents a handler of messages from Flutter.
+ */
+ public interface BluetoothAdapterHostApi {
+ /**
+ * Get a handle to the default local Bluetooth adapter.
+ *
+ * Currently Android only supports one Bluetooth adapter, but the API could
+ * be extended to support more. This will always return the default adapter.
+ *
+ * See https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#getDefaultAdapter().
+ */
+ @NonNull
+ String getDefaultAdapter();
+ /**
+ * Return true if Bluetooth is currently enabled and ready for use.
+ *
+ * Equivalent to: getBluetoothState() == STATE_ON.
+ *
+ * For apps targeting [Build.versionCodes.r] or lower, this requires the
+ * [Manifest.permission.bluetooth] permission which can be gained with a
+ * simple manifest tag.
+ *
+ * See https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#isEnabled().
+ */
+ @NonNull
+ Boolean isEnabled(@NonNull String instanceId);
+
+ /** The codec used by BluetoothAdapterHostApi. */
+ static @NonNull MessageCodec getCodec() {
+ return new StandardMessageCodec();
+ }
+ /**Sets up an instance of `BluetoothAdapterHostApi` to handle messages through the `binaryMessenger`. */
+ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable BluetoothAdapterHostApi api) {
+ {
+ BasicMessageChannel channel =
+ new BasicMessageChannel<>(
+ binaryMessenger, "dev.flutter.pigeon.permission_handler_android.BluetoothAdapterHostApi.getDefaultAdapter", getCodec());
+ if (api != null) {
+ channel.setMessageHandler(
+ (message, reply) -> {
+ ArrayList wrapped = new ArrayList();
+ try {
+ String output = api.getDefaultAdapter();
+ wrapped.add(0, output);
+ }
+ catch (Throwable exception) {
+ ArrayList wrappedError = wrapError(exception);
+ wrapped = wrappedError;
+ }
+ reply.reply(wrapped);
+ });
+ } else {
+ channel.setMessageHandler(null);
+ }
+ }
+ {
+ BasicMessageChannel channel =
+ new BasicMessageChannel<>(
+ binaryMessenger, "dev.flutter.pigeon.permission_handler_android.BluetoothAdapterHostApi.isEnabled", getCodec());
+ if (api != null) {
+ channel.setMessageHandler(
+ (message, reply) -> {
+ ArrayList wrapped = new ArrayList();
+ ArrayList args = (ArrayList) message;
+ String instanceIdArg = (String) args.get(0);
+ try {
+ Boolean output = api.isEnabled(instanceIdArg);
+ wrapped.add(0, output);
+ }
+ catch (Throwable exception) {
+ ArrayList wrappedError = wrapError(exception);
+ wrapped = wrappedError;
+ }
+ reply.reply(wrapped);
+ });
+ } else {
+ channel.setMessageHandler(null);
+ }
+ }
+ }
+ }
+ /**
+ * Flutter API for `BluetoothAdapter`.
+ *
+ * This class may handle instantiating and adding Dart instances that are
+ * attached to a native instance or receiving callback methods from an
+ * overridden native class.
+ *
+ * See https://developer.android.com/reference/android/bluetooth/BluetoothAdapter.
+ *
+ * Generated class from Pigeon that represents Flutter messages that can be called from Java.
+ */
+ public static class BluetoothAdapterFlutterApi {
+ private final @NonNull BinaryMessenger binaryMessenger;
+
+ public BluetoothAdapterFlutterApi(@NonNull BinaryMessenger argBinaryMessenger) {
+ this.binaryMessenger = argBinaryMessenger;
+ }
+
+ /** Public interface for sending reply. */
+ @SuppressWarnings("UnknownNullness")
+ public interface Reply {
+ void reply(T reply);
+ }
+ /** The codec used by BluetoothAdapterFlutterApi. */
+ static @NonNull MessageCodec getCodec() {
+ return new StandardMessageCodec();
+ }
+ /** Create a new Dart instance and add it to the `InstanceManager`. */
+ public void create(@NonNull String instanceIdArg, @NonNull Reply callback) {
+ BasicMessageChannel channel =
+ new BasicMessageChannel<>(
+ binaryMessenger, "dev.flutter.pigeon.permission_handler_android.BluetoothAdapterFlutterApi.create", getCodec());
+ channel.send(
+ new ArrayList(Collections.singletonList(instanceIdArg)),
+ channelReply -> callback.reply(null));
+ }
+ /** Dispose of the Dart instance and remove it from the `InstanceManager`. */
+ public void dispose(@NonNull String instanceIdArg, @NonNull Reply callback) {
+ BasicMessageChannel channel =
+ new BasicMessageChannel<>(
+ binaryMessenger, "dev.flutter.pigeon.permission_handler_android.BluetoothAdapterFlutterApi.dispose", getCodec());
+ channel.send(
+ new ArrayList(Collections.singletonList(instanceIdArg)),
+ channelReply -> callback.reply(null));
+ }
+ }
+ /**
+ * Host API for `BluetoothManager`.
+ *
+ * This class may handle instantiating and adding native object instances that
+ * are attached to a Dart instance or handle method calls on the associated
+ * native class or an instance of the class.
+ *
+ * See https://developer.android.com/reference/android/bluetooth/BluetoothManager.
+ *
+ * Generated interface from Pigeon that represents a handler of messages from Flutter.
+ */
+ public interface BluetoothManagerHostApi {
+ /**
+ * Get the BLUETOOTH Adapter for this device.
+ *
+ * See https://developer.android.com/reference/android/bluetooth/BluetoothManager#getAdapter().
+ */
+ @NonNull
+ String getAdapter(@NonNull String instanceId);
+
+ /** The codec used by BluetoothManagerHostApi. */
+ static @NonNull MessageCodec getCodec() {
+ return new StandardMessageCodec();
+ }
+ /**Sets up an instance of `BluetoothManagerHostApi` to handle messages through the `binaryMessenger`. */
+ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable BluetoothManagerHostApi api) {
+ {
+ BasicMessageChannel channel =
+ new BasicMessageChannel<>(
+ binaryMessenger, "dev.flutter.pigeon.permission_handler_android.BluetoothManagerHostApi.getAdapter", getCodec());
+ if (api != null) {
+ channel.setMessageHandler(
+ (message, reply) -> {
+ ArrayList wrapped = new ArrayList();
+ ArrayList args = (ArrayList) message;
+ String instanceIdArg = (String) args.get(0);
+ try {
+ String output = api.getAdapter(instanceIdArg);
+ wrapped.add(0, output);
+ }
+ catch (Throwable exception) {
+ ArrayList wrappedError = wrapError(exception);
+ wrapped = wrappedError;
+ }
+ reply.reply(wrapped);
+ });
+ } else {
+ channel.setMessageHandler(null);
+ }
+ }
+ }
+ }
+ /**
+ * Flutter API for `BluetoothManager`.
+ *
+ * This class may handle instantiating and adding Dart instances that are
+ * attached to a native instance or receiving callback methods from an
+ * overridden native class.
+ *
+ * See https://developer.android.com/reference/android/bluetooth/BluetoothManager.
+ *
+ * Generated class from Pigeon that represents Flutter messages that can be called from Java.
+ */
+ public static class BluetoothManagerFlutterApi {
+ private final @NonNull BinaryMessenger binaryMessenger;
+
+ public BluetoothManagerFlutterApi(@NonNull BinaryMessenger argBinaryMessenger) {
+ this.binaryMessenger = argBinaryMessenger;
+ }
+
+ /** Public interface for sending reply. */
+ @SuppressWarnings("UnknownNullness")
+ public interface Reply {
+ void reply(T reply);
+ }
+ /** The codec used by BluetoothManagerFlutterApi. */
+ static @NonNull MessageCodec getCodec() {
+ return new StandardMessageCodec();
+ }
+ /** Create a new Dart instance and add it to the `InstanceManager`. */
+ public void create(@NonNull String instanceIdArg, @NonNull Reply callback) {
+ BasicMessageChannel channel =
+ new BasicMessageChannel<>(
+ binaryMessenger, "dev.flutter.pigeon.permission_handler_android.BluetoothManagerFlutterApi.create", getCodec());
+ channel.send(
+ new ArrayList(Collections.singletonList(instanceIdArg)),
+ channelReply -> callback.reply(null));
+ }
+ /** Dispose of the Dart instance and remove it from the `InstanceManager`. */
+ public void dispose(@NonNull String instanceIdArg, @NonNull Reply callback) {
+ BasicMessageChannel channel =
+ new BasicMessageChannel<>(
+ binaryMessenger, "dev.flutter.pigeon.permission_handler_android.BluetoothManagerFlutterApi.dispose", getCodec());
+ channel.send(
+ new ArrayList(Collections.singletonList(instanceIdArg)),
+ channelReply -> callback.reply(null));
+ }
+ }
+ /**
+ * Flutter API for `ContentResolver`.
+ *
+ * This class may handle instantiating and adding Dart instances that are
+ * attached to a native instance or receiving callback methods from an
+ * overridden native class.
+ *
+ * See https://developer.android.com/reference/android/content/ContentResolver.
+ *
+ * Generated class from Pigeon that represents Flutter messages that can be called from Java.
+ */
+ public static class ContentResolverFlutterApi {
+ private final @NonNull BinaryMessenger binaryMessenger;
+
+ public ContentResolverFlutterApi(@NonNull BinaryMessenger argBinaryMessenger) {
+ this.binaryMessenger = argBinaryMessenger;
+ }
+
+ /** Public interface for sending reply. */
+ @SuppressWarnings("UnknownNullness")
+ public interface Reply {
+ void reply(T reply);
+ }
+ /** The codec used by ContentResolverFlutterApi. */
+ static @NonNull MessageCodec getCodec() {
+ return new StandardMessageCodec();
+ }
+ /** Create a new Dart instance and add it to the `InstanceManager`. */
+ public void create(@NonNull String instanceIdArg, @NonNull Reply callback) {
+ BasicMessageChannel channel =
+ new BasicMessageChannel<>(
+ binaryMessenger, "dev.flutter.pigeon.permission_handler_android.ContentResolverFlutterApi.create", getCodec());
+ channel.send(
+ new ArrayList(Collections.singletonList(instanceIdArg)),
+ channelReply -> callback.reply(null));
+ }
+ /** Dispose of the Dart instance and remove it from the `InstanceManager`. */
+ public void dispose(@NonNull String instanceIdArg, @NonNull Reply callback) {
+ BasicMessageChannel channel =
+ new BasicMessageChannel<>(
+ binaryMessenger, "dev.flutter.pigeon.permission_handler_android.ContentResolverFlutterApi.dispose", getCodec());
+ channel.send(
+ new ArrayList(Collections.singletonList(instanceIdArg)),
+ channelReply -> callback.reply(null));
+ }
+ }
+ /** Generated interface from Pigeon that represents a handler of messages from Flutter. */
+ public interface SettingsSecureHostApi {
+ /**
+ * Convenience function for retrieving a single secure settings value as an integer.
+ *
+ * Note that internally setting values are always stored as strings; this
+ * function converts the string to an integer for you.
+ *
+ * This version does not take a default value. If the setting has not been
+ * set, or the string value is not a number, it returns null.
+ *
+ * See https://developer.android.com/reference/android/provider/Settings.Secure#getInt(android.content.ContentResolver,%20java.lang.String).
+ */
+ @Nullable
+ Long getInt(@NonNull String contentResolverInstanceId, @NonNull String name);
+ /**
+ * Convenience function for retrieving a single secure settings value as an integer.
+ *
+ * Note that internally setting values are always stored as strings; this
+ * function converts the string to an integer for you.
+ *
+ * The default value will be returned if the setting is not defined or not an
+ * integer.
+ *
+ * See https://developer.android.com/reference/android/provider/Settings.Secure#getInt(android.content.ContentResolver,%20java.lang.String,%20int).
+ */
+ @NonNull
+ Long getIntWithDefault(@NonNull String contentResolverInstanceId, @NonNull String name, @NonNull Long defaultValue);
+ /**
+ * Look up a name in the database.
+ *
+ * See https://developer.android.com/reference/android/provider/Settings.Secure#getString(android.content.ContentResolver,%20java.lang.String).
+ */
+ @Nullable
+ String getString(@NonNull String contentResolverInstanceId, @NonNull String name);
+
+ /** The codec used by SettingsSecureHostApi. */
+ static @NonNull MessageCodec getCodec() {
+ return new StandardMessageCodec();
+ }
+ /**Sets up an instance of `SettingsSecureHostApi` to handle messages through the `binaryMessenger`. */
+ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable SettingsSecureHostApi api) {
+ {
+ BasicMessageChannel channel =
+ new BasicMessageChannel<>(
+ binaryMessenger, "dev.flutter.pigeon.permission_handler_android.SettingsSecureHostApi.getInt", getCodec());
+ if (api != null) {
+ channel.setMessageHandler(
+ (message, reply) -> {
+ ArrayList wrapped = new ArrayList();
+ ArrayList args = (ArrayList) message;
+ String contentResolverInstanceIdArg = (String) args.get(0);
+ String nameArg = (String) args.get(1);
+ try {
+ Long output = api.getInt(contentResolverInstanceIdArg, nameArg);
+ wrapped.add(0, output);
+ }
+ catch (Throwable exception) {
+ ArrayList wrappedError = wrapError(exception);
+ wrapped = wrappedError;
+ }
+ reply.reply(wrapped);
+ });
+ } else {
+ channel.setMessageHandler(null);
+ }
+ }
+ {
+ BasicMessageChannel channel =
+ new BasicMessageChannel<>(
+ binaryMessenger, "dev.flutter.pigeon.permission_handler_android.SettingsSecureHostApi.getIntWithDefault", getCodec());
+ if (api != null) {
+ channel.setMessageHandler(
+ (message, reply) -> {
+ ArrayList wrapped = new ArrayList();
+ ArrayList args = (ArrayList) message;
+ String contentResolverInstanceIdArg = (String) args.get(0);
+ String nameArg = (String) args.get(1);
+ Number defaultValueArg = (Number) args.get(2);
+ try {
+ Long output = api.getIntWithDefault(contentResolverInstanceIdArg, nameArg, (defaultValueArg == null) ? null : defaultValueArg.longValue());
+ wrapped.add(0, output);
+ }
+ catch (Throwable exception) {
+ ArrayList wrappedError = wrapError(exception);
+ wrapped = wrappedError;
+ }
+ reply.reply(wrapped);
+ });
+ } else {
+ channel.setMessageHandler(null);
+ }
+ }
+ {
+ BasicMessageChannel channel =
+ new BasicMessageChannel<>(
+ binaryMessenger, "dev.flutter.pigeon.permission_handler_android.SettingsSecureHostApi.getString", getCodec());
+ if (api != null) {
+ channel.setMessageHandler(
+ (message, reply) -> {
+ ArrayList wrapped = new ArrayList();
+ ArrayList args = (ArrayList) message;
+ String contentResolverInstanceIdArg = (String) args.get(0);
+ String nameArg = (String) args.get(1);
+ try {
+ String output = api.getString(contentResolverInstanceIdArg, nameArg);
+ wrapped.add(0, output);
+ }
+ catch (Throwable exception) {
+ ArrayList wrappedError = wrapError(exception);
+ wrapped = wrappedError;
+ }
+ reply.reply(wrapped);
+ });
+ } else {
+ channel.setMessageHandler(null);
+ }
+ }
+ }
+ }
}
diff --git a/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/PermissionHandlerPlugin.java b/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/PermissionHandlerPlugin.java
index 09568618f..658ac715c 100644
--- a/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/PermissionHandlerPlugin.java
+++ b/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/PermissionHandlerPlugin.java
@@ -13,9 +13,12 @@
import com.baseflow.permissionhandler.PermissionHandlerPigeon.ActivityHostApi;
import com.baseflow.permissionhandler.PermissionHandlerPigeon.AlarmManagerHostApi;
import com.baseflow.permissionhandler.PermissionHandlerPigeon.BuildVersionHostApi;
+import com.baseflow.permissionhandler.PermissionHandlerPigeon.BluetoothAdapterHostApi;
+import com.baseflow.permissionhandler.PermissionHandlerPigeon.BluetoothManagerHostApi;
import com.baseflow.permissionhandler.PermissionHandlerPigeon.ContextHostApi;
import com.baseflow.permissionhandler.PermissionHandlerPigeon.EnvironmentHostApi;
import com.baseflow.permissionhandler.PermissionHandlerPigeon.IntentHostApi;
+import com.baseflow.permissionhandler.PermissionHandlerPigeon.LocationManagerHostApi;
import com.baseflow.permissionhandler.PermissionHandlerPigeon.NotificationManagerHostApi;
import com.baseflow.permissionhandler.PermissionHandlerPigeon.PackageInfoFlagsHostApi;
import com.baseflow.permissionhandler.PermissionHandlerPigeon.PackageInfoHostApi;
@@ -25,6 +28,8 @@
import com.baseflow.permissionhandler.PermissionHandlerPigeon.PackageManagerHostApi;
import com.baseflow.permissionhandler.PermissionHandlerPigeon.PowerManagerHostApi;
import com.baseflow.permissionhandler.PermissionHandlerPigeon.SettingsHostApi;
+import com.baseflow.permissionhandler.PermissionHandlerPigeon.SettingsSecureHostApi;
+import com.baseflow.permissionhandler.PermissionHandlerPigeon.TelephonyManagerHostApi;
import com.baseflow.permissionhandler.PermissionHandlerPigeon.UriHostApi;
import io.flutter.embedding.engine.plugins.FlutterPlugin;
@@ -99,13 +104,23 @@ private void setUp(
final PackageInfoHostApi packageInfoHostApi = new PackageInfoHostApiImpl(instanceManager);
PackageInfoHostApi.setup(binaryMessenger, packageInfoHostApi);
+ final FeatureInfoFlutterApiImpl featureInfoFlutterApi = new FeatureInfoFlutterApiImpl(binaryMessenger, instanceManager);
+
final PackageManagerFlutterApiImpl packageManagerFlutterApi = new PackageManagerFlutterApiImpl(binaryMessenger, instanceManager);
- final PackageManagerHostApi packageManagerHostApi = new PackageManagerHostApiImpl(packageInfoFlutterApi, resolveInfoFlutterApi, instanceManager);
+ final PackageManagerHostApi packageManagerHostApi = new PackageManagerHostApiImpl(
+ packageInfoFlutterApi,
+ resolveInfoFlutterApi,
+ featureInfoFlutterApi,
+ instanceManager
+ );
PackageManagerHostApi.setup(binaryMessenger, packageManagerHostApi);
final SettingsHostApi settingsHostApi = new SettingsHostApiImpl(instanceManager);
SettingsHostApi.setup(binaryMessenger, settingsHostApi);
+ final SettingsSecureHostApiImpl settingsSecureHostApi = new SettingsSecureHostApiImpl(instanceManager);
+ SettingsSecureHostApi.setup(binaryMessenger, settingsSecureHostApi);
+
final NotificationManagerFlutterApiImpl notificationManagerFlutterApi = new NotificationManagerFlutterApiImpl(binaryMessenger, instanceManager);
final NotificationManagerHostApi notificationManagerHostApi = new NotificationManagerHostApiImpl(instanceManager);
NotificationManagerHostApi.setup(binaryMessenger, notificationManagerHostApi);
@@ -113,6 +128,24 @@ private void setUp(
final EnvironmentHostApi environmentHostApi = new EnvironmentHostApiImpl(instanceManager);
EnvironmentHostApi.setup(binaryMessenger, environmentHostApi);
+ final TelephonyManagerFlutterApiImpl telephonyManagerFlutterApi = new TelephonyManagerFlutterApiImpl(binaryMessenger, instanceManager);
+ final TelephonyManagerHostApi telephonyManagerHostApi = new TelephonyManagerHostApiImpl(instanceManager);
+ TelephonyManagerHostApi.setup(binaryMessenger, telephonyManagerHostApi);
+
+ final LocationManagerFlutterApiImpl locationManagerFlutterApi = new LocationManagerFlutterApiImpl(binaryMessenger, instanceManager);
+ final LocationManagerHostApi locationManagerHostApi = new LocationManagerHostApiImpl(instanceManager);
+ LocationManagerHostApi.setup(binaryMessenger, locationManagerHostApi);
+
+ final BluetoothAdapterFlutterApiImpl bluetoothAdapterFlutterApi = new BluetoothAdapterFlutterApiImpl(binaryMessenger, instanceManager);
+ final BluetoothAdapterHostApi bluetoothAdapterHostApi = new BluetoothAdapterHostApiImpl(bluetoothAdapterFlutterApi, instanceManager);
+ BluetoothAdapterHostApi.setup(binaryMessenger, bluetoothAdapterHostApi);
+
+ final BluetoothManagerFlutterApiImpl bluetoothManagerFlutterApi = new BluetoothManagerFlutterApiImpl(binaryMessenger, instanceManager);
+ final BluetoothManagerHostApi bluetoothManagerHostApi = new BluetoothManagerHostApiImpl(bluetoothAdapterFlutterApi, instanceManager);
+ BluetoothManagerHostApi.setup(binaryMessenger, bluetoothManagerHostApi);
+
+ final ContentResolverFlutterApiImpl contentResolverFlutterApi = new ContentResolverFlutterApiImpl(binaryMessenger, instanceManager);
+
activityFlutterApi = new ActivityFlutterApiImpl(binaryMessenger, instanceManager);
activityHostApi = new ActivityHostApiImpl(instanceManager);
ActivityHostApi.setup(binaryMessenger, activityHostApi);
@@ -123,6 +156,10 @@ private void setUp(
alarmManagerFlutterApi,
packageManagerFlutterApi,
notificationManagerFlutterApi,
+ telephonyManagerFlutterApi,
+ locationManagerFlutterApi,
+ bluetoothManagerFlutterApi,
+ contentResolverFlutterApi,
instanceManager
);
ContextHostApi.setup(binaryMessenger, contextHostApi);
diff --git a/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/SettingsSecureHostApiImpl.java b/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/SettingsSecureHostApiImpl.java
new file mode 100644
index 000000000..6e7a89084
--- /dev/null
+++ b/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/SettingsSecureHostApiImpl.java
@@ -0,0 +1,63 @@
+package com.baseflow.permissionhandler;
+
+import android.content.ContentResolver;
+import android.provider.Settings;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
+import com.baseflow.instancemanager.InstanceManager;
+import com.baseflow.permissionhandler.PermissionHandlerPigeon.SettingsSecureHostApi;
+
+import java.util.UUID;
+
+/**
+ * Host API implementation for `Settings.Secure`.
+ *
+ * This class may handle instantiating and adding native object instances that are attached to a
+ * Dart instance or handle method calls on the associated native class or an instance of the class.
+ */
+public class SettingsSecureHostApiImpl implements SettingsSecureHostApi {
+ private final InstanceManager instanceManager;
+
+ /**
+ * Constructs an {@link SettingsSecureHostApiImpl}.
+ *
+ * @param instanceManager maintains instances stored to communicate with attached Dart objects
+ */
+ public SettingsSecureHostApiImpl(
+ @NonNull InstanceManager instanceManager
+ ) {
+ this.instanceManager = instanceManager;
+ }
+
+ @Override
+ public Long getInt(@NonNull String contentResolverInstanceId, @NonNull String name) {
+ final UUID contentResolverUuid = UUID.fromString(contentResolverInstanceId);
+ final ContentResolver contentResolver = instanceManager.getInstance(contentResolverUuid);
+
+ try {
+ return (long) Settings.Secure.getInt(contentResolver, name);
+ } catch (Settings.SettingNotFoundException e) {
+ return null;
+ }
+ }
+
+ @NonNull
+ @Override
+ public Long getIntWithDefault(@NonNull String contentResolverInstanceId, @NonNull String name, @NonNull Long defaultValue) {
+ final UUID contentResolverUuid = UUID.fromString(contentResolverInstanceId);
+ final ContentResolver contentResolver = instanceManager.getInstance(contentResolverUuid);
+
+ return (long) Settings.Secure.getInt(contentResolver, name, defaultValue.intValue());
+ }
+
+ @Nullable
+ @Override
+ public String getString(@NonNull String contentResolverInstanceId, @NonNull String name) {
+ final UUID contentResolverUuid = UUID.fromString(contentResolverInstanceId);
+ final ContentResolver contentResolver = instanceManager.getInstance(contentResolverUuid);
+
+ return Settings.Secure.getString(contentResolver, name);
+ }
+}
diff --git a/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/TelephonyManagerFlutterApiImpl.java b/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/TelephonyManagerFlutterApiImpl.java
new file mode 100644
index 000000000..236a583b5
--- /dev/null
+++ b/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/TelephonyManagerFlutterApiImpl.java
@@ -0,0 +1,61 @@
+package com.baseflow.permissionhandler;
+
+import android.telephony.TelephonyManager;
+
+import androidx.annotation.NonNull;
+
+import com.baseflow.instancemanager.InstanceManager;
+import com.baseflow.permissionhandler.PermissionHandlerPigeon.TelephonyManagerFlutterApi;
+
+import java.util.UUID;
+
+import io.flutter.plugin.common.BinaryMessenger;
+
+/**
+ * Flutter API implementation for `TelephonyManager`.
+ *
+ *
This class may handle adding native instances that are attached to a Dart instance or passing
+ * arguments of callbacks methods to a Dart instance.
+ */
+public class TelephonyManagerFlutterApiImpl {
+ private final InstanceManager instanceManager;
+
+ private final TelephonyManagerFlutterApi api;
+
+ /**
+ * Constructs a {@link TelephonyManagerFlutterApiImpl}.
+ *
+ * @param binaryMessenger used to communicate with Dart over asynchronous messages
+ * @param instanceManager maintains instances stored to communicate with attached Dart objects
+ */
+ public TelephonyManagerFlutterApiImpl(
+ @NonNull BinaryMessenger binaryMessenger,
+ @NonNull InstanceManager instanceManager
+ ) {
+ this.instanceManager = instanceManager;
+ api = new TelephonyManagerFlutterApi(binaryMessenger);
+ }
+
+ /**
+ * Stores the `TelephonyManager` instance and notifies Dart to create and store a new
+ * `TelephonyManager` instance that is attached to this one. If `instance` has already been
+ * added, this method does nothing.
+ */
+ public void create(@NonNull TelephonyManager instance) {
+ if (!instanceManager.containsInstance(instance)) {
+ final UUID telephonyManagerInstanceUuid = instanceManager.addHostCreatedInstance(instance);
+ api.create(telephonyManagerInstanceUuid.toString(), reply -> {});
+ }
+ }
+
+ /**
+ * Disposes of the `TelephonyManager` instance in the instance manager and notifies Dart to do
+ * the same. If `instance` was already disposed, this method does nothing.
+ */
+ public void dispose(TelephonyManager instance) {
+ final UUID telephonyManagerInstanceUuid = instanceManager.getIdentifierForStrongReference(instance);
+ if (telephonyManagerInstanceUuid != null) {
+ api.dispose(telephonyManagerInstanceUuid.toString(), reply -> {});
+ }
+ }
+}
diff --git a/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/TelephonyManagerHostApiImpl.java b/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/TelephonyManagerHostApiImpl.java
new file mode 100644
index 000000000..c76025818
--- /dev/null
+++ b/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/TelephonyManagerHostApiImpl.java
@@ -0,0 +1,47 @@
+package com.baseflow.permissionhandler;
+
+import android.telephony.TelephonyManager;
+
+import androidx.annotation.NonNull;
+
+import com.baseflow.instancemanager.InstanceManager;
+import com.baseflow.permissionhandler.PermissionHandlerPigeon.TelephonyManagerHostApi;
+
+import java.util.UUID;
+
+/**
+ * Host API implementation for `TelephonyManager`.
+ *
+ *
This class may handle instantiating and adding native object instances that are attached to a
+ * Dart instance or handle method calls on the associated native class or an instance of the class.
+ */
+public class TelephonyManagerHostApiImpl implements TelephonyManagerHostApi {
+ private final InstanceManager instanceManager;
+
+ /**
+ * Constructs an {@link TelephonyManagerHostApiImpl}.
+ *
+ * @param instanceManager maintains instances stored to communicate with attached Dart objects
+ */
+ public TelephonyManagerHostApiImpl(
+ @NonNull InstanceManager instanceManager
+ ) {
+ this.instanceManager = instanceManager;
+ }
+
+ @NonNull
+ @Override
+ public Long getPhoneType(@NonNull String instanceId) {
+ final UUID instanceUuid = UUID.fromString(instanceId);
+ final TelephonyManager telephonyManager = instanceManager.getInstance(instanceUuid);
+ return (long) telephonyManager.getPhoneType();
+ }
+
+ @NonNull
+ @Override
+ public Long getSimState(@NonNull String instanceId) {
+ final UUID instanceUuid = UUID.fromString(instanceId);
+ final TelephonyManager telephonyManager = instanceManager.getInstance(instanceUuid);
+ return (long) telephonyManager.getSimState();
+ }
+}
diff --git a/permission_handler_android/lib/permission_handler_android.dart b/permission_handler_android/lib/permission_handler_android.dart
index ec7f8f895..dcfcf84d1 100644
--- a/permission_handler_android/lib/permission_handler_android.dart
+++ b/permission_handler_android/lib/permission_handler_android.dart
@@ -1,9 +1,14 @@
export 'src/android_object_mirrors/activity.dart';
export 'src/android_object_mirrors/alarm_manager.dart';
+export 'src/android_object_mirrors/bluetooth_adapter.dart';
+export 'src/android_object_mirrors/bluetooth_manager.dart';
export 'src/android_object_mirrors/build.dart';
+export 'src/android_object_mirrors/content_resolver.dart';
export 'src/android_object_mirrors/context.dart';
export 'src/android_object_mirrors/environment.dart';
+export 'src/android_object_mirrors/feature_info.dart';
export 'src/android_object_mirrors/intent.dart';
+export 'src/android_object_mirrors/location_manager.dart';
export 'src/android_object_mirrors/manifest.dart';
export 'src/android_object_mirrors/notification_manager.dart';
export 'src/android_object_mirrors/package_info.dart';
@@ -11,6 +16,7 @@ export 'src/android_object_mirrors/package_manager.dart';
export 'src/android_object_mirrors/power_manager.dart';
export 'src/android_object_mirrors/resolve_info.dart';
export 'src/android_object_mirrors/settings.dart';
+export 'src/android_object_mirrors/telephony_manager.dart';
export 'src/android_object_mirrors/uri.dart';
export 'src/activity_aware.dart';
diff --git a/permission_handler_android/lib/src/android_object_mirrors/activity.dart b/permission_handler_android/lib/src/android_object_mirrors/activity.dart
index 3bc872729..dbf128a53 100644
--- a/permission_handler_android/lib/src/android_object_mirrors/activity.dart
+++ b/permission_handler_android/lib/src/android_object_mirrors/activity.dart
@@ -55,6 +55,33 @@ class Activity extends Context {
/// See https://developer.android.com/reference/android/content/Context.html#NOTIFICATION_SERVICE.
static const String notificationService = 'notification';
+ /// Use with [Context.getSystemService] to retrieve a [TelephonyManager] for
+ /// handling management the telephony features of the device.
+ ///
+ /// Copy of [Context.telephonyService], as static fields are not inherited in
+ /// Dart.
+ ///
+ /// See https://developer.android.com/reference/android/content/Context.html#TELEPHONY_SERVICE.
+ static const String telephonyService = 'phone';
+
+ /// Use with [Context.getSystemService] to retrieve a [LocationManager] for
+ /// controlling location updates.
+ ///
+ /// Copy of [Context.locationService], as static fields are not inherited in
+ /// Dart.
+ ///
+ /// See https://developer.android.com/reference/android/content/Context.html#LOCATION_SERVICE.
+ static const String locationService = 'location';
+
+ /// Use with [Context.getSystemService] to retrieve a [BluetoothManager] for
+ /// using Bluetooth.
+ ///
+ /// Copy of [Context.bluetoothService], as static fields are not inherited in
+ /// Dart.
+ ///
+ /// See https://developer.android.com/reference/android/content/Context.html#BLUETOOTH_SERVICE.
+ static const String bluetoothService = 'bluetooth';
+
/// Standard activity result: operation succeeded.
///
/// Constant Value: -1 (0xffffffff).
diff --git a/permission_handler_android/lib/src/android_object_mirrors/bluetooth_adapter.dart b/permission_handler_android/lib/src/android_object_mirrors/bluetooth_adapter.dart
new file mode 100644
index 000000000..960f5d358
--- /dev/null
+++ b/permission_handler_android/lib/src/android_object_mirrors/bluetooth_adapter.dart
@@ -0,0 +1,67 @@
+import 'package:flutter/services.dart';
+import 'package:flutter_instance_manager/flutter_instance_manager.dart';
+import 'package:permission_handler_android/src/android_permission_handler_api_impls.dart';
+
+/// Represents the local device Bluetooth adapter.
+///
+/// The BluetoothAdapter lets you perform fundamental Bluetooth tasks, such as
+/// initiate device discovery, query a list of bonded (paired) devices,
+/// instantiate a BluetoothDevice using a known MAC address, and create a
+/// BluetoothServerSocket to listen for connection requests from other devices,
+/// and start a scan for Bluetooth LE devices.
+///
+/// To get a BluetoothAdapter representing the local Bluetooth adapter, call the
+/// [BluetoothManager.getAdapter] function on BluetoothManager. On
+/// JELLY_BEAN_MR1 and below you will need to use the static
+/// [BluetoothManager.getDefaultAdapter] method instead.
+///
+/// Fundamentally, this is your starting point for all Bluetooth actions. Once
+/// you have the local adapter, you can get a set of BluetoothDevice objects
+/// representing all paired devices with getBondedDevices(); start device
+/// discovery with startDiscovery(); or create a BluetoothServerSocket to listen
+/// for incoming RFComm connection requests with
+/// listenUsingRfcommWithServiceRecord(java.lang.String, java.util.UUID); listen
+/// for incoming L2CAP Connection-oriented Channels (CoC) connection requests
+/// with listenUsingL2capChannel(); or start a scan for Bluetooth LE devices
+/// with startLeScan(android.bluetooth.BluetoothAdapter.LeScanCallback).
+///
+/// This class is thread safe.
+///
+/// See https://developer.android.com/reference/android/bluetooth/BluetoothAdapter.
+class BluetoothAdapter extends JavaObject {
+ /// Instantiates a [BluetoothAdapter] without creating and attaching to an
+ /// instance of the associated native class.
+ BluetoothAdapter.detached({
+ BinaryMessenger? binaryMessenger,
+ InstanceManager? instanceManager,
+ }) : super.detached(
+ binaryMessenger: binaryMessenger,
+ instanceManager: instanceManager,
+ );
+
+ static final BluetoothAdapterHostApiImpl _hostApi =
+ BluetoothAdapterHostApiImpl();
+
+ /// Get a handle to the default local Bluetooth adapter.
+ ///
+ /// Currently Android only supports one Bluetooth adapter, but the API could
+ /// be extended to support more. This will always return the default adapter.
+ ///
+ /// See https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#getDefaultAdapter().
+ static Future getDefaultAdapter() {
+ return _hostApi.getDefaultAdapterFromClass();
+ }
+
+ /// Return true if Bluetooth is currently enabled and ready for use.
+ ///
+ /// Equivalent to: getBluetoothState() == STATE_ON.
+ ///
+ /// For apps targeting [Build.versionCodes.r] or lower, this requires the
+ /// [Manifest.permission.bluetooth] permission which can be gained with a
+ /// simple manifest tag.
+ ///
+ /// See https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#isEnabled().
+ Future isEnabled() {
+ return _hostApi.isEnabledFromInstance(this);
+ }
+}
diff --git a/permission_handler_android/lib/src/android_object_mirrors/bluetooth_manager.dart b/permission_handler_android/lib/src/android_object_mirrors/bluetooth_manager.dart
new file mode 100644
index 000000000..ad3dd1845
--- /dev/null
+++ b/permission_handler_android/lib/src/android_object_mirrors/bluetooth_manager.dart
@@ -0,0 +1,33 @@
+import 'package:flutter/services.dart';
+import 'package:flutter_instance_manager/flutter_instance_manager.dart';
+import 'package:permission_handler_android/src/android_permission_handler_api_impls.dart';
+
+import 'bluetooth_adapter.dart';
+
+/// High level manager used to obtain an instance of a [BluetoothAdapter] and to conduct overall Bluetooth Management.
+///
+/// Use [Context.getSystemService] with [Context.bluetoothService] to create a
+/// BluetoothManager, then call [getAdapter] to obtain the BluetoothAdapter.
+///
+/// See https://developer.android.com/reference/android/bluetooth/BluetoothManager.
+class BluetoothManager extends JavaObject {
+ /// Instantiates a [BluetoothManager] without creating and attaching to an
+ /// instance of the associated native class.
+ BluetoothManager.detached({
+ BinaryMessenger? binaryMessenger,
+ InstanceManager? instanceManager,
+ }) : super.detached(
+ binaryMessenger: binaryMessenger,
+ instanceManager: instanceManager,
+ );
+
+ static final BluetoothManagerHostApiImpl _hostApi =
+ BluetoothManagerHostApiImpl();
+
+ /// Get the BLUETOOTH Adapter for this device.
+ ///
+ /// See https://developer.android.com/reference/android/bluetooth/BluetoothManager#getAdapter().
+ Future getAdapter() async {
+ return _hostApi.getAdapterFromInstance(this);
+ }
+}
diff --git a/permission_handler_android/lib/src/android_object_mirrors/content_resolver.dart b/permission_handler_android/lib/src/android_object_mirrors/content_resolver.dart
new file mode 100644
index 000000000..e4ee1b9fb
--- /dev/null
+++ b/permission_handler_android/lib/src/android_object_mirrors/content_resolver.dart
@@ -0,0 +1,17 @@
+import 'package:flutter/services.dart';
+import 'package:flutter_instance_manager/flutter_instance_manager.dart';
+
+/// This class provides applications access to the content model.
+///
+/// See https://developer.android.com/reference/android/content/ContentResolver.
+class ContentResolver extends JavaObject {
+ /// Instantiates an [ContentResolver] without creating and attaching to an
+ /// instance of the associated native class.
+ ContentResolver.detached({
+ BinaryMessenger? binaryMessenger,
+ InstanceManager? instanceManager,
+ }) : super.detached(
+ binaryMessenger: binaryMessenger,
+ instanceManager: instanceManager,
+ );
+}
diff --git a/permission_handler_android/lib/src/android_object_mirrors/context.dart b/permission_handler_android/lib/src/android_object_mirrors/context.dart
index f1f8d5a8e..633845917 100644
--- a/permission_handler_android/lib/src/android_object_mirrors/context.dart
+++ b/permission_handler_android/lib/src/android_object_mirrors/context.dart
@@ -48,6 +48,24 @@ class Context extends JavaObject {
/// See https://developer.android.com/reference/android/content/Context.html#NOTIFICATION_SERVICE.
static const String notificationService = 'notification';
+ /// Use with [Context.getSystemService] to retrieve a [TelephonyManager] for
+ /// handling management the telephony features of the device.
+ ///
+ /// See https://developer.android.com/reference/android/content/Context.html#TELEPHONY_SERVICE.
+ static const String telephonyService = 'phone';
+
+ /// Use with [Context.getSystemService] to retrieve a [LocationManager] for
+ /// controlling location updates.
+ ///
+ /// See https://developer.android.com/reference/android/content/Context.html#LOCATION_SERVICE.
+ static const String locationService = 'location';
+
+ /// Use with [Context.getSystemService] to retrieve a [BluetoothManager] for
+ /// using Bluetooth.
+ ///
+ /// See https://developer.android.com/reference/android/content/Context.html#BLUETOOTH_SERVICE.
+ static const String bluetoothService = 'bluetooth';
+
/// Determines whether the application has been granted a particular permission.
///
/// See https://developer.android.com/reference/android/content/Context#checkSelfPermission(java.lang.String).
@@ -103,4 +121,13 @@ class Context extends JavaObject {
this,
);
}
+
+ /// Returns a ContentResolver instance for your application's package.
+ ///
+ /// See https://developer.android.com/reference/android/content/Context#getContentResolver().
+ Future getContentResolver() {
+ return _hostApi.getContentResolverFromInstance(
+ this,
+ );
+ }
}
diff --git a/permission_handler_android/lib/src/android_object_mirrors/feature_info.dart b/permission_handler_android/lib/src/android_object_mirrors/feature_info.dart
new file mode 100644
index 000000000..2ccde93ea
--- /dev/null
+++ b/permission_handler_android/lib/src/android_object_mirrors/feature_info.dart
@@ -0,0 +1,27 @@
+import 'package:flutter/services.dart';
+import 'package:flutter_instance_manager/flutter_instance_manager.dart';
+
+/// Definition of a single optional hardware or software feature of an Android device.
+///
+/// This object is used to represent both features supported by a device and
+/// features requested by an app. Apps can request that certain features be
+/// available as a prerequisite to being installed through the uses-feature tag
+/// in their manifests.
+///
+/// Starting in [Build.versionCodes.n], features can have a version, which must
+/// always be backwards compatible. That is, a device claiming to support
+/// version 3 of a specific feature must support apps requesting version 1 of
+/// that feature.
+///
+/// See https://developer.android.com/reference/android/content/pm/FeatureInfo.
+class FeatureInfo extends JavaObject {
+ /// Instantiates a [FeatureInfo] without creating and attaching to an instance
+ /// of the associated native class.
+ FeatureInfo.detached({
+ InstanceManager? instanceManager,
+ BinaryMessenger? binaryMessenger,
+ }) : super.detached(
+ instanceManager: instanceManager,
+ binaryMessenger: binaryMessenger,
+ );
+}
diff --git a/permission_handler_android/lib/src/android_object_mirrors/location_manager.dart b/permission_handler_android/lib/src/android_object_mirrors/location_manager.dart
new file mode 100644
index 000000000..f5fd9001f
--- /dev/null
+++ b/permission_handler_android/lib/src/android_object_mirrors/location_manager.dart
@@ -0,0 +1,35 @@
+import 'package:flutter/services.dart';
+import 'package:flutter_instance_manager/flutter_instance_manager.dart';
+import 'package:permission_handler_android/src/android_permission_handler_api_impls.dart';
+
+/// Provides access to the system location services.
+///
+/// These services allow applications to obtain periodic updates of the device's
+/// geographical location, or to be notified when the device enters the
+/// proximity of a given geographical location.
+///
+/// See https://developer.android.com/reference/android/location/LocationManager.
+class LocationManager extends JavaObject {
+ /// Instantiates a [LocationManager] without creating and attaching to an
+ /// instance of the associated native class.
+ LocationManager.detached({
+ BinaryMessenger? binaryMessenger,
+ InstanceManager? instanceManager,
+ }) : _hostApi = LocationManagerHostApiImpl(
+ binaryMessenger: binaryMessenger,
+ instanceManager: instanceManager,
+ ),
+ super.detached(
+ binaryMessenger: binaryMessenger,
+ instanceManager: instanceManager,
+ );
+
+ final LocationManagerHostApiImpl _hostApi;
+
+ /// Returns the current enabled/disabled state of location.
+ ///
+ /// See https://developer.android.com/reference/android/location/LocationManager#isLocationEnabled().
+ Future isLocationEnabled() async {
+ return await _hostApi.isLocationEnabledFromInstance(this);
+ }
+}
diff --git a/permission_handler_android/lib/src/android_object_mirrors/package_manager.dart b/permission_handler_android/lib/src/android_object_mirrors/package_manager.dart
index 0ced16191..1f8351935 100644
--- a/permission_handler_android/lib/src/android_object_mirrors/package_manager.dart
+++ b/permission_handler_android/lib/src/android_object_mirrors/package_manager.dart
@@ -3,6 +3,7 @@ import 'package:flutter_instance_manager/flutter_instance_manager.dart';
import 'package:permission_handler_android/src/android_object_mirrors/package_info.dart';
import '../android_permission_handler_api_impls.dart';
+import 'feature_info.dart';
import 'intent.dart';
import 'resolve_info.dart';
@@ -38,6 +39,27 @@ class PackageManager extends JavaObject {
/// Constant Value: 0 (0x00000000)
static const int permissionGranted = 0;
+ /// The device has a telephony radio with data communication support.
+ ///
+ /// Feature for [getSystemAvailableFeatures] and [hasSystemFeature].
+ ///
+ /// Constant Value: "android.hardware.telephony".
+ ///
+ /// See https://developer.android.com/reference/android/content/pm/PackageManager#FEATURE_TELEPHONY.
+ static const String featureTelephony = 'android.hardware.telephony';
+
+ /// The device supports Telephony APIs for the subscription.
+ ///
+ /// Feature for [getSystemAvailableFeatures] and [hasSystemFeature].
+ ///
+ /// This feature should only be defined if [featureTelephony] has been defined.
+ ///
+ /// Constant Value: "android.hardware.telephony.subscription".
+ ///
+ /// See https://developer.android.com/reference/android/content/pm/PackageManager#FEATURE_TELEPHONY_SUBSCRIPTION.
+ static const String featureTelephonySubscription =
+ 'android.hardware.telephony.subscription';
+
/// Checks whether the calling package is allowed to request package installs through package installer.
///
/// See https://developer.android.com/reference/android/content/pm/PackageManager#canRequestPackageInstalls().
@@ -73,6 +95,13 @@ class PackageManager extends JavaObject {
);
}
+ /// Check whether the given feature name is one of the available features as returned by getSystemAvailableFeatures().
+ ///
+ /// See https://developer.android.com/reference/android/content/pm/PackageManager#hasSystemFeature(java.lang.String).
+ Future hasSystemFeature(String name) {
+ return _hostApi.hasSystemFeatureFromInstance(this, name);
+ }
+
/// Retrieve all activities that can be performed for the given intent.
///
/// See https://developer.android.com/reference/android/content/pm/PackageManager#queryIntentActivities(android.content.Intent,%20int).
@@ -100,6 +129,13 @@ class PackageManager extends JavaObject {
resolveInfoFlags,
);
}
+
+ /// Get a list of features that are available on the system.
+ ///
+ /// See https://developer.android.com/reference/android/content/pm/PackageManager#getSystemAvailableFeatures().
+ Future> getSystemAvailableFeatures() {
+ return _hostApi.getSystemAvailableFeaturesFromInstance(this);
+ }
}
/// Specific flags used for retrieving package info.
diff --git a/permission_handler_android/lib/src/android_object_mirrors/power_manager.dart b/permission_handler_android/lib/src/android_object_mirrors/power_manager.dart
index 33a7cb0cf..11d9204e4 100644
--- a/permission_handler_android/lib/src/android_object_mirrors/power_manager.dart
+++ b/permission_handler_android/lib/src/android_object_mirrors/power_manager.dart
@@ -4,7 +4,7 @@ import 'package:permission_handler_android/src/android_permission_handler_api_im
/// This class lets you query and request control of aspects of the device's power state.
///
-/// See: https://developer.android.com/reference/android/os/PowerManager
+/// See: https://developer.android.com/reference/android/os/PowerManager.
class PowerManager extends JavaObject {
/// Instantiates a [PowerManager] without creating and attaching to an
/// instance of the associated native class.
diff --git a/permission_handler_android/lib/src/android_object_mirrors/settings.dart b/permission_handler_android/lib/src/android_object_mirrors/settings.dart
index b47cf168e..020b196f3 100644
--- a/permission_handler_android/lib/src/android_object_mirrors/settings.dart
+++ b/permission_handler_android/lib/src/android_object_mirrors/settings.dart
@@ -1,5 +1,6 @@
import '../android_permission_handler_api_impls.dart';
import 'build.dart';
+import 'content_resolver.dart';
import 'context.dart';
/// The Settings provider contains global system-level device preferences.
@@ -10,12 +11,39 @@ class Settings {
static final SettingsHostApiImpl _hostApi = SettingsHostApiImpl();
+ /// Secure system settings, containing system preferences that applications
+ static _Secure get secure => _Secure();
+
/// Activity Action: Show screen of details about a particular application.
///
/// Constant Value: "android.settings.APPLICATION_DETAILS_SETTINGS".
+ ///
+ /// See https://developer.android.com/reference/android/provider/Settings#ACTION_APPLICATION_DETAILS_SETTINGS.
static const String actionApplicationDetailsSettings =
'android.settings.APPLICATION_DETAILS_SETTINGS';
+ /// Activity Action: Show settings to allow configuration of Bluetooth.
+ ///
+ /// In some cases, a matching Activity may not exist, so ensure you safeguard
+ /// against this.
+ ///
+ /// Constant Value: "android.settings.BLUETOOTH_SETTINGS".
+ ///
+ /// See https://developer.android.com/reference/android/provider/Settings#ACTION_BLUETOOTH_SETTINGS.
+ static const String actionBluetoothSettings =
+ 'android.settings.BLUETOOTH_SETTINGS';
+
+ /// Activity Action: Show settings to allow configuration of current location sources.
+ ///
+ /// In some cases, a matching Activity may not exist, so ensure you safeguard
+ /// against this.
+ ///
+ /// Constant Value: "android.settings.LOCATION_SOURCE_SETTINGS".
+ ///
+ /// See https://developer.android.com/reference/android/provider/Settings#ACTION_LOCATION_SOURCE_SETTINGS.
+ static const String actionLocationSourceSettings =
+ 'android.settings.LOCATION_SOURCE_SETTINGS';
+
/// Activity Action: Ask the user to allow an app to ignore battery optimizations.
///
/// Note: most applications should not use this; there are many facilities
@@ -34,6 +62,8 @@ class Settings {
/// You can use [PowerManager#isIgnoringBatteryOptimizations] to determine if
/// an application is already ignoring optimizations.
///
+ /// Constant Value: "android.settings.IGNORE_BATTERY_OPTIMIZATIONS".
+ ///
/// See https://developer.android.com/reference/android/provider/Settings#ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS.
static const String actionRequestIgnoreBatteryOptimizations =
'android.settings.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS';
@@ -44,12 +74,16 @@ class Settings {
/// whose ability of managing external storage you want to control. For
/// example "package:com.my.app".
///
+ /// Constant Value: "android.settings.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION".
+ ///
/// See https://developer.android.com/reference/android/provider/Settings#ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION.
static const String actionManagerAppAllFilesAccessPermission =
'android.settings.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION';
/// Activity Action: Show screen for controlling which apps can draw on top of other apps.
///
+ /// Constant Value: "android.settings.action.MANAGE_OVERLAY_PERMISSION".
+ ///
/// See https://developer.android.com/reference/android/provider/Settings#ACTION_MANAGE_OVERLAY_PERMISSION.
static const String actionManageOverlayPermission =
'android.settings.action.MANAGE_OVERLAY_PERMISSION';
@@ -60,6 +94,8 @@ class Settings {
/// package name to directly invoke the management GUI specific to the package
/// name. For example "package:com.my.app".
///
+ /// Constant Value: "android.settings.MANAGE_UNKNOWN_APP_SOURCES".
+ ///
/// See https://developer.android.com/reference/android/provider/Settings#ACTION_MANAGE_UNKNOWN_APP_SOURCES.
static const String actionManageUnknownAppSources =
'android.settings.MANAGE_UNKNOWN_APP_SOURCES';
@@ -69,6 +105,8 @@ class Settings {
/// Users can grant and deny access to Do Not Disturb configuration from here.
/// Managed profiles cannot grant Do Not Disturb access.
///
+ /// Constant Value: "android.settings.NOTIFICATION_POLICY_ACCESS_SETTINGS".
+ ///
/// See https://developer.android.com/reference/android/provider/Settings#ACTION_NOTIFICATION_POLICY_ACCESS_SETTINGS.
static const String actionNotificationPolicyAccessSettings =
'android.settings.NOTIFICATION_POLICY_ACCESS_SETTINGS';
@@ -83,10 +121,23 @@ class Settings {
/// set to [Activity#RESULT_OK] if the permission was granted to the app.
/// Otherwise, the result is set to [Activity#RESULT_CANCELED].
///
- /// See https://developer.android.com/reference/android/provider/Settings#ACTION_MANAGE_OVERLAY_PERMISSION.
+ /// Constant Value: "android.settings.REQUEST_SCHEDULE_EXACT_ALARM".
+ ///
+ /// See https://developer.android.com/reference/android/provider/Settings#ACTION_REQUEST_SCHEDULE_EXACT_ALARM.
static const String actionRequestScheduleExactAlarm =
'android.settings.REQUEST_SCHEDULE_EXACT_ALARM';
+ /// Activity Action: Show settings to allow configuration of wireless controls such as Wi-Fi, Bluetooth and Mobile networks.
+ ///
+ /// In some cases, a matching Activity may not exist, so ensure you safeguard
+ /// against this.
+ ///
+ /// Constant Value: "android.settings.WIRELESS_SETTINGS".
+ ///
+ /// See https://developer.android.com/reference/android/provider/Settings#ACTION_WIRELESS_SETTINGS.
+ static const String actionWirelessSettings =
+ 'android.settings.WIRELESS_SETTINGS';
+
/// Checks if the specified context can draw on top of other apps.
///
/// As of API level 23, an app cannot draw on top of other apps unless it
@@ -108,3 +159,117 @@ class Settings {
);
}
}
+
+/// Secure system settings, containing system preferences that applications
+/// can read but are not allowed to write. These are for preferences that the
+/// user must explicitly modify through the system UI or specialized APIs for
+/// those values, not modified directly by applications.
+///
+/// See https://developer.android.com/reference/android/provider/Settings.Secure.
+class _Secure {
+ static final SettingsSecureHostApiImpl _hostApi = SettingsSecureHostApiImpl();
+
+ /// The current location mode of the device.
+ ///
+ /// Do not rely on this value being present or on ContentObserver
+ /// notifications on the corresponding Uri.
+ ///
+ /// Constant Value: "location_mode".
+ ///
+ /// See https://developer.android.com/reference/android/provider/Settings.Secure#LOCATION_MODE.
+ String get locationMode => 'location_mode';
+
+ /// This mode no longer has any distinct meaning, but is interpreted as the location mode is on.
+ ///
+ /// Constant Value: 2 (0x00000002).
+ ///
+ /// See https://developer.android.com/reference/android/provider/Settings.Secure#LOCATION_MODE_BATTERY_SAVING.
+ int get locationModeBatterySaving => 2;
+
+ /// This mode no longer has any distinct meaning, but is interpreted as the location mode is on.
+ ///
+ /// Constant Value: 3 (0x00000003).
+ ///
+ /// See https://developer.android.com/reference/android/provider/Settings.Secure#LOCATION_MODE_HIGH_ACCURACY.
+ int get locationModeHighAccuracy => 3;
+
+ /// Location mode is off.
+ ///
+ /// Constant Value: 0 (0x00000000).
+ ///
+ /// See https://developer.android.com/reference/android/provider/Settings.Secure#LOCATION_MODE_OFF.
+ int get locationModeOff => 0;
+
+ /// This mode no longer has any distinct meaning, but is interpreted as the location mode is on.
+ ///
+ /// Constant Value: 1 (0x00000001).
+ ///
+ /// See https://developer.android.com/reference/android/provider/Settings.Secure#LOCATION_MODE_SENSORS_ONLY.
+ int get locationModeSensorsOnly => 1;
+
+ /// Comma-separated list of location providers that are enabled.
+ ///
+ /// **NOTE:** This constant was deprecated in API level 19.
+ /// This setting no longer exists from Android S onwards as it no longer is
+ /// capable of realistically reflecting location settings. Use
+ /// [LocationManager.isProviderEnabled] or
+ /// [LocationManager.isLocationEnabled] instead.
+ ///
+ /// Do not rely on this value being present or correct, or on ContentObserver
+ /// notifications on the corresponding Uri.
+ ///
+ /// Constant Value: "location_providers_allowed".
+ ///
+ /// See https://developer.android.com/reference/android/provider/Settings.Secure#LOCATION_PROVIDERS_ALLOWED.
+ String get locationProvidersAllowed => 'location_providers_allowed';
+
+ /// Convenience function for retrieving a single secure settings value as an integer.
+ ///
+ /// Note that internally setting values are always stored as strings; this
+ /// function converts the string to an integer for you.
+ ///
+ /// This version does not take a default value. If the setting has not been
+ /// set, or the string value is not a number, it returns null.
+ ///
+ /// See https://developer.android.com/reference/android/provider/Settings.Secure#getInt(android.content.ContentResolver,%20java.lang.String).
+ Future getInt(
+ ContentResolver contentResolver,
+ String name,
+ ) {
+ return _hostApi.getIntFromClass(contentResolver, name);
+ }
+
+ /// Convenience function for retrieving a single secure settings value as an integer.
+ ///
+ /// Note that internally setting values are always stored as strings; this
+ /// function converts the string to an integer for you.
+ ///
+ /// The default value will be returned if the setting is not defined or not an
+ /// integer.
+ ///
+ /// See https://developer.android.com/reference/android/provider/Settings.Secure#getInt(android.content.ContentResolver,%20java.lang.String,%20int).
+ Future getIntWithDefault(
+ ContentResolver contentResolver,
+ String name,
+ int defaultValue,
+ ) async {
+ return _hostApi.getIntWithDefaultFromClass(
+ contentResolver,
+ name,
+ defaultValue,
+ );
+ }
+
+ /// Look up a name in the database.
+ ///
+ /// See https://developer.android.com/reference/android/provider/Settings.Secure#getString(android.content.ContentResolver,%20java.lang.String).
+ Future getString(
+ ContentResolver contentResolver,
+ String name,
+ ) async {
+ return _hostApi.getStringFromClass(
+ contentResolver,
+ name,
+ );
+ }
+}
diff --git a/permission_handler_android/lib/src/android_object_mirrors/telephony_manager.dart b/permission_handler_android/lib/src/android_object_mirrors/telephony_manager.dart
new file mode 100644
index 000000000..d2f3d8221
--- /dev/null
+++ b/permission_handler_android/lib/src/android_object_mirrors/telephony_manager.dart
@@ -0,0 +1,152 @@
+import 'package:flutter/services.dart';
+import 'package:flutter_instance_manager/flutter_instance_manager.dart';
+import 'package:permission_handler_android/src/android_permission_handler_api_impls.dart';
+
+/// Provides access to information about the telephony services on the device.
+///
+/// Applications can use the methods in this class to determine telephony
+/// services and states, as well as to access some types of subscriber
+/// information. Applications can also register a listener to receive
+/// notification of telephony state changes.
+///
+/// TelephonyManager is intended for use on devices that implement
+/// [PackageManage.featureTelephony]. On devices that do not implement this
+/// feature, the behavior is not reliable.
+///
+/// Requires the [PackageManager.featureTelephony] feature which can be detected
+/// using [PackageManager.hasSystemFeature].
+class TelephonyManager extends JavaObject {
+ /// Instantiates a [TelephonyManager] without creating and attaching to an
+ /// instance of the associated native class.
+ TelephonyManager.detached({
+ BinaryMessenger? binaryMessenger,
+ InstanceManager? instanceManager,
+ }) : _hostApi = TelephonyManagerHostApiImpl(
+ binaryMessenger: binaryMessenger,
+ instanceManager: instanceManager,
+ ),
+ super.detached(
+ binaryMessenger: binaryMessenger,
+ instanceManager: instanceManager,
+ );
+
+ final TelephonyManagerHostApiImpl _hostApi;
+
+ /// Phone radio is CDMA.
+ ///
+ /// Constant Value: 2 (0x00000002).
+ ///
+ /// See https://developer.android.com/reference/android/telephony/TelephonyManager#PHONE_TYPE_CDMA.
+ static const int phoneTypeCdma = 2;
+
+ /// Phone radio is GSM.
+ ///
+ /// Constant Value: 1 (0x00000001).
+ ///
+ /// See https://developer.android.com/reference/android/telephony/TelephonyManager#PHONE_TYPE_GSM.
+ static const int phoneTypeGsm = 1;
+
+ /// No phone radio.
+ ///
+ /// Constant Value: 0 (0x00000000).
+ ///
+ /// See https://developer.android.com/reference/android/telephony/TelephonyManager#PHONE_TYPE_NONE.
+ static const int phoneTypeNone = 0;
+
+ /// Phone radio is SIP.
+ ///
+ /// Constant Value: 3 (0x00000003).
+ ///
+ /// See https://developer.android.com/reference/android/telephony/TelephonyManager#PHONE_TYPE_SIP.
+ static const int phoneTypeSip = 3;
+
+ /// SIM card state: no SIM card is available in the device.
+ ///
+ /// Constant Value: 1 (0x00000001).
+ ///
+ /// See https://developer.android.com/reference/android/telephony/TelephonyManager#SIM_STATE_ABSENT.
+ static const int simStateAbsent = 1;
+
+ /// SIM card state: SIM Card Error, present but faulty.
+ ///
+ /// Constant Value: 8 (0x00000008).
+ ///
+ /// See https://developer.android.com/reference/android/telephony/TelephonyManager#SIM_STATE_CARD_IO_ERROR.
+ static const int simStateCardIoError = 8;
+
+ /// SIM card state: SIM Card restricted, present but not usable due to carrier restrictions.
+ ///
+ /// Constant Value: 7 (0x00000007).
+ ///
+ /// See https://developer.android.com/reference/android/telephony/TelephonyManager#SIM_STATE_CARD_RESTRICTED.
+ static const int simStateCardRestricted = 7;
+
+ /// SIM card state: Locked: requires a network PIN to unlock.
+ ///
+ /// Constant Value: 4 (0x00000004).
+ ///
+ /// See https://developer.android.com/reference/android/telephony/TelephonyManager#SIM_STATE_NETWORK_LOCKED.
+ static const int simStateNetworkLocked = 4;
+
+ /// SIM card state: SIM Card is NOT READY.
+ ///
+ /// Constant Value: 6 (0x00000006).
+ ///
+ /// See https://developer.android.com/reference/android/telephony/TelephonyManager#SIM_STATE_NOT_READY.
+ static const int simStateNotReady = 6;
+
+ /// SIM card state: SIM Card Error, permanently disabled.
+ ///
+ /// Constant Value: 9 (0x00000009).
+ ///
+ /// See https://developer.android.com/reference/android/telephony/TelephonyManager#SIM_STATE_PERM_DISABLED.
+ static const int simStatePermDisabled = 9;
+
+ /// SIM card state: Locked: requires the user's SIM PIN to unlock.
+ ///
+ /// Constant Value: 2 (0x00000002).
+ ///
+ /// See https://developer.android.com/reference/android/telephony/TelephonyManager#SIM_STATE_PIN_REQUIRED.
+ static const int simStatePinRequired = 2;
+
+ /// SIM card state: Locked: requires the user's SIM PUK to unlock.
+ ///
+ /// Constant Value: 3 (0x00000003).
+ ///
+ /// See https://developer.android.com/reference/android/telephony/TelephonyManager#SIM_STATE_PUK_REQUIRED.
+ static const int simStatePukRequired = 3;
+
+ /// SIM card state: Ready.
+ ///
+ /// Constant Value: 5 (0x00000005).
+ ///
+ /// See https://developer.android.com/reference/android/telephony/TelephonyManager#SIM_STATE_READY.
+ static const int simStateReady = 5;
+
+ /// SIM card state: Unknown.
+ ///
+ /// Constant Value: 0 (0x00000000).
+ ///
+ /// See https://developer.android.com/reference/android/telephony/TelephonyManager#SIM_STATE_UNKNOWN.
+ static const int simStateUnknown = 0;
+
+ /// Returns a constant indicating the device phone type. This indicates the type of radio used to transmit voice calls.
+ ///
+ /// Requires the [PackageManager.featureTelephony] feature which can be
+ /// detected using [PackageManager.hasSystemFeature].
+ ///
+ /// See https://developer.android.com/reference/android/telephony/TelephonyManager#getPhoneType().
+ Future getPhoneType() {
+ return _hostApi.getPhoneTypeFromInstance(this);
+ }
+
+ /// Returns a constant indicating the state of the default SIM card.
+ ///
+ /// Requires the [PackageManager.featureTelephonySubscription] feature which
+ /// can be detected using [PackageManager.hasSystemFeature].
+ ///
+ /// See https://developer.android.com/reference/android/telephony/TelephonyManager#getSimState(int).
+ Future getSimState() {
+ return _hostApi.getSimeStateFromInstance(this);
+ }
+}
diff --git a/permission_handler_android/lib/src/android_permission_handler_api_impls.dart b/permission_handler_android/lib/src/android_permission_handler_api_impls.dart
index df899aa59..ae51be70b 100644
--- a/permission_handler_android/lib/src/android_permission_handler_api_impls.dart
+++ b/permission_handler_android/lib/src/android_permission_handler_api_impls.dart
@@ -21,6 +21,12 @@ class AndroidPermissionHandlerFlutterApis {
ComponentInfoFlagsFlutterApiImpl? componentInfoFlagsFlutterApi,
ApplicationInfoFlagsFlutterApiImpl? applicationInfoFlagsFlutterApi,
NotificationManagerFlutterApiImpl? notificationManagerFlutterApi,
+ FeatureInfoFlutterApiImpl? featureInfoFlutterApi,
+ TelephonyManagerFlutterApiImpl? telephonyManagerFlutterApi,
+ LocationManagerFlutterApiImpl? locationManagerFlutterApi,
+ BluetoothAdapterFlutterApiImpl? bluetoothAdapterFlutterApi,
+ BluetoothManagerFlutterApiImpl? bluetoothManagerFlutterApi,
+ ContentResolverFlutterApiImpl? contentResolverFlutterApi,
}) {
this.activityFlutterApi = activityFlutterApi ?? ActivityFlutterApiImpl();
this.contextFlutterApi = contextFlutterApi ?? ContextFlutterApiImpl();
@@ -45,6 +51,18 @@ class AndroidPermissionHandlerFlutterApis {
applicationInfoFlagsFlutterApi ?? ApplicationInfoFlagsFlutterApiImpl();
this.notificationManagerFlutterApi =
notificationManagerFlutterApi ?? NotificationManagerFlutterApiImpl();
+ this.featureInfoFlutterApi =
+ featureInfoFlutterApi ?? FeatureInfoFlutterApiImpl();
+ this.telephonyManagerFlutterApi =
+ telephonyManagerFlutterApi ?? TelephonyManagerFlutterApiImpl();
+ this.locationManagerFlutterApi =
+ locationManagerFlutterApi ?? LocationManagerFlutterApiImpl();
+ this.bluetoothAdapterFlutterApi =
+ bluetoothAdapterFlutterApi ?? BluetoothAdapterFlutterApiImpl();
+ this.bluetoothManagerFlutterApi =
+ bluetoothManagerFlutterApi ?? BluetoothManagerFlutterApiImpl();
+ this.contentResolverFlutterApi =
+ contentResolverFlutterApi ?? ContentResolverFlutterApiImpl();
}
static bool _haveBeenSetUp = false;
@@ -97,6 +115,24 @@ class AndroidPermissionHandlerFlutterApis {
/// Flutter API for [NotificationManager].
late final NotificationManagerFlutterApiImpl notificationManagerFlutterApi;
+ /// Flutter API for [FeatureInfo].
+ late final FeatureInfoFlutterApiImpl featureInfoFlutterApi;
+
+ /// Flutter API for [TelephonyManager].
+ late final TelephonyManagerFlutterApiImpl telephonyManagerFlutterApi;
+
+ /// Flutter API for [LocationManager].
+ late final LocationManagerFlutterApiImpl locationManagerFlutterApi;
+
+ /// Flutter API for [BluetoothAdapter].
+ late final BluetoothAdapterFlutterApiImpl bluetoothAdapterFlutterApi;
+
+ /// Flutter API for [BluetoothManager].
+ late final BluetoothManagerFlutterApiImpl bluetoothManagerFlutterApi;
+
+ /// Flutter API for [ContentResolver].
+ late final ContentResolverFlutterApiImpl contentResolverFlutterApi;
+
/// Ensures all the Flutter APIs have been setup to receive calls from native code.
void ensureSetUp() {
if (!_haveBeenSetUp) {
@@ -113,6 +149,12 @@ class AndroidPermissionHandlerFlutterApis {
ComponentInfoFlagsFlutterApi.setup(componentInfoFlagsFlutterApi);
ApplicationInfoFlagsFlutterApi.setup(applicationInfoFlagsFlutterApi);
NotificationManagerFlutterApi.setup(notificationManagerFlutterApi);
+ FeatureInfoFlutterApi.setup(featureInfoFlutterApi);
+ TelephonyManagerFlutterApi.setup(telephonyManagerFlutterApi);
+ LocationManagerFlutterApi.setup(locationManagerFlutterApi);
+ BluetoothAdapterFlutterApi.setup(bluetoothAdapterFlutterApi);
+ BluetoothManagerFlutterApi.setup(bluetoothManagerFlutterApi);
+ ContentResolverFlutterApi.setup(contentResolverFlutterApi);
_haveBeenSetUp = true;
}
@@ -298,11 +340,15 @@ class ContextHostApiImpl extends ContextHostApi {
Context context,
String name,
) async {
- final String systemServiceId = await getSystemService(
+ final String? systemServiceId = await getSystemService(
instanceManager.getIdentifier(context)!,
name,
);
+ if (systemServiceId == null) {
+ return null;
+ }
+
return instanceManager.getInstanceWithWeakReference(systemServiceId);
}
@@ -319,6 +365,20 @@ class ContextHostApiImpl extends ContextHostApi {
return instanceManager.getInstanceWithWeakReference(packageManagerId)
as PackageManager;
}
+
+ /// Return a ContentResolver instance for your application's package.
+ ///
+ /// See https://developer.android.com/reference/android/content/Context#getContentResolver().
+ Future getContentResolverFromInstance(
+ Context context,
+ ) async {
+ final String contentResolverId = await getContentResolver(
+ instanceManager.getIdentifier(context)!,
+ );
+
+ return instanceManager.getInstanceWithWeakReference(contentResolverId)
+ as ContentResolver;
+ }
}
/// Flutter API implementation of Context.
@@ -783,6 +843,21 @@ class PackageManagerHostApiImpl extends PackageManagerHostApi {
.getInstanceWithWeakReference(instanceId) as ResolveInfo)
.toList();
}
+
+ /// Get a list of features that are available on the system.
+ ///
+ /// See https://developer.android.com/reference/android/content/pm/PackageManager#getSystemAvailableFeatures().
+ Future> getSystemAvailableFeaturesFromInstance(
+ PackageManager packageManager,
+ ) async {
+ return (await getSystemAvailableFeatures(
+ instanceManager.getIdentifier(packageManager)!,
+ ))
+ .whereType()
+ .map((String instanceId) => instanceManager
+ .getInstanceWithWeakReference(instanceId) as FeatureInfo)
+ .toList();
+ }
}
/// Flutter API implementation of PackageManager.
@@ -1285,3 +1360,389 @@ class ResolveInfoFlutterApiImpl extends ResolveInfoFlutterApi {
_instanceManager.remove(instanceId);
}
}
+
+/// Flutter API implementation of FeatureInfo.
+class FeatureInfoFlutterApiImpl extends FeatureInfoFlutterApi {
+ /// Constructs a new instance of [FeatureInfoFlutterApiImpl].
+ FeatureInfoFlutterApiImpl({
+ InstanceManager? instanceManager,
+ }) : _instanceManager = instanceManager ?? JavaObject.globalInstanceManager;
+
+ /// Maintains instances stored to communicate with native language objects.
+ final InstanceManager _instanceManager;
+
+ @override
+ void create(String instanceId) {
+ final FeatureInfo featureInfo = FeatureInfo.detached();
+ _instanceManager.addHostCreatedInstance(
+ featureInfo,
+ instanceId,
+ );
+ }
+
+ @override
+ void dispose(String instanceId) {
+ _instanceManager.remove(instanceId);
+ }
+}
+
+/// Host API implementation of TelephonyManager.
+class TelephonyManagerHostApiImpl extends TelephonyManagerHostApi {
+ /// Creates a new instance of [TelephonyManagerHostApiImpl].
+ TelephonyManagerHostApiImpl({
+ this.binaryMessenger,
+ InstanceManager? instanceManager,
+ }) : instanceManager = instanceManager ?? JavaObject.globalInstanceManager,
+ super(
+ binaryMessenger: binaryMessenger,
+ );
+
+ /// Sends binary data across the Flutter platform barrier.
+ ///
+ /// If it is null, the default BinaryMessenger will be used which routes to the host platform.
+ final BinaryMessenger? binaryMessenger;
+
+ /// Maintains instances stored to communicate with native language objects.
+ final InstanceManager instanceManager;
+
+ /// Returns a constant indicating the device phone type. This indicates the type of radio used to transmit voice calls.
+ ///
+ /// Requires the [PackageManager.featureTelephony] feature which can be
+ /// detected using [PackageManager.hasSystemFeature].
+ ///
+ /// See https://developer.android.com/reference/android/telephony/TelephonyManager#getPhoneType().
+ Future getPhoneTypeFromInstance(
+ TelephonyManager telephonyManager,
+ ) {
+ return getPhoneType(
+ instanceManager.getIdentifier(telephonyManager)!,
+ );
+ }
+
+ /// Returns a constant indicating the state of the default SIM card.
+ ///
+ /// Requires the [PackageManager.featureTelephonySubscription] feature which
+ /// can be detected using [PackageManager.hasSystemFeature].
+ ///
+ /// See https://developer.android.com/reference/android/telephony/TelephonyManager#getSimState(int).
+ Future getSimeStateFromInstance(
+ TelephonyManager telephonyManager,
+ ) {
+ return getSimState(
+ instanceManager.getIdentifier(telephonyManager)!,
+ );
+ }
+}
+
+/// Flutter API implementation of TelephonyManager.
+class TelephonyManagerFlutterApiImpl extends TelephonyManagerFlutterApi {
+ /// Constructs a new instance of [TelephonyManagerFlutterApiImpl].
+ TelephonyManagerFlutterApiImpl({
+ InstanceManager? instanceManager,
+ }) : _instanceManager = instanceManager ?? JavaObject.globalInstanceManager;
+
+ /// Maintains instances stored to communicate with native language objects.
+ final InstanceManager _instanceManager;
+
+ @override
+ void create(String instanceId) {
+ final TelephonyManager telephonyManager = TelephonyManager.detached();
+ _instanceManager.addHostCreatedInstance(
+ telephonyManager,
+ instanceId,
+ );
+ }
+
+ @override
+ void dispose(String instanceId) {
+ _instanceManager.remove(instanceId);
+ }
+}
+
+/// Host API implementation of LocationManager.
+class LocationManagerHostApiImpl extends LocationManagerHostApi {
+ /// Creates a new instance of [LocationManagerHostApiImpl].
+ LocationManagerHostApiImpl({
+ this.binaryMessenger,
+ InstanceManager? instanceManager,
+ }) : instanceManager = instanceManager ?? JavaObject.globalInstanceManager,
+ super(
+ binaryMessenger: binaryMessenger,
+ );
+
+ /// Sends binary data across the Flutter platform barrier.
+ ///
+ /// If it is null, the default BinaryMessenger will be used which routes to the host platform.
+ final BinaryMessenger? binaryMessenger;
+
+ /// Maintains instances stored to communicate with native language objects.
+ final InstanceManager instanceManager;
+
+ /// Returns the current enabled/disabled status of location updates.
+ ///
+ /// See https://developer.android.com/reference/android/location/LocationManager#isLocationEnabled().
+ Future isLocationEnabledFromInstance(
+ LocationManager locationManager,
+ ) {
+ return isLocationEnabled(instanceManager.getIdentifier(locationManager)!);
+ }
+}
+
+/// Flutter API implementation of LocationManager.
+class LocationManagerFlutterApiImpl extends LocationManagerFlutterApi {
+ /// Constructs a new instance of [LocationManagerFlutterApiImpl].
+ LocationManagerFlutterApiImpl({
+ InstanceManager? instanceManager,
+ }) : _instanceManager = instanceManager ?? JavaObject.globalInstanceManager;
+
+ /// Maintains instances stored to communicate with native language objects.
+ final InstanceManager _instanceManager;
+
+ @override
+ void create(String instanceId) {
+ final LocationManager locationManager = LocationManager.detached();
+ _instanceManager.addHostCreatedInstance(
+ locationManager,
+ instanceId,
+ );
+ }
+
+ @override
+ void dispose(String instanceId) {
+ _instanceManager.remove(instanceId);
+ }
+}
+
+/// Host API implementation of BluetoothAdapter.
+class BluetoothAdapterHostApiImpl extends BluetoothAdapterHostApi {
+ /// Creates a new instance of [BluetoothAdapterHostApiImpl].
+ BluetoothAdapterHostApiImpl({
+ this.binaryMessenger,
+ InstanceManager? instanceManager,
+ }) : instanceManager = instanceManager ?? JavaObject.globalInstanceManager,
+ super(
+ binaryMessenger: binaryMessenger,
+ );
+
+ /// Sends binary data across the Flutter platform barrier.
+ ///
+ /// If it is null, the default BinaryMessenger will be used which routes to the host platform.
+ final BinaryMessenger? binaryMessenger;
+
+ /// Maintains instances stored to communicate with native language objects.
+ final InstanceManager instanceManager;
+
+ /// Get a handle to the default local Bluetooth adapter.
+ ///
+ /// Currently Android only supports one Bluetooth adapter, but the API could
+ /// be extended to support more. This will always return the default adapter.
+ ///
+ /// See https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#getDefaultAdapter().
+ Future getDefaultAdapterFromClass() async {
+ final String instanceId = await getDefaultAdapter();
+
+ return instanceManager.getInstanceWithWeakReference(instanceId)
+ as BluetoothAdapter;
+ }
+
+ /// Return true if Bluetooth is currently enabled and ready for use.
+ ///
+ /// Equivalent to: getBluetoothState() == STATE_ON.
+ ///
+ /// For apps targeting [Build.versionCodes.r] or lower, this requires the
+ /// [Manifest.permission.bluetooth] permission which can be gained with a
+ /// simple manifest tag.
+ ///
+ /// See https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#isEnabled().
+ Future isEnabledFromInstance(
+ BluetoothAdapter bluetoothAdapter,
+ ) {
+ return isEnabled(instanceManager.getIdentifier(bluetoothAdapter)!);
+ }
+}
+
+/// Flutter API implementation of BluetoothAdapter.
+class BluetoothAdapterFlutterApiImpl extends BluetoothAdapterFlutterApi {
+ /// Constructs a new instance of [BluetoothAdapterFlutterApiImpl].
+ BluetoothAdapterFlutterApiImpl({
+ InstanceManager? instanceManager,
+ }) : _instanceManager = instanceManager ?? JavaObject.globalInstanceManager;
+
+ /// Maintains instances stored to communicate with native language objects.
+ final InstanceManager _instanceManager;
+
+ @override
+ void create(String instanceId) {
+ final BluetoothAdapter bluetoothAdapter = BluetoothAdapter.detached();
+ _instanceManager.addHostCreatedInstance(
+ bluetoothAdapter,
+ instanceId,
+ );
+ }
+
+ @override
+ void dispose(String instanceId) {
+ _instanceManager.remove(instanceId);
+ }
+}
+
+/// Host API implementation of BluetoothManager.
+class BluetoothManagerHostApiImpl extends BluetoothManagerHostApi {
+ /// Creates a new instance of [BluetoothManagerHostApiImpl].
+ BluetoothManagerHostApiImpl({
+ this.binaryMessenger,
+ InstanceManager? instanceManager,
+ }) : instanceManager = instanceManager ?? JavaObject.globalInstanceManager,
+ super(
+ binaryMessenger: binaryMessenger,
+ );
+
+ /// Sends binary data across the Flutter platform barrier.
+ ///
+ /// If it is null, the default BinaryMessenger will be used which routes to the host platform.
+ final BinaryMessenger? binaryMessenger;
+
+ /// Maintains instances stored to communicate with native language objects.
+ final InstanceManager instanceManager;
+
+ /// Get the BLUETOOTH Adapter for this device.
+ ///
+ /// See https://developer.android.com/reference/android/bluetooth/BluetoothManager#getAdapter().
+ Future getAdapterFromInstance(
+ BluetoothManager bluetoothManager,
+ ) async {
+ final String adapterInstanceId =
+ await getAdapter(instanceManager.getIdentifier(bluetoothManager)!);
+
+ return instanceManager.getInstanceWithWeakReference(adapterInstanceId)
+ as BluetoothAdapter;
+ }
+}
+
+/// Flutter API implementation of BluetoothManager.
+class BluetoothManagerFlutterApiImpl extends BluetoothManagerFlutterApi {
+ /// Constructs a new instance of [BluetoothManagerFlutterApiImpl].
+ BluetoothManagerFlutterApiImpl({
+ InstanceManager? instanceManager,
+ }) : _instanceManager = instanceManager ?? JavaObject.globalInstanceManager;
+
+ /// Maintains instances stored to communicate with native language objects.
+ final InstanceManager _instanceManager;
+
+ @override
+ void create(String instanceId) {
+ final BluetoothManager bluetoothManager = BluetoothManager.detached();
+ _instanceManager.addHostCreatedInstance(
+ bluetoothManager,
+ instanceId,
+ );
+ }
+
+ @override
+ void dispose(String instanceId) {
+ _instanceManager.remove(instanceId);
+ }
+}
+
+/// Flutter API implementation of ContentResolver.
+class ContentResolverFlutterApiImpl extends ContentResolverFlutterApi {
+ /// Constructs a new instance of [ContentResolverFlutterApiImpl].
+ ContentResolverFlutterApiImpl({
+ InstanceManager? instanceManager,
+ }) : _instanceManager = instanceManager ?? JavaObject.globalInstanceManager;
+
+ /// Maintains instances stored to communicate with native language objects.
+ final InstanceManager _instanceManager;
+
+ @override
+ void create(String instanceId) {
+ final ContentResolver contentResolver = ContentResolver.detached();
+ _instanceManager.addHostCreatedInstance(
+ contentResolver,
+ instanceId,
+ );
+ }
+
+ @override
+ void dispose(String instanceId) {
+ _instanceManager.remove(instanceId);
+ }
+}
+
+/// Host API implementation of Settings.Secure.
+class SettingsSecureHostApiImpl extends SettingsSecureHostApi {
+ /// Creates a new instance of [SettingsSecureHostApiImpl].
+ SettingsSecureHostApiImpl({
+ this.binaryMessenger,
+ InstanceManager? instanceManager,
+ }) : instanceManager = instanceManager ?? JavaObject.globalInstanceManager,
+ super(
+ binaryMessenger: binaryMessenger,
+ );
+
+ /// Sends binary data across the Flutter platform barrier.
+ ///
+ /// If it is null, the default BinaryMessenger will be used which routes to the host platform.
+ final BinaryMessenger? binaryMessenger;
+
+ /// Maintains instances stored to communicate with native language objects.
+ final InstanceManager instanceManager;
+
+ /// Convenience function for retrieving a single secure settings value as an integer.
+ ///
+ /// Note that internally setting values are always stored as strings; this
+ /// function converts the string to an integer for you.
+ ///
+ /// This version does not take a default value. If the setting has not been
+ /// set, or the string value is not a number, it returns null.
+ ///
+ /// See https://developer.android.com/reference/android/provider/Settings.Secure#getInt(android.content.ContentResolver,%20java.lang.String).
+ Future getIntFromClass(
+ ContentResolver contentResolver,
+ String name,
+ ) {
+ return getInt(
+ instanceManager.getIdentifier(contentResolver)!,
+ name,
+ );
+ }
+
+ /// Convenience function for retrieving a single secure settings value as an integer.
+ ///
+ /// Note that internally setting values are always stored as strings; this
+ /// function converts the string to an integer for you.
+ ///
+ /// The default value will be returned if the setting is not defined or not an
+ /// integer.
+ ///
+ /// See https://developer.android.com/reference/android/provider/Settings.Secure#getInt(android.content.ContentResolver,%20java.lang.String,%20int).
+ Future getIntWithDefaultFromClass(
+ ContentResolver contentResolver,
+ String name,
+ int defaultValue,
+ ) {
+ assert(
+ defaultValue.bitLength + 1 <= 32,
+ 'The default value must fit in a 32-bit integer.',
+ );
+
+ return getIntWithDefault(
+ instanceManager.getIdentifier(contentResolver)!,
+ name,
+ defaultValue,
+ );
+ }
+
+ /// Look up a name in the database.
+ ///
+ /// See https://developer.android.com/reference/android/provider/Settings.Secure#getString(android.content.ContentResolver,%20java.lang.String).
+ Future getStringFromClass(
+ ContentResolver contentResolver,
+ String name,
+ ) {
+ return getString(
+ instanceManager.getIdentifier(contentResolver)!,
+ name,
+ );
+ }
+}
diff --git a/permission_handler_android/lib/src/permission_handler.pigeon.dart b/permission_handler_android/lib/src/permission_handler.pigeon.dart
index 6d01fb487..2ca1cbdeb 100644
--- a/permission_handler_android/lib/src/permission_handler.pigeon.dart
+++ b/permission_handler_android/lib/src/permission_handler.pigeon.dart
@@ -94,9 +94,9 @@ class _ActivityHostApiCodec extends StandardMessageCodec {
@override
Object? readValueOfType(int type, ReadBuffer buffer) {
switch (type) {
- case 128:
+ case 128:
return ActivityResultPigeon.decode(readValue(buffer)!);
- case 129:
+ case 129:
return PermissionRequestResult.decode(readValue(buffer)!);
default:
return super.readValueOfType(type, buffer);
@@ -124,12 +124,14 @@ class ActivityHostApi {
/// Gets whether the application should show UI with rationale before requesting a permission.
///
/// See https://developer.android.com/reference/android/app/Activity#shouldShowRequestPermissionRationale(java.lang.String).
- Future shouldShowRequestPermissionRationale(String arg_instanceId, String arg_permission) async {
+ Future shouldShowRequestPermissionRationale(
+ String arg_instanceId, String arg_permission) async {
final BasicMessageChannel channel = BasicMessageChannel(
- 'dev.flutter.pigeon.permission_handler_android.ActivityHostApi.shouldShowRequestPermissionRationale', codec,
+ 'dev.flutter.pigeon.permission_handler_android.ActivityHostApi.shouldShowRequestPermissionRationale',
+ codec,
binaryMessenger: _binaryMessenger);
- final List? replyList =
- await channel.send([arg_instanceId, arg_permission]) as List?;
+ final List? replyList = await channel
+ .send([arg_instanceId, arg_permission]) as List?;
if (replyList == null) {
throw PlatformException(
code: 'channel-error',
@@ -157,12 +159,15 @@ class ActivityHostApi {
/// https://developer.android.com/reference/android/app/Activity#requestPermissions(java.lang.String[],%20int)
/// and
/// https://developer.android.com/reference/android/app/Activity#onRequestPermissionsResult(int,%20java.lang.String[],%20int[]).
- Future requestPermissions(String arg_instanceId, List arg_permissions, int? arg_requestCode) async {
+ Future requestPermissions(String arg_instanceId,
+ List arg_permissions, int? arg_requestCode) async {
final BasicMessageChannel channel = BasicMessageChannel(
- 'dev.flutter.pigeon.permission_handler_android.ActivityHostApi.requestPermissions', codec,
+ 'dev.flutter.pigeon.permission_handler_android.ActivityHostApi.requestPermissions',
+ codec,
binaryMessenger: _binaryMessenger);
- final List? replyList =
- await channel.send([arg_instanceId, arg_permissions, arg_requestCode]) as List?;
+ final List? replyList = await channel
+ .send([arg_instanceId, arg_permissions, arg_requestCode])
+ as List?;
if (replyList == null) {
throw PlatformException(
code: 'channel-error',
@@ -187,12 +192,15 @@ class ActivityHostApi {
/// Start an activity for which the application would like a result when it finished.
///
/// See https://developer.android.com/reference/android/app/Activity#startActivityForResult(android.content.Intent,%20int).
- Future startActivityForResult(String arg_instanceId, String arg_intentInstanceId, int? arg_requestCode) async {
+ Future startActivityForResult(String arg_instanceId,
+ String arg_intentInstanceId, int? arg_requestCode) async {
final BasicMessageChannel channel = BasicMessageChannel(
- 'dev.flutter.pigeon.permission_handler_android.ActivityHostApi.startActivityForResult', codec,
+ 'dev.flutter.pigeon.permission_handler_android.ActivityHostApi.startActivityForResult',
+ codec,
binaryMessenger: _binaryMessenger);
- final List? replyList =
- await channel.send([arg_instanceId, arg_intentInstanceId, arg_requestCode]) as List?;
+ final List? replyList = await channel.send(
+ [arg_instanceId, arg_intentInstanceId, arg_requestCode])
+ as List?;
if (replyList == null) {
throw PlatformException(
code: 'channel-error',
@@ -231,17 +239,19 @@ abstract class ActivityFlutterApi {
/// Dispose of the Dart instance and remove it from the `InstanceManager`.
void dispose(String instanceId);
- static void setup(ActivityFlutterApi? api, {BinaryMessenger? binaryMessenger}) {
+ static void setup(ActivityFlutterApi? api,
+ {BinaryMessenger? binaryMessenger}) {
{
final BasicMessageChannel channel = BasicMessageChannel(
- 'dev.flutter.pigeon.permission_handler_android.ActivityFlutterApi.create', codec,
+ 'dev.flutter.pigeon.permission_handler_android.ActivityFlutterApi.create',
+ codec,
binaryMessenger: binaryMessenger);
if (api == null) {
channel.setMessageHandler(null);
} else {
channel.setMessageHandler((Object? message) async {
assert(message != null,
- 'Argument for dev.flutter.pigeon.permission_handler_android.ActivityFlutterApi.create was null.');
+ 'Argument for dev.flutter.pigeon.permission_handler_android.ActivityFlutterApi.create was null.');
final List args = (message as List?)!;
final String? arg_instanceId = (args[0] as String?);
assert(arg_instanceId != null,
@@ -253,14 +263,15 @@ abstract class ActivityFlutterApi {
}
{
final BasicMessageChannel channel = BasicMessageChannel(
- 'dev.flutter.pigeon.permission_handler_android.ActivityFlutterApi.dispose', codec,
+ 'dev.flutter.pigeon.permission_handler_android.ActivityFlutterApi.dispose',
+ codec,
binaryMessenger: binaryMessenger);
if (api == null) {
channel.setMessageHandler(null);
} else {
channel.setMessageHandler((Object? message) async {
assert(message != null,
- 'Argument for dev.flutter.pigeon.permission_handler_android.ActivityFlutterApi.dispose was null.');
+ 'Argument for dev.flutter.pigeon.permission_handler_android.ActivityFlutterApi.dispose was null.');
final List args = (message as List?)!;
final String? arg_instanceId = (args[0] as String?);
assert(arg_instanceId != null,
@@ -293,12 +304,14 @@ class ContextHostApi {
/// Determine whether the application has been granted a particular permission.
///
/// See https://developer.android.com/reference/android/content/Context#checkSelfPermission(java.lang.String).
- Future checkSelfPermission(String arg_instanceId, String arg_permission) async {
+ Future checkSelfPermission(
+ String arg_instanceId, String arg_permission) async {
final BasicMessageChannel channel = BasicMessageChannel(
- 'dev.flutter.pigeon.permission_handler_android.ContextHostApi.checkSelfPermission', codec,
+ 'dev.flutter.pigeon.permission_handler_android.ContextHostApi.checkSelfPermission',
+ codec,
binaryMessenger: _binaryMessenger);
- final List? replyList =
- await channel.send([arg_instanceId, arg_permission]) as List?;
+ final List? replyList = await channel
+ .send([arg_instanceId, arg_permission]) as List?;
if (replyList == null) {
throw PlatformException(
code: 'channel-error',
@@ -323,12 +336,15 @@ class ContextHostApi {
/// Launch a new activity.
///
/// See https://developer.android.com/reference/android/content/Context#startActivity(android.content.Intent).
- Future startActivity(String arg_instanceId, String arg_intentInstanceId) async {
+ Future startActivity(
+ String arg_instanceId, String arg_intentInstanceId) async {
final BasicMessageChannel channel = BasicMessageChannel(
- 'dev.flutter.pigeon.permission_handler_android.ContextHostApi.startActivity', codec,
+ 'dev.flutter.pigeon.permission_handler_android.ContextHostApi.startActivity',
+ codec,
binaryMessenger: _binaryMessenger);
final List? replyList =
- await channel.send([arg_instanceId, arg_intentInstanceId]) as List?;
+ await channel.send([arg_instanceId, arg_intentInstanceId])
+ as List?;
if (replyList == null) {
throw PlatformException(
code: 'channel-error',
@@ -350,7 +366,8 @@ class ContextHostApi {
/// See https://developer.android.com/reference/android/content/Context#getPackageName().
Future getPackageName(String arg_instanceId) async {
final BasicMessageChannel channel = BasicMessageChannel(
- 'dev.flutter.pigeon.permission_handler_android.ContextHostApi.getPackageName', codec,
+ 'dev.flutter.pigeon.permission_handler_android.ContextHostApi.getPackageName',
+ codec,
binaryMessenger: _binaryMessenger);
final List? replyList =
await channel.send([arg_instanceId]) as List?;
@@ -382,12 +399,40 @@ class ContextHostApi {
/// Returns the instance ID of the service.
///
/// See https://developer.android.com/reference/android/content/Context#getSystemService(java.lang.String).
- Future getSystemService(String arg_instanceId, String arg_name) async {
+ Future getSystemService(
+ String arg_instanceId, String arg_name) async {
+ final BasicMessageChannel channel = BasicMessageChannel(
+ 'dev.flutter.pigeon.permission_handler_android.ContextHostApi.getSystemService',
+ codec,
+ binaryMessenger: _binaryMessenger);
+ final List? replyList = await channel
+ .send([arg_instanceId, arg_name]) as List?;
+ if (replyList == null) {
+ throw PlatformException(
+ code: 'channel-error',
+ message: 'Unable to establish connection on channel.',
+ );
+ } else if (replyList.length > 1) {
+ throw PlatformException(
+ code: replyList[0]! as String,
+ message: replyList[1] as String?,
+ details: replyList[2],
+ );
+ } else {
+ return (replyList[0] as String?);
+ }
+ }
+
+ /// Returns the instance ID of a PackageManager instance to find global package information.
+ ///
+ /// See https://developer.android.com/reference/android/content/Context#getPackageManager().
+ Future getPackageManager(String arg_instanceId) async {
final BasicMessageChannel channel = BasicMessageChannel(
- 'dev.flutter.pigeon.permission_handler_android.ContextHostApi.getSystemService', codec,
+ 'dev.flutter.pigeon.permission_handler_android.ContextHostApi.getPackageManager',
+ codec,
binaryMessenger: _binaryMessenger);
final List? replyList =
- await channel.send([arg_instanceId, arg_name]) as List?;
+ await channel.send([arg_instanceId]) as List?;
if (replyList == null) {
throw PlatformException(
code: 'channel-error',
@@ -409,12 +454,13 @@ class ContextHostApi {
}
}
- /// Returns the instance ID of a PackageManager instance to find global package information.
+ /// Return a ContentResolver instance for your application's package.
///
- /// See https://developer.android.com/reference/android/content/Context#getPackageManager().
- Future getPackageManager(String arg_instanceId) async {
+ /// See https://developer.android.com/reference/android/content/Context#getContentResolver().
+ Future getContentResolver(String arg_instanceId) async {
final BasicMessageChannel channel = BasicMessageChannel(
- 'dev.flutter.pigeon.permission_handler_android.ContextHostApi.getPackageManager', codec,
+ 'dev.flutter.pigeon.permission_handler_android.ContextHostApi.getContentResolver',
+ codec,
binaryMessenger: _binaryMessenger);
final List? replyList =
await channel.send([arg_instanceId]) as List?;
@@ -456,17 +502,19 @@ abstract class ContextFlutterApi {
/// Dispose of the Dart instance and remove it from the `InstanceManager`.
void dispose(String instanceId);
- static void setup(ContextFlutterApi? api, {BinaryMessenger? binaryMessenger}) {
+ static void setup(ContextFlutterApi? api,
+ {BinaryMessenger? binaryMessenger}) {
{
final BasicMessageChannel channel = BasicMessageChannel(
- 'dev.flutter.pigeon.permission_handler_android.ContextFlutterApi.create', codec,
+ 'dev.flutter.pigeon.permission_handler_android.ContextFlutterApi.create',
+ codec,
binaryMessenger: binaryMessenger);
if (api == null) {
channel.setMessageHandler(null);
} else {
channel.setMessageHandler((Object? message) async {
assert(message != null,
- 'Argument for dev.flutter.pigeon.permission_handler_android.ContextFlutterApi.create was null.');
+ 'Argument for dev.flutter.pigeon.permission_handler_android.ContextFlutterApi.create was null.');
final List args = (message as List?)!;
final String? arg_instanceId = (args[0] as String?);
assert(arg_instanceId != null,
@@ -478,14 +526,15 @@ abstract class ContextFlutterApi {
}
{
final BasicMessageChannel channel = BasicMessageChannel(
- 'dev.flutter.pigeon.permission_handler_android.ContextFlutterApi.dispose', codec,
+ 'dev.flutter.pigeon.permission_handler_android.ContextFlutterApi.dispose',
+ codec,
binaryMessenger: binaryMessenger);
if (api == null) {
channel.setMessageHandler(null);
} else {
channel.setMessageHandler((Object? message) async {
assert(message != null,
- 'Argument for dev.flutter.pigeon.permission_handler_android.ContextFlutterApi.dispose was null.');
+ 'Argument for dev.flutter.pigeon.permission_handler_android.ContextFlutterApi.dispose was null.');
final List args = (message as List?)!;
final String? arg_instanceId = (args[0] as String?);
assert(arg_instanceId != null,
@@ -557,7 +606,8 @@ class UriHostApi {
/// See https://developer.android.com/reference/android/net/Uri#toString().
Future