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 toStringAsync(String arg_instanceId) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.UriHostApi.toStringAsync', codec, + 'dev.flutter.pigeon.permission_handler_android.UriHostApi.toStringAsync', + codec, binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_instanceId]) as List?; @@ -602,14 +652,15 @@ abstract class UriFlutterApi { static void setup(UriFlutterApi? api, {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.UriFlutterApi.create', codec, + 'dev.flutter.pigeon.permission_handler_android.UriFlutterApi.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.UriFlutterApi.create was null.'); + 'Argument for dev.flutter.pigeon.permission_handler_android.UriFlutterApi.create was null.'); final List args = (message as List?)!; final String? arg_instanceId = (args[0] as String?); assert(arg_instanceId != null, @@ -621,14 +672,15 @@ abstract class UriFlutterApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.UriFlutterApi.dispose', codec, + 'dev.flutter.pigeon.permission_handler_android.UriFlutterApi.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.UriFlutterApi.dispose was null.'); + 'Argument for dev.flutter.pigeon.permission_handler_android.UriFlutterApi.dispose was null.'); final List args = (message as List?)!; final String? arg_instanceId = (args[0] as String?); assert(arg_instanceId != null, @@ -663,7 +715,8 @@ class IntentHostApi { /// See https://developer.android.com/reference/android/content/Intent#Intent(). Future create(String arg_instanceId) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.IntentHostApi.create', codec, + 'dev.flutter.pigeon.permission_handler_android.IntentHostApi.create', + codec, binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_instanceId]) as List?; @@ -688,10 +741,11 @@ class IntentHostApi { /// See https://developer.android.com/reference/android/content/Intent#setAction(java.lang.String). Future setAction(String arg_instanceId, String arg_action) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.IntentHostApi.setAction', codec, + 'dev.flutter.pigeon.permission_handler_android.IntentHostApi.setAction', + codec, binaryMessenger: _binaryMessenger); - final List? replyList = - await channel.send([arg_instanceId, arg_action]) as List?; + final List? replyList = await channel + .send([arg_instanceId, arg_action]) as List?; if (replyList == null) { throw PlatformException( code: 'channel-error', @@ -713,10 +767,11 @@ class IntentHostApi { /// See https://developer.android.com/reference/android/content/Intent#setData(android.net.Uri). Future setData(String arg_instanceId, String arg_uriInstanceId) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.IntentHostApi.setData', codec, + 'dev.flutter.pigeon.permission_handler_android.IntentHostApi.setData', + codec, binaryMessenger: _binaryMessenger); - final List? replyList = - await channel.send([arg_instanceId, arg_uriInstanceId]) as List?; + final List? replyList = await channel + .send([arg_instanceId, arg_uriInstanceId]) as List?; if (replyList == null) { throw PlatformException( code: 'channel-error', @@ -742,10 +797,11 @@ class IntentHostApi { /// See https://developer.android.com/reference/android/content/Intent#addCategory(java.lang.String). Future addCategory(String arg_instanceId, String arg_category) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.IntentHostApi.addCategory', codec, + 'dev.flutter.pigeon.permission_handler_android.IntentHostApi.addCategory', + codec, binaryMessenger: _binaryMessenger); - final List? replyList = - await channel.send([arg_instanceId, arg_category]) as List?; + final List? replyList = await channel + .send([arg_instanceId, arg_category]) as List?; if (replyList == null) { throw PlatformException( code: 'channel-error', @@ -767,10 +823,11 @@ class IntentHostApi { /// See https://developer.android.com/reference/android/content/Intent#addFlags(int). Future addFlags(String arg_instanceId, int arg_flags) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.IntentHostApi.addFlags', codec, + 'dev.flutter.pigeon.permission_handler_android.IntentHostApi.addFlags', + codec, binaryMessenger: _binaryMessenger); - final List? replyList = - await channel.send([arg_instanceId, arg_flags]) as List?; + final List? replyList = await channel + .send([arg_instanceId, arg_flags]) as List?; if (replyList == null) { throw PlatformException( code: 'channel-error', @@ -815,12 +872,14 @@ class PowerManagerHostApi { /// be applied. /// /// See https://developer.android.com/reference/android/os/PowerManager#isIgnoringBatteryOptimizations(java.lang.String). - Future isIgnoringBatteryOptimizations(String arg_instanceId, String arg_packageName) async { + Future isIgnoringBatteryOptimizations( + String arg_instanceId, String arg_packageName) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.PowerManagerHostApi.isIgnoringBatteryOptimizations', codec, + 'dev.flutter.pigeon.permission_handler_android.PowerManagerHostApi.isIgnoringBatteryOptimizations', + codec, binaryMessenger: _binaryMessenger); - final List? replyList = - await channel.send([arg_instanceId, arg_packageName]) as List?; + final List? replyList = await channel + .send([arg_instanceId, arg_packageName]) as List?; if (replyList == null) { throw PlatformException( code: 'channel-error', @@ -859,17 +918,19 @@ abstract class PowerManagerFlutterApi { /// Dispose of the Dart instance and remove it from the `InstanceManager`. void dispose(String instanceId); - static void setup(PowerManagerFlutterApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(PowerManagerFlutterApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.PowerManagerFlutterApi.create', codec, + 'dev.flutter.pigeon.permission_handler_android.PowerManagerFlutterApi.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.PowerManagerFlutterApi.create was null.'); + 'Argument for dev.flutter.pigeon.permission_handler_android.PowerManagerFlutterApi.create was null.'); final List args = (message as List?)!; final String? arg_instanceId = (args[0] as String?); assert(arg_instanceId != null, @@ -881,14 +942,15 @@ abstract class PowerManagerFlutterApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.PowerManagerFlutterApi.dispose', codec, + 'dev.flutter.pigeon.permission_handler_android.PowerManagerFlutterApi.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.PowerManagerFlutterApi.dispose was null.'); + 'Argument for dev.flutter.pigeon.permission_handler_android.PowerManagerFlutterApi.dispose was null.'); final List args = (message as List?)!; final String? arg_instanceId = (args[0] as String?); assert(arg_instanceId != null, @@ -928,10 +990,10 @@ class BuildVersionHostApi { /// See https://developer.android.com/reference/android/os/Build.VERSION#SDK_INT. Future sdkInt() async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.BuildVersionHostApi.sdkInt', codec, + 'dev.flutter.pigeon.permission_handler_android.BuildVersionHostApi.sdkInt', + codec, binaryMessenger: _binaryMessenger); - final List? replyList = - await channel.send(null) as List?; + final List? replyList = await channel.send(null) as List?; if (replyList == null) { throw PlatformException( code: 'channel-error', @@ -976,7 +1038,8 @@ class AlarmManagerHostApi { /// See https://developer.android.com/reference/android/app/AlarmManager#canScheduleExactAlarms(). Future canScheduleExactAlarms(String arg_instanceId) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.AlarmManagerHostApi.canScheduleExactAlarms', codec, + 'dev.flutter.pigeon.permission_handler_android.AlarmManagerHostApi.canScheduleExactAlarms', + codec, binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_instanceId]) as List?; @@ -1018,17 +1081,19 @@ abstract class AlarmManagerFlutterApi { /// Dispose of the Dart instance and remove it from the `InstanceManager`. void dispose(String instanceId); - static void setup(AlarmManagerFlutterApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(AlarmManagerFlutterApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.AlarmManagerFlutterApi.create', codec, + 'dev.flutter.pigeon.permission_handler_android.AlarmManagerFlutterApi.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.AlarmManagerFlutterApi.create was null.'); + 'Argument for dev.flutter.pigeon.permission_handler_android.AlarmManagerFlutterApi.create was null.'); final List args = (message as List?)!; final String? arg_instanceId = (args[0] as String?); assert(arg_instanceId != null, @@ -1040,14 +1105,15 @@ abstract class AlarmManagerFlutterApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.AlarmManagerFlutterApi.dispose', codec, + 'dev.flutter.pigeon.permission_handler_android.AlarmManagerFlutterApi.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.AlarmManagerFlutterApi.dispose was null.'); + 'Argument for dev.flutter.pigeon.permission_handler_android.AlarmManagerFlutterApi.dispose was null.'); final List args = (message as List?)!; final String? arg_instanceId = (args[0] as String?); assert(arg_instanceId != null, @@ -1082,7 +1148,8 @@ class PackageManagerHostApi { /// See https://developer.android.com/reference/android/content/pm/PackageManager#canRequestPackageInstalls(). Future canRequestPackageInstalls(String arg_instanceId) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.PackageManagerHostApi.canRequestPackageInstalls', codec, + 'dev.flutter.pigeon.permission_handler_android.PackageManagerHostApi.canRequestPackageInstalls', + codec, binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_instanceId]) as List?; @@ -1112,12 +1179,15 @@ class PackageManagerHostApi { /// Use [getPackageInfoWithInfoFlags] when long flags are needed. /// /// See https://developer.android.com/reference/android/content/pm/PackageManager#getPackageInfo(java.lang.String,%20int). - Future getPackageInfoWithFlags(String arg_instanceId, String arg_packageName, int arg_flags) async { + Future getPackageInfoWithFlags( + String arg_instanceId, String arg_packageName, int arg_flags) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.PackageManagerHostApi.getPackageInfoWithFlags', codec, + 'dev.flutter.pigeon.permission_handler_android.PackageManagerHostApi.getPackageInfoWithFlags', + codec, binaryMessenger: _binaryMessenger); - final List? replyList = - await channel.send([arg_instanceId, arg_packageName, arg_flags]) as List?; + final List? replyList = await channel + .send([arg_instanceId, arg_packageName, arg_flags]) + as List?; if (replyList == null) { throw PlatformException( code: 'channel-error', @@ -1137,12 +1207,15 @@ class PackageManagerHostApi { /// Retrieve overall information about an application package that is installed on the system. /// /// See https://developer.android.com/reference/android/content/pm/PackageManager#getPackageInfo(java.lang.String,%20android.content.pm.PackageManager.PackageInfoFlags). - Future getPackageInfoWithInfoFlags(String arg_instanceId, String arg_packageName, String arg_flagsInstanceId) async { + Future getPackageInfoWithInfoFlags(String arg_instanceId, + String arg_packageName, String arg_flagsInstanceId) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.PackageManagerHostApi.getPackageInfoWithInfoFlags', codec, + 'dev.flutter.pigeon.permission_handler_android.PackageManagerHostApi.getPackageInfoWithInfoFlags', + codec, binaryMessenger: _binaryMessenger); - final List? replyList = - await channel.send([arg_instanceId, arg_packageName, arg_flagsInstanceId]) as List?; + final List? replyList = await channel.send( + [arg_instanceId, arg_packageName, arg_flagsInstanceId]) + as List?; if (replyList == null) { throw PlatformException( code: 'channel-error', @@ -1162,12 +1235,14 @@ class PackageManagerHostApi { /// 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 arg_instanceId, String arg_featureName) async { + Future hasSystemFeature( + String arg_instanceId, String arg_featureName) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.PackageManagerHostApi.hasSystemFeature', codec, + 'dev.flutter.pigeon.permission_handler_android.PackageManagerHostApi.hasSystemFeature', + codec, binaryMessenger: _binaryMessenger); - final List? replyList = - await channel.send([arg_instanceId, arg_featureName]) as List?; + final List? replyList = await channel + .send([arg_instanceId, arg_featureName]) as List?; if (replyList == null) { throw PlatformException( code: 'channel-error', @@ -1192,12 +1267,15 @@ class PackageManagerHostApi { /// 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). - Future> queryIntentActivitiesWithFlags(String arg_instanceId, String arg_intentInstanceId, int arg_flags) async { + Future> queryIntentActivitiesWithFlags( + String arg_instanceId, String arg_intentInstanceId, int arg_flags) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.PackageManagerHostApi.queryIntentActivitiesWithFlags', codec, + 'dev.flutter.pigeon.permission_handler_android.PackageManagerHostApi.queryIntentActivitiesWithFlags', + codec, binaryMessenger: _binaryMessenger); - final List? replyList = - await channel.send([arg_instanceId, arg_intentInstanceId, arg_flags]) as List?; + final List? replyList = await channel + .send([arg_instanceId, arg_intentInstanceId, arg_flags]) + as List?; if (replyList == null) { throw PlatformException( code: 'channel-error', @@ -1222,12 +1300,51 @@ class PackageManagerHostApi { /// 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,%20android.content.pm.ResolveInfoFlags). - Future> queryIntentActivitiesWithInfoFlags(String arg_instanceId, String arg_intentInstanceId, String arg_flagsInstanceId) async { + Future> queryIntentActivitiesWithInfoFlags( + String arg_instanceId, + String arg_intentInstanceId, + String arg_flagsInstanceId) async { + final BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.permission_handler_android.PackageManagerHostApi.queryIntentActivitiesWithInfoFlags', + codec, + binaryMessenger: _binaryMessenger); + final List? replyList = await channel.send([ + arg_instanceId, + arg_intentInstanceId, + arg_flagsInstanceId + ]) 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 if (replyList[0] == null) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } else { + return (replyList[0] as List?)!.cast(); + } + } + + /// Get a list of features that are available on the system. + /// + /// See https://developer.android.com/reference/android/content/pm/PackageManager#getSystemAvailableFeatures(). + Future> getSystemAvailableFeatures( + String arg_instanceId) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.PackageManagerHostApi.queryIntentActivitiesWithInfoFlags', codec, + 'dev.flutter.pigeon.permission_handler_android.PackageManagerHostApi.getSystemAvailableFeatures', + codec, binaryMessenger: _binaryMessenger); final List? replyList = - await channel.send([arg_instanceId, arg_intentInstanceId, arg_flagsInstanceId]) as List?; + await channel.send([arg_instanceId]) as List?; if (replyList == null) { throw PlatformException( code: 'channel-error', @@ -1266,17 +1383,19 @@ abstract class PackageManagerFlutterApi { /// Dispose of the Dart instance and remove it from the `InstanceManager`. void dispose(String instanceId); - static void setup(PackageManagerFlutterApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(PackageManagerFlutterApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.PackageManagerFlutterApi.create', codec, + 'dev.flutter.pigeon.permission_handler_android.PackageManagerFlutterApi.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.PackageManagerFlutterApi.create was null.'); + 'Argument for dev.flutter.pigeon.permission_handler_android.PackageManagerFlutterApi.create was null.'); final List args = (message as List?)!; final String? arg_instanceId = (args[0] as String?); assert(arg_instanceId != null, @@ -1288,14 +1407,15 @@ abstract class PackageManagerFlutterApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.PackageManagerFlutterApi.dispose', codec, + 'dev.flutter.pigeon.permission_handler_android.PackageManagerFlutterApi.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.PackageManagerFlutterApi.dispose was null.'); + 'Argument for dev.flutter.pigeon.permission_handler_android.PackageManagerFlutterApi.dispose was null.'); final List args = (message as List?)!; final String? arg_instanceId = (args[0] as String?); assert(arg_instanceId != null, @@ -1337,7 +1457,8 @@ class SettingsHostApi { /// See https://developer.android.com/reference/android/provider/Settings#canDrawOverlays(android.content.Context). Future canDrawOverlays(String arg_contextInstanceId) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.SettingsHostApi.canDrawOverlays', codec, + 'dev.flutter.pigeon.permission_handler_android.SettingsHostApi.canDrawOverlays', + codec, binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_contextInstanceId]) as List?; @@ -1391,7 +1512,8 @@ class NotificationManagerHostApi { /// See https://developer.android.com/reference/android/app/NotificationManager#isNotificationPolicyAccessGranted(). Future isNotificationPolicyAccessGranted(String arg_instanceId) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.NotificationManagerHostApi.isNotificationPolicyAccessGranted', codec, + 'dev.flutter.pigeon.permission_handler_android.NotificationManagerHostApi.isNotificationPolicyAccessGranted', + codec, binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_instanceId]) as List?; @@ -1421,7 +1543,8 @@ class NotificationManagerHostApi { /// See https://developer.android.com/reference/android/app/NotificationManager#areNotificationsEnabled(). Future areNotificationsEnabled(String arg_instanceId) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.NotificationManagerHostApi.areNotificationsEnabled', codec, + 'dev.flutter.pigeon.permission_handler_android.NotificationManagerHostApi.areNotificationsEnabled', + codec, binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_instanceId]) as List?; @@ -1463,17 +1586,19 @@ abstract class NotificationManagerFlutterApi { /// Dispose of the Dart instance and remove it from the `InstanceManager`. void dispose(String instanceId); - static void setup(NotificationManagerFlutterApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(NotificationManagerFlutterApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.NotificationManagerFlutterApi.create', codec, + 'dev.flutter.pigeon.permission_handler_android.NotificationManagerFlutterApi.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.NotificationManagerFlutterApi.create was null.'); + 'Argument for dev.flutter.pigeon.permission_handler_android.NotificationManagerFlutterApi.create was null.'); final List args = (message as List?)!; final String? arg_instanceId = (args[0] as String?); assert(arg_instanceId != null, @@ -1485,14 +1610,15 @@ abstract class NotificationManagerFlutterApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.NotificationManagerFlutterApi.dispose', codec, + 'dev.flutter.pigeon.permission_handler_android.NotificationManagerFlutterApi.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.NotificationManagerFlutterApi.dispose was null.'); + 'Argument for dev.flutter.pigeon.permission_handler_android.NotificationManagerFlutterApi.dispose was null.'); final List args = (message as List?)!; final String? arg_instanceId = (args[0] as String?); assert(arg_instanceId != null, @@ -1531,10 +1657,10 @@ class EnvironmentHostApi { /// See https://developer.android.com/reference/android/os/Environment#isExternalStorageManager(). Future isExternalStorageManager() async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.EnvironmentHostApi.isExternalStorageManager', codec, + 'dev.flutter.pigeon.permission_handler_android.EnvironmentHostApi.isExternalStorageManager', + codec, binaryMessenger: _binaryMessenger); - final List? replyList = - await channel.send(null) as List?; + final List? replyList = await channel.send(null) as List?; if (replyList == null) { throw PlatformException( code: 'channel-error', @@ -1583,7 +1709,8 @@ class PackageInfoHostApi { /// See https://developer.android.com/reference/android/content/pm/PackageInfo#requestedPermissions. Future> getRequestedPermissions(String arg_instanceId) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.PackageInfoHostApi.getRequestedPermissions', codec, + 'dev.flutter.pigeon.permission_handler_android.PackageInfoHostApi.getRequestedPermissions', + codec, binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_instanceId]) as List?; @@ -1625,17 +1752,19 @@ abstract class PackageInfoFlutterApi { /// Dispose of the Dart instance and remove it from the `InstanceManager`. void dispose(String instanceId); - static void setup(PackageInfoFlutterApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(PackageInfoFlutterApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.PackageInfoFlutterApi.create', codec, + 'dev.flutter.pigeon.permission_handler_android.PackageInfoFlutterApi.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.PackageInfoFlutterApi.create was null.'); + 'Argument for dev.flutter.pigeon.permission_handler_android.PackageInfoFlutterApi.create was null.'); final List args = (message as List?)!; final String? arg_instanceId = (args[0] as String?); assert(arg_instanceId != null, @@ -1647,14 +1776,15 @@ abstract class PackageInfoFlutterApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.PackageInfoFlutterApi.dispose', codec, + 'dev.flutter.pigeon.permission_handler_android.PackageInfoFlutterApi.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.PackageInfoFlutterApi.dispose was null.'); + 'Argument for dev.flutter.pigeon.permission_handler_android.PackageInfoFlutterApi.dispose was null.'); final List args = (message as List?)!; final String? arg_instanceId = (args[0] as String?); assert(arg_instanceId != null, @@ -1687,7 +1817,8 @@ class PackageInfoFlagsHostApi { /// See https://developer.android.com/reference/android/content/pm/PackageManager.PackageInfoFlags#of(long). Future of(int arg_value) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.PackageInfoFlagsHostApi.of', codec, + 'dev.flutter.pigeon.permission_handler_android.PackageInfoFlagsHostApi.of', + codec, binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_value]) as List?; @@ -1729,17 +1860,19 @@ abstract class PackageInfoFlagsFlutterApi { /// Dispose of the Dart instance and remove it from the `InstanceManager`. void dispose(String instanceId); - static void setup(PackageInfoFlagsFlutterApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(PackageInfoFlagsFlutterApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.PackageInfoFlagsFlutterApi.create', codec, + 'dev.flutter.pigeon.permission_handler_android.PackageInfoFlagsFlutterApi.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.PackageInfoFlagsFlutterApi.create was null.'); + 'Argument for dev.flutter.pigeon.permission_handler_android.PackageInfoFlagsFlutterApi.create was null.'); final List args = (message as List?)!; final String? arg_instanceId = (args[0] as String?); assert(arg_instanceId != null, @@ -1751,14 +1884,15 @@ abstract class PackageInfoFlagsFlutterApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.PackageInfoFlagsFlutterApi.dispose', codec, + 'dev.flutter.pigeon.permission_handler_android.PackageInfoFlagsFlutterApi.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.PackageInfoFlagsFlutterApi.dispose was null.'); + 'Argument for dev.flutter.pigeon.permission_handler_android.PackageInfoFlagsFlutterApi.dispose was null.'); final List args = (message as List?)!; final String? arg_instanceId = (args[0] as String?); assert(arg_instanceId != null, @@ -1791,7 +1925,8 @@ class ResolveInfoFlagsHostApi { /// See https://developer.android.com/reference/android/content/pm/PackageManager.ResolveInfoFlags#of(long). Future of(int arg_value) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.ResolveInfoFlagsHostApi.of', codec, + 'dev.flutter.pigeon.permission_handler_android.ResolveInfoFlagsHostApi.of', + codec, binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_value]) as List?; @@ -1833,17 +1968,19 @@ abstract class ResolveInfoFlagsFlutterApi { /// Dispose of the Dart instance and remove it from the `InstanceManager`. void dispose(String instanceId); - static void setup(ResolveInfoFlagsFlutterApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(ResolveInfoFlagsFlutterApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.ResolveInfoFlagsFlutterApi.create', codec, + 'dev.flutter.pigeon.permission_handler_android.ResolveInfoFlagsFlutterApi.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.ResolveInfoFlagsFlutterApi.create was null.'); + 'Argument for dev.flutter.pigeon.permission_handler_android.ResolveInfoFlagsFlutterApi.create was null.'); final List args = (message as List?)!; final String? arg_instanceId = (args[0] as String?); assert(arg_instanceId != null, @@ -1855,14 +1992,15 @@ abstract class ResolveInfoFlagsFlutterApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.ResolveInfoFlagsFlutterApi.dispose', codec, + 'dev.flutter.pigeon.permission_handler_android.ResolveInfoFlagsFlutterApi.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.ResolveInfoFlagsFlutterApi.dispose was null.'); + 'Argument for dev.flutter.pigeon.permission_handler_android.ResolveInfoFlagsFlutterApi.dispose was null.'); final List args = (message as List?)!; final String? arg_instanceId = (args[0] as String?); assert(arg_instanceId != null, @@ -1895,7 +2033,8 @@ class ApplicationInfoFlagsHostApi { /// See https://developer.android.com/reference/android/content/pm/PackageManager.ApplicationInfoFlags#of(long). Future of(int arg_value) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.ApplicationInfoFlagsHostApi.of', codec, + 'dev.flutter.pigeon.permission_handler_android.ApplicationInfoFlagsHostApi.of', + codec, binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_value]) as List?; @@ -1937,17 +2076,19 @@ abstract class ApplicationInfoFlagsFlutterApi { /// Dispose of the Dart instance and remove it from the `InstanceManager`. void dispose(String instanceId); - static void setup(ApplicationInfoFlagsFlutterApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(ApplicationInfoFlagsFlutterApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.ApplicationInfoFlagsFlutterApi.create', codec, + 'dev.flutter.pigeon.permission_handler_android.ApplicationInfoFlagsFlutterApi.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.ApplicationInfoFlagsFlutterApi.create was null.'); + 'Argument for dev.flutter.pigeon.permission_handler_android.ApplicationInfoFlagsFlutterApi.create was null.'); final List args = (message as List?)!; final String? arg_instanceId = (args[0] as String?); assert(arg_instanceId != null, @@ -1959,14 +2100,15 @@ abstract class ApplicationInfoFlagsFlutterApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.ApplicationInfoFlagsFlutterApi.dispose', codec, + 'dev.flutter.pigeon.permission_handler_android.ApplicationInfoFlagsFlutterApi.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.ApplicationInfoFlagsFlutterApi.dispose was null.'); + 'Argument for dev.flutter.pigeon.permission_handler_android.ApplicationInfoFlagsFlutterApi.dispose was null.'); final List args = (message as List?)!; final String? arg_instanceId = (args[0] as String?); assert(arg_instanceId != null, @@ -1999,7 +2141,8 @@ class ComponentInfoFlagsHostApi { /// See https://developer.android.com/reference/android/content/pm/PackageManager.ComponentInfoFlags#of(long). Future of(int arg_value) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.ComponentInfoFlagsHostApi.of', codec, + 'dev.flutter.pigeon.permission_handler_android.ComponentInfoFlagsHostApi.of', + codec, binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_value]) as List?; @@ -2041,17 +2184,19 @@ abstract class ComponentInfoFlagsFlutterApi { /// Dispose of the Dart instance and remove it from the `InstanceManager`. void dispose(String instanceId); - static void setup(ComponentInfoFlagsFlutterApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(ComponentInfoFlagsFlutterApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.ComponentInfoFlagsFlutterApi.create', codec, + 'dev.flutter.pigeon.permission_handler_android.ComponentInfoFlagsFlutterApi.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.ComponentInfoFlagsFlutterApi.create was null.'); + 'Argument for dev.flutter.pigeon.permission_handler_android.ComponentInfoFlagsFlutterApi.create was null.'); final List args = (message as List?)!; final String? arg_instanceId = (args[0] as String?); assert(arg_instanceId != null, @@ -2063,14 +2208,15 @@ abstract class ComponentInfoFlagsFlutterApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.ComponentInfoFlagsFlutterApi.dispose', codec, + 'dev.flutter.pigeon.permission_handler_android.ComponentInfoFlagsFlutterApi.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.ComponentInfoFlagsFlutterApi.dispose was null.'); + 'Argument for dev.flutter.pigeon.permission_handler_android.ComponentInfoFlagsFlutterApi.dispose was null.'); final List args = (message as List?)!; final String? arg_instanceId = (args[0] as String?); assert(arg_instanceId != null, @@ -2099,17 +2245,19 @@ abstract class ResolveInfoFlutterApi { /// Dispose of the Dart instance and remove it from the `InstanceManager`. void dispose(String instanceId); - static void setup(ResolveInfoFlutterApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(ResolveInfoFlutterApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.ResolveInfoFlutterApi.create', codec, + 'dev.flutter.pigeon.permission_handler_android.ResolveInfoFlutterApi.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.ResolveInfoFlutterApi.create was null.'); + 'Argument for dev.flutter.pigeon.permission_handler_android.ResolveInfoFlutterApi.create was null.'); final List args = (message as List?)!; final String? arg_instanceId = (args[0] as String?); assert(arg_instanceId != null, @@ -2121,14 +2269,15 @@ abstract class ResolveInfoFlutterApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.ResolveInfoFlutterApi.dispose', codec, + 'dev.flutter.pigeon.permission_handler_android.ResolveInfoFlutterApi.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.ResolveInfoFlutterApi.dispose was null.'); + 'Argument for dev.flutter.pigeon.permission_handler_android.ResolveInfoFlutterApi.dispose was null.'); final List args = (message as List?)!; final String? arg_instanceId = (args[0] as String?); assert(arg_instanceId != null, @@ -2140,3 +2289,755 @@ abstract class ResolveInfoFlutterApi { } } } + +/// 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. +abstract class FeatureInfoFlutterApi { + static const MessageCodec codec = StandardMessageCodec(); + + /// Create a new Dart instance and add it to the `InstanceManager`. + void create(String instanceId); + + /// Dispose of the Dart instance and remove it from the `InstanceManager`. + void dispose(String instanceId); + + static void setup(FeatureInfoFlutterApi? api, + {BinaryMessenger? binaryMessenger}) { + { + final BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.permission_handler_android.FeatureInfoFlutterApi.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.FeatureInfoFlutterApi.create was null.'); + final List args = (message as List?)!; + final String? arg_instanceId = (args[0] as String?); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.permission_handler_android.FeatureInfoFlutterApi.create was null, expected non-null String.'); + api.create(arg_instanceId!); + return; + }); + } + } + { + final BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.permission_handler_android.FeatureInfoFlutterApi.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.FeatureInfoFlutterApi.dispose was null.'); + final List args = (message as List?)!; + final String? arg_instanceId = (args[0] as String?); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.permission_handler_android.FeatureInfoFlutterApi.dispose was null, expected non-null String.'); + api.dispose(arg_instanceId!); + return; + }); + } + } + } +} + +/// 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. +class TelephonyManagerHostApi { + /// Constructor for [TelephonyManagerHostApi]. The [binaryMessenger] named argument is + /// available for dependency injection. If it is left null, the default + /// BinaryMessenger will be used which routes to the host platform. + TelephonyManagerHostApi({BinaryMessenger? binaryMessenger}) + : _binaryMessenger = binaryMessenger; + final BinaryMessenger? _binaryMessenger; + + static const MessageCodec codec = StandardMessageCodec(); + + /// 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(String arg_instanceId) async { + final BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.permission_handler_android.TelephonyManagerHostApi.getPhoneType', + codec, + binaryMessenger: _binaryMessenger); + final List? replyList = + await channel.send([arg_instanceId]) 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 if (replyList[0] == null) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } else { + return (replyList[0] as int?)!; + } + } + + /// 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(String arg_instanceId) async { + final BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.permission_handler_android.TelephonyManagerHostApi.getSimState', + codec, + binaryMessenger: _binaryMessenger); + final List? replyList = + await channel.send([arg_instanceId]) 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 if (replyList[0] == null) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } else { + return (replyList[0] as int?)!; + } + } +} + +/// 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. +abstract class TelephonyManagerFlutterApi { + static const MessageCodec codec = StandardMessageCodec(); + + /// Create a new Dart instance and add it to the `InstanceManager`. + void create(String instanceId); + + /// Dispose of the Dart instance and remove it from the `InstanceManager`. + void dispose(String instanceId); + + static void setup(TelephonyManagerFlutterApi? api, + {BinaryMessenger? binaryMessenger}) { + { + final BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.permission_handler_android.TelephonyManagerFlutterApi.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.TelephonyManagerFlutterApi.create was null.'); + final List args = (message as List?)!; + final String? arg_instanceId = (args[0] as String?); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.permission_handler_android.TelephonyManagerFlutterApi.create was null, expected non-null String.'); + api.create(arg_instanceId!); + return; + }); + } + } + { + final BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.permission_handler_android.TelephonyManagerFlutterApi.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.TelephonyManagerFlutterApi.dispose was null.'); + final List args = (message as List?)!; + final String? arg_instanceId = (args[0] as String?); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.permission_handler_android.TelephonyManagerFlutterApi.dispose was null, expected non-null String.'); + api.dispose(arg_instanceId!); + return; + }); + } + } + } +} + +/// 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. +class LocationManagerHostApi { + /// Constructor for [LocationManagerHostApi]. The [binaryMessenger] named argument is + /// available for dependency injection. If it is left null, the default + /// BinaryMessenger will be used which routes to the host platform. + LocationManagerHostApi({BinaryMessenger? binaryMessenger}) + : _binaryMessenger = binaryMessenger; + final BinaryMessenger? _binaryMessenger; + + static const MessageCodec codec = StandardMessageCodec(); + + /// Returns the current enabled/disabled status of location updates. + /// + /// See https://developer.android.com/reference/android/location/LocationManager#isLocationEnabled(). + Future isLocationEnabled(String arg_instanceId) async { + final BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.permission_handler_android.LocationManagerHostApi.isLocationEnabled', + codec, + binaryMessenger: _binaryMessenger); + final List? replyList = + await channel.send([arg_instanceId]) 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 if (replyList[0] == null) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } else { + return (replyList[0] as bool?)!; + } + } +} + +/// 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. +abstract class LocationManagerFlutterApi { + static const MessageCodec codec = StandardMessageCodec(); + + /// Create a new Dart instance and add it to the `InstanceManager`. + void create(String instanceId); + + /// Dispose of the Dart instance and remove it from the `InstanceManager`. + void dispose(String instanceId); + + static void setup(LocationManagerFlutterApi? api, + {BinaryMessenger? binaryMessenger}) { + { + final BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.permission_handler_android.LocationManagerFlutterApi.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.LocationManagerFlutterApi.create was null.'); + final List args = (message as List?)!; + final String? arg_instanceId = (args[0] as String?); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.permission_handler_android.LocationManagerFlutterApi.create was null, expected non-null String.'); + api.create(arg_instanceId!); + return; + }); + } + } + { + final BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.permission_handler_android.LocationManagerFlutterApi.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.LocationManagerFlutterApi.dispose was null.'); + final List args = (message as List?)!; + final String? arg_instanceId = (args[0] as String?); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.permission_handler_android.LocationManagerFlutterApi.dispose was null, expected non-null String.'); + api.dispose(arg_instanceId!); + return; + }); + } + } + } +} + +/// 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. +class BluetoothAdapterHostApi { + /// Constructor for [BluetoothAdapterHostApi]. The [binaryMessenger] named argument is + /// available for dependency injection. If it is left null, the default + /// BinaryMessenger will be used which routes to the host platform. + BluetoothAdapterHostApi({BinaryMessenger? binaryMessenger}) + : _binaryMessenger = binaryMessenger; + final BinaryMessenger? _binaryMessenger; + + static const MessageCodec codec = StandardMessageCodec(); + + /// 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 getDefaultAdapter() async { + final BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.permission_handler_android.BluetoothAdapterHostApi.getDefaultAdapter', + codec, + binaryMessenger: _binaryMessenger); + final List? replyList = await channel.send(null) 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 if (replyList[0] == null) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } else { + return (replyList[0] as String?)!; + } + } + + /// 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(String arg_instanceId) async { + final BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.permission_handler_android.BluetoothAdapterHostApi.isEnabled', + codec, + binaryMessenger: _binaryMessenger); + final List? replyList = + await channel.send([arg_instanceId]) 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 if (replyList[0] == null) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } else { + return (replyList[0] as bool?)!; + } + } +} + +/// 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. +abstract class BluetoothAdapterFlutterApi { + static const MessageCodec codec = StandardMessageCodec(); + + /// Create a new Dart instance and add it to the `InstanceManager`. + void create(String instanceId); + + /// Dispose of the Dart instance and remove it from the `InstanceManager`. + void dispose(String instanceId); + + static void setup(BluetoothAdapterFlutterApi? api, + {BinaryMessenger? binaryMessenger}) { + { + final BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.permission_handler_android.BluetoothAdapterFlutterApi.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.BluetoothAdapterFlutterApi.create was null.'); + final List args = (message as List?)!; + final String? arg_instanceId = (args[0] as String?); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.permission_handler_android.BluetoothAdapterFlutterApi.create was null, expected non-null String.'); + api.create(arg_instanceId!); + return; + }); + } + } + { + final BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.permission_handler_android.BluetoothAdapterFlutterApi.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.BluetoothAdapterFlutterApi.dispose was null.'); + final List args = (message as List?)!; + final String? arg_instanceId = (args[0] as String?); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.permission_handler_android.BluetoothAdapterFlutterApi.dispose was null, expected non-null String.'); + api.dispose(arg_instanceId!); + return; + }); + } + } + } +} + +/// 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. +class BluetoothManagerHostApi { + /// Constructor for [BluetoothManagerHostApi]. The [binaryMessenger] named argument is + /// available for dependency injection. If it is left null, the default + /// BinaryMessenger will be used which routes to the host platform. + BluetoothManagerHostApi({BinaryMessenger? binaryMessenger}) + : _binaryMessenger = binaryMessenger; + final BinaryMessenger? _binaryMessenger; + + static const MessageCodec codec = StandardMessageCodec(); + + /// Get the BLUETOOTH Adapter for this device. + /// + /// See https://developer.android.com/reference/android/bluetooth/BluetoothManager#getAdapter(). + Future getAdapter(String arg_instanceId) async { + final BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.permission_handler_android.BluetoothManagerHostApi.getAdapter', + codec, + binaryMessenger: _binaryMessenger); + final List? replyList = + await channel.send([arg_instanceId]) 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 if (replyList[0] == null) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } else { + return (replyList[0] as String?)!; + } + } +} + +/// 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. +abstract class BluetoothManagerFlutterApi { + static const MessageCodec codec = StandardMessageCodec(); + + /// Create a new Dart instance and add it to the `InstanceManager`. + void create(String instanceId); + + /// Dispose of the Dart instance and remove it from the `InstanceManager`. + void dispose(String instanceId); + + static void setup(BluetoothManagerFlutterApi? api, + {BinaryMessenger? binaryMessenger}) { + { + final BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.permission_handler_android.BluetoothManagerFlutterApi.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.BluetoothManagerFlutterApi.create was null.'); + final List args = (message as List?)!; + final String? arg_instanceId = (args[0] as String?); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.permission_handler_android.BluetoothManagerFlutterApi.create was null, expected non-null String.'); + api.create(arg_instanceId!); + return; + }); + } + } + { + final BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.permission_handler_android.BluetoothManagerFlutterApi.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.BluetoothManagerFlutterApi.dispose was null.'); + final List args = (message as List?)!; + final String? arg_instanceId = (args[0] as String?); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.permission_handler_android.BluetoothManagerFlutterApi.dispose was null, expected non-null String.'); + api.dispose(arg_instanceId!); + return; + }); + } + } + } +} + +/// 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. +abstract class ContentResolverFlutterApi { + static const MessageCodec codec = StandardMessageCodec(); + + /// Create a new Dart instance and add it to the `InstanceManager`. + void create(String instanceId); + + /// Dispose of the Dart instance and remove it from the `InstanceManager`. + void dispose(String instanceId); + + static void setup(ContentResolverFlutterApi? api, + {BinaryMessenger? binaryMessenger}) { + { + final BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.permission_handler_android.ContentResolverFlutterApi.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.ContentResolverFlutterApi.create was null.'); + final List args = (message as List?)!; + final String? arg_instanceId = (args[0] as String?); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.permission_handler_android.ContentResolverFlutterApi.create was null, expected non-null String.'); + api.create(arg_instanceId!); + return; + }); + } + } + { + final BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.permission_handler_android.ContentResolverFlutterApi.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.ContentResolverFlutterApi.dispose was null.'); + final List args = (message as List?)!; + final String? arg_instanceId = (args[0] as String?); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.permission_handler_android.ContentResolverFlutterApi.dispose was null, expected non-null String.'); + api.dispose(arg_instanceId!); + return; + }); + } + } + } +} + +class SettingsSecureHostApi { + /// Constructor for [SettingsSecureHostApi]. The [binaryMessenger] named argument is + /// available for dependency injection. If it is left null, the default + /// BinaryMessenger will be used which routes to the host platform. + SettingsSecureHostApi({BinaryMessenger? binaryMessenger}) + : _binaryMessenger = binaryMessenger; + final BinaryMessenger? _binaryMessenger; + + static const MessageCodec codec = StandardMessageCodec(); + + /// 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( + String arg_contentResolverInstanceId, String arg_name) async { + final BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.permission_handler_android.SettingsSecureHostApi.getInt', + codec, + binaryMessenger: _binaryMessenger); + final List? replyList = + await channel.send([arg_contentResolverInstanceId, 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 int?); + } + } + + /// 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(String arg_contentResolverInstanceId, + String arg_name, int arg_defaultValue) async { + final BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.permission_handler_android.SettingsSecureHostApi.getIntWithDefault', + codec, + binaryMessenger: _binaryMessenger); + final List? replyList = await channel.send([ + arg_contentResolverInstanceId, + arg_name, + arg_defaultValue + ]) 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 if (replyList[0] == null) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } else { + return (replyList[0] as int?)!; + } + } + + /// 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( + String arg_contentResolverInstanceId, String arg_name) async { + final BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.permission_handler_android.SettingsSecureHostApi.getString', + codec, + binaryMessenger: _binaryMessenger); + final List? replyList = + await channel.send([arg_contentResolverInstanceId, 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?); + } + } +} diff --git a/permission_handler_android/pigeons/android_permission_handler.dart b/permission_handler_android/pigeons/android_permission_handler.dart index b8857d5f9..2b5b1a5d5 100644 --- a/permission_handler_android/pigeons/android_permission_handler.dart +++ b/permission_handler_android/pigeons/android_permission_handler.dart @@ -143,7 +143,7 @@ abstract class ContextHostApi { /// Returns the instance ID of the service. /// /// See https://developer.android.com/reference/android/content/Context#getSystemService(java.lang.String). - String getSystemService( + String? getSystemService( String instanceId, String name, ); @@ -154,6 +154,13 @@ abstract class ContextHostApi { String getPackageManager( String instanceId, ); + + /// Return a ContentResolver instance for your application's package. + /// + /// See https://developer.android.com/reference/android/content/Context#getContentResolver(). + String getContentResolver( + String instanceId, + ); } /// Flutter API for `Context`. @@ -423,6 +430,13 @@ abstract class PackageManagerHostApi { String intentInstanceId, String flagsInstanceId, ); + + /// Get a list of features that are available on the system. + /// + /// See https://developer.android.com/reference/android/content/pm/PackageManager#getSystemAvailableFeatures(). + List getSystemAvailableFeatures( + String instanceId, + ); } /// Flutter API for `PackageManager`. @@ -696,3 +710,232 @@ abstract class ResolveInfoFlutterApi { /// Dispose of the Dart instance and remove it from the `InstanceManager`. void dispose(String instanceId); } + +/// 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. +@FlutterApi() +abstract class FeatureInfoFlutterApi { + /// Create a new Dart instance and add it to the `InstanceManager`. + void create(String instanceId); + + /// Dispose of the Dart instance and remove it from the `InstanceManager`. + void dispose(String instanceId); +} + +/// 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. +@HostApi(dartHostTestHandler: 'TelephonyManagerTestHostApi') +abstract class 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(). + int getPhoneType( + 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). + int getSimState( + String instanceId, + ); +} + +/// 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. +@FlutterApi() +abstract class TelephonyManagerFlutterApi { + /// Create a new Dart instance and add it to the `InstanceManager`. + void create(String instanceId); + + /// Dispose of the Dart instance and remove it from the `InstanceManager`. + void dispose(String instanceId); +} + +/// 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. +@HostApi(dartHostTestHandler: 'LocationManagerTestHostApi') +abstract class LocationManagerHostApi { + /// Returns the current enabled/disabled status of location updates. + /// + /// See https://developer.android.com/reference/android/location/LocationManager#isLocationEnabled(). + bool isLocationEnabled(String instanceId); +} + +/// 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. +@FlutterApi() +abstract class LocationManagerFlutterApi { + /// Create a new Dart instance and add it to the `InstanceManager`. + void create(String instanceId); + + /// Dispose of the Dart instance and remove it from the `InstanceManager`. + void dispose(String instanceId); +} + +/// 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. +@HostApi(dartHostTestHandler: 'BluetoothAdapterTestHostApi') +abstract class 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(). + 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(). + bool isEnabled( + String instanceId, + ); +} + +/// 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. +@FlutterApi() +abstract class BluetoothAdapterFlutterApi { + /// Create a new Dart instance and add it to the `InstanceManager`. + void create(String instanceId); + + /// Dispose of the Dart instance and remove it from the `InstanceManager`. + void dispose(String instanceId); +} + +/// 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. +@HostApi(dartHostTestHandler: 'BluetoothManagerTestHostApi') +abstract class BluetoothManagerHostApi { + /// Get the BLUETOOTH Adapter for this device. + /// + /// See https://developer.android.com/reference/android/bluetooth/BluetoothManager#getAdapter(). + String getAdapter( + String instanceId, + ); +} + +/// 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. +@FlutterApi() +abstract class BluetoothManagerFlutterApi { + /// Create a new Dart instance and add it to the `InstanceManager`. + void create(String instanceId); + + /// Dispose of the Dart instance and remove it from the `InstanceManager`. + void dispose(String instanceId); +} + +/// 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. +@FlutterApi() +abstract class ContentResolverFlutterApi { + /// Create a new Dart instance and add it to the `InstanceManager`. + void create(String instanceId); + + /// Dispose of the Dart instance and remove it from the `InstanceManager`. + void dispose(String instanceId); +} + +@HostApi(dartHostTestHandler: 'ContentResolverTestHostApi') +abstract class 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). + int? getInt( + String contentResolverInstanceId, + 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). + int getIntWithDefault( + String contentResolverInstanceId, + String name, + int 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). + String? getString( + String contentResolverInstanceId, + String name, + ); +} diff --git a/permission_handler_android/test/test_permission_handler.pigeon.dart b/permission_handler_android/test/test_permission_handler.pigeon.dart index 30f78411e..dedde330d 100644 --- a/permission_handler_android/test/test_permission_handler.pigeon.dart +++ b/permission_handler_android/test/test_permission_handler.pigeon.dart @@ -28,9 +28,9 @@ class _ActivityTestHostApiCodec 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); @@ -46,13 +46,15 @@ class _ActivityTestHostApiCodec extends StandardMessageCodec { /// /// See https://developer.android.com/reference/android/app/Activity. abstract class ActivityTestHostApi { - static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => TestDefaultBinaryMessengerBinding.instance; + static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => + TestDefaultBinaryMessengerBinding.instance; static const MessageCodec codec = _ActivityTestHostApiCodec(); /// 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). - bool shouldShowRequestPermissionRationale(String instanceId, String permission); + bool shouldShowRequestPermissionRationale( + String instanceId, String permission); /// Requests permissions to be granted to this application. /// @@ -60,24 +62,31 @@ abstract class ActivityTestHostApi { /// 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 instanceId, List permissions, int? requestCode); + Future requestPermissions( + String instanceId, List permissions, int? requestCode); /// 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 instanceId, String intentInstanceId, int? requestCode); + Future startActivityForResult( + String instanceId, String intentInstanceId, int? requestCode); - static void setup(ActivityTestHostApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(ActivityTestHostApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.ActivityHostApi.shouldShowRequestPermissionRationale', codec, + 'dev.flutter.pigeon.permission_handler_android.ActivityHostApi.shouldShowRequestPermissionRationale', + codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.permission_handler_android.ActivityHostApi.shouldShowRequestPermissionRationale was null.'); + 'Argument for dev.flutter.pigeon.permission_handler_android.ActivityHostApi.shouldShowRequestPermissionRationale was null.'); final List args = (message as List?)!; final String? arg_instanceId = (args[0] as String?); assert(arg_instanceId != null, @@ -85,44 +94,55 @@ abstract class ActivityTestHostApi { final String? arg_permission = (args[1] as String?); assert(arg_permission != null, 'Argument for dev.flutter.pigeon.permission_handler_android.ActivityHostApi.shouldShowRequestPermissionRationale was null, expected non-null String.'); - final bool output = api.shouldShowRequestPermissionRationale(arg_instanceId!, arg_permission!); + final bool output = api.shouldShowRequestPermissionRationale( + arg_instanceId!, arg_permission!); return [output]; }); } } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.ActivityHostApi.requestPermissions', codec, + 'dev.flutter.pigeon.permission_handler_android.ActivityHostApi.requestPermissions', + codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.permission_handler_android.ActivityHostApi.requestPermissions was null.'); + 'Argument for dev.flutter.pigeon.permission_handler_android.ActivityHostApi.requestPermissions was null.'); final List args = (message as List?)!; final String? arg_instanceId = (args[0] as String?); assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.permission_handler_android.ActivityHostApi.requestPermissions was null, expected non-null String.'); - final List? arg_permissions = (args[1] as List?)?.cast(); + final List? arg_permissions = + (args[1] as List?)?.cast(); assert(arg_permissions != null, 'Argument for dev.flutter.pigeon.permission_handler_android.ActivityHostApi.requestPermissions was null, expected non-null List.'); final int? arg_requestCode = (args[2] as int?); - final PermissionRequestResult output = await api.requestPermissions(arg_instanceId!, arg_permissions!, arg_requestCode); + final PermissionRequestResult output = await api.requestPermissions( + arg_instanceId!, arg_permissions!, arg_requestCode); return [output]; }); } } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.ActivityHostApi.startActivityForResult', codec, + 'dev.flutter.pigeon.permission_handler_android.ActivityHostApi.startActivityForResult', + codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.permission_handler_android.ActivityHostApi.startActivityForResult was null.'); + 'Argument for dev.flutter.pigeon.permission_handler_android.ActivityHostApi.startActivityForResult was null.'); final List args = (message as List?)!; final String? arg_instanceId = (args[0] as String?); assert(arg_instanceId != null, @@ -131,7 +151,8 @@ abstract class ActivityTestHostApi { assert(arg_intentInstanceId != null, 'Argument for dev.flutter.pigeon.permission_handler_android.ActivityHostApi.startActivityForResult was null, expected non-null String.'); final int? arg_requestCode = (args[2] as int?); - final ActivityResultPigeon output = await api.startActivityForResult(arg_instanceId!, arg_intentInstanceId!, arg_requestCode); + final ActivityResultPigeon output = await api.startActivityForResult( + arg_instanceId!, arg_intentInstanceId!, arg_requestCode); return [output]; }); } @@ -147,7 +168,8 @@ abstract class ActivityTestHostApi { /// /// See https://developer.android.com/reference/android/content/Context. abstract class ContextTestHostApi { - static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => TestDefaultBinaryMessengerBinding.instance; + static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => + TestDefaultBinaryMessengerBinding.instance; static const MessageCodec codec = StandardMessageCodec(); /// Determine whether the application has been granted a particular permission. @@ -172,24 +194,34 @@ abstract class ContextTestHostApi { /// Returns the instance ID of the service. /// /// See https://developer.android.com/reference/android/content/Context#getSystemService(java.lang.String). - String getSystemService(String instanceId, String name); + String? getSystemService(String instanceId, String name); /// Returns the instance ID of a PackageManager instance to find global package information. /// /// See https://developer.android.com/reference/android/content/Context#getPackageManager(). String getPackageManager(String instanceId); - static void setup(ContextTestHostApi? api, {BinaryMessenger? binaryMessenger}) { + /// Return a ContentResolver instance for your application's package. + /// + /// See https://developer.android.com/reference/android/content/Context#getContentResolver(). + String getContentResolver(String instanceId); + + static void setup(ContextTestHostApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.ContextHostApi.checkSelfPermission', codec, + 'dev.flutter.pigeon.permission_handler_android.ContextHostApi.checkSelfPermission', + codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.permission_handler_android.ContextHostApi.checkSelfPermission was null.'); + 'Argument for dev.flutter.pigeon.permission_handler_android.ContextHostApi.checkSelfPermission was null.'); final List args = (message as List?)!; final String? arg_instanceId = (args[0] as String?); assert(arg_instanceId != null, @@ -197,21 +229,26 @@ abstract class ContextTestHostApi { final String? arg_permission = (args[1] as String?); assert(arg_permission != null, 'Argument for dev.flutter.pigeon.permission_handler_android.ContextHostApi.checkSelfPermission was null, expected non-null String.'); - final int output = api.checkSelfPermission(arg_instanceId!, arg_permission!); + final int output = + api.checkSelfPermission(arg_instanceId!, arg_permission!); return [output]; }); } } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.ContextHostApi.startActivity', codec, + 'dev.flutter.pigeon.permission_handler_android.ContextHostApi.startActivity', + codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.permission_handler_android.ContextHostApi.startActivity was null.'); + 'Argument for dev.flutter.pigeon.permission_handler_android.ContextHostApi.startActivity was null.'); final List args = (message as List?)!; final String? arg_instanceId = (args[0] as String?); assert(arg_instanceId != null, @@ -226,14 +263,18 @@ abstract class ContextTestHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.ContextHostApi.getPackageName', codec, + 'dev.flutter.pigeon.permission_handler_android.ContextHostApi.getPackageName', + codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.permission_handler_android.ContextHostApi.getPackageName was null.'); + 'Argument for dev.flutter.pigeon.permission_handler_android.ContextHostApi.getPackageName was null.'); final List args = (message as List?)!; final String? arg_instanceId = (args[0] as String?); assert(arg_instanceId != null, @@ -245,14 +286,18 @@ abstract class ContextTestHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.ContextHostApi.getSystemService', codec, + 'dev.flutter.pigeon.permission_handler_android.ContextHostApi.getSystemService', + codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.permission_handler_android.ContextHostApi.getSystemService was null.'); + 'Argument for dev.flutter.pigeon.permission_handler_android.ContextHostApi.getSystemService was null.'); final List args = (message as List?)!; final String? arg_instanceId = (args[0] as String?); assert(arg_instanceId != null, @@ -260,21 +305,26 @@ abstract class ContextTestHostApi { final String? arg_name = (args[1] as String?); assert(arg_name != null, 'Argument for dev.flutter.pigeon.permission_handler_android.ContextHostApi.getSystemService was null, expected non-null String.'); - final String output = api.getSystemService(arg_instanceId!, arg_name!); + final String? output = + api.getSystemService(arg_instanceId!, arg_name!); return [output]; }); } } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.ContextHostApi.getPackageManager', codec, + 'dev.flutter.pigeon.permission_handler_android.ContextHostApi.getPackageManager', + codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.permission_handler_android.ContextHostApi.getPackageManager was null.'); + 'Argument for dev.flutter.pigeon.permission_handler_android.ContextHostApi.getPackageManager was null.'); final List args = (message as List?)!; final String? arg_instanceId = (args[0] as String?); assert(arg_instanceId != null, @@ -284,6 +334,29 @@ abstract class ContextTestHostApi { }); } } + { + final BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.permission_handler_android.ContextHostApi.getContentResolver', + codec, + binaryMessenger: binaryMessenger); + if (api == null) { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); + } else { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.permission_handler_android.ContextHostApi.getContentResolver was null.'); + final List args = (message as List?)!; + final String? arg_instanceId = (args[0] as String?); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.permission_handler_android.ContextHostApi.getContentResolver was null, expected non-null String.'); + final String output = api.getContentResolver(arg_instanceId!); + return [output]; + }); + } + } } } @@ -295,7 +368,8 @@ abstract class ContextTestHostApi { /// /// See https://developer.android.com/reference/android/net/Uri. abstract class UriTestHostApi { - static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => TestDefaultBinaryMessengerBinding.instance; + static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => + TestDefaultBinaryMessengerBinding.instance; static const MessageCodec codec = StandardMessageCodec(); /// Creates a Uri which parses the given encoded URI string. @@ -318,14 +392,18 @@ abstract class UriTestHostApi { static void setup(UriTestHostApi? api, {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.UriHostApi.parse', codec, + 'dev.flutter.pigeon.permission_handler_android.UriHostApi.parse', + codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.permission_handler_android.UriHostApi.parse was null.'); + 'Argument for dev.flutter.pigeon.permission_handler_android.UriHostApi.parse was null.'); final List args = (message as List?)!; final String? arg_uriString = (args[0] as String?); assert(arg_uriString != null, @@ -337,14 +415,18 @@ abstract class UriTestHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.UriHostApi.toStringAsync', codec, + 'dev.flutter.pigeon.permission_handler_android.UriHostApi.toStringAsync', + codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.permission_handler_android.UriHostApi.toStringAsync was null.'); + 'Argument for dev.flutter.pigeon.permission_handler_android.UriHostApi.toStringAsync was null.'); final List args = (message as List?)!; final String? arg_instanceId = (args[0] as String?); assert(arg_instanceId != null, @@ -365,7 +447,8 @@ abstract class UriTestHostApi { /// /// See https://developer.android.com/reference/android/content/Intent. abstract class IntentTestHostApi { - static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => TestDefaultBinaryMessengerBinding.instance; + static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => + TestDefaultBinaryMessengerBinding.instance; static const MessageCodec codec = StandardMessageCodec(); /// Creates an empty intent. @@ -397,17 +480,22 @@ abstract class IntentTestHostApi { /// See https://developer.android.com/reference/android/content/Intent#addFlags(int). void addFlags(String instanceId, int flags); - static void setup(IntentTestHostApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(IntentTestHostApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.IntentHostApi.create', codec, + 'dev.flutter.pigeon.permission_handler_android.IntentHostApi.create', + codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.permission_handler_android.IntentHostApi.create was null.'); + 'Argument for dev.flutter.pigeon.permission_handler_android.IntentHostApi.create was null.'); final List args = (message as List?)!; final String? arg_instanceId = (args[0] as String?); assert(arg_instanceId != null, @@ -419,14 +507,18 @@ abstract class IntentTestHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.IntentHostApi.setAction', codec, + 'dev.flutter.pigeon.permission_handler_android.IntentHostApi.setAction', + codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.permission_handler_android.IntentHostApi.setAction was null.'); + 'Argument for dev.flutter.pigeon.permission_handler_android.IntentHostApi.setAction was null.'); final List args = (message as List?)!; final String? arg_instanceId = (args[0] as String?); assert(arg_instanceId != null, @@ -441,14 +533,18 @@ abstract class IntentTestHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.IntentHostApi.setData', codec, + 'dev.flutter.pigeon.permission_handler_android.IntentHostApi.setData', + codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.permission_handler_android.IntentHostApi.setData was null.'); + 'Argument for dev.flutter.pigeon.permission_handler_android.IntentHostApi.setData was null.'); final List args = (message as List?)!; final String? arg_instanceId = (args[0] as String?); assert(arg_instanceId != null, @@ -463,14 +559,18 @@ abstract class IntentTestHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.IntentHostApi.addCategory', codec, + 'dev.flutter.pigeon.permission_handler_android.IntentHostApi.addCategory', + codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.permission_handler_android.IntentHostApi.addCategory was null.'); + 'Argument for dev.flutter.pigeon.permission_handler_android.IntentHostApi.addCategory was null.'); final List args = (message as List?)!; final String? arg_instanceId = (args[0] as String?); assert(arg_instanceId != null, @@ -485,14 +585,18 @@ abstract class IntentTestHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.IntentHostApi.addFlags', codec, + 'dev.flutter.pigeon.permission_handler_android.IntentHostApi.addFlags', + codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.permission_handler_android.IntentHostApi.addFlags was null.'); + 'Argument for dev.flutter.pigeon.permission_handler_android.IntentHostApi.addFlags was null.'); final List args = (message as List?)!; final String? arg_instanceId = (args[0] as String?); assert(arg_instanceId != null, @@ -516,7 +620,8 @@ abstract class IntentTestHostApi { /// /// See https://developer.android.com/reference/android/os/PowerManager. abstract class PowerManagerTestHostApi { - static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => TestDefaultBinaryMessengerBinding.instance; + static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => + TestDefaultBinaryMessengerBinding.instance; static const MessageCodec codec = StandardMessageCodec(); /// Returns whether the given application package name is on the device's power allowlist. @@ -531,17 +636,22 @@ abstract class PowerManagerTestHostApi { /// See https://developer.android.com/reference/android/os/PowerManager#isIgnoringBatteryOptimizations(java.lang.String). bool isIgnoringBatteryOptimizations(String instanceId, String packageName); - static void setup(PowerManagerTestHostApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(PowerManagerTestHostApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.PowerManagerHostApi.isIgnoringBatteryOptimizations', codec, + 'dev.flutter.pigeon.permission_handler_android.PowerManagerHostApi.isIgnoringBatteryOptimizations', + codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.permission_handler_android.PowerManagerHostApi.isIgnoringBatteryOptimizations was null.'); + 'Argument for dev.flutter.pigeon.permission_handler_android.PowerManagerHostApi.isIgnoringBatteryOptimizations was null.'); final List args = (message as List?)!; final String? arg_instanceId = (args[0] as String?); assert(arg_instanceId != null, @@ -549,7 +659,8 @@ abstract class PowerManagerTestHostApi { final String? arg_packageName = (args[1] as String?); assert(arg_packageName != null, 'Argument for dev.flutter.pigeon.permission_handler_android.PowerManagerHostApi.isIgnoringBatteryOptimizations was null, expected non-null String.'); - final bool output = api.isIgnoringBatteryOptimizations(arg_instanceId!, arg_packageName!); + final bool output = api.isIgnoringBatteryOptimizations( + arg_instanceId!, arg_packageName!); return [output]; }); } @@ -565,7 +676,8 @@ abstract class PowerManagerTestHostApi { /// /// See https://developer.android.com/reference/android/os/Build.VERSION. abstract class BuildVersionTestHostApi { - static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => TestDefaultBinaryMessengerBinding.instance; + static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => + TestDefaultBinaryMessengerBinding.instance; static const MessageCodec codec = StandardMessageCodec(); /// The SDK version of the software currently running on this hardware device. @@ -578,15 +690,20 @@ abstract class BuildVersionTestHostApi { /// See https://developer.android.com/reference/android/os/Build.VERSION#SDK_INT. int sdkInt(); - static void setup(BuildVersionTestHostApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(BuildVersionTestHostApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.BuildVersionHostApi.sdkInt', codec, + 'dev.flutter.pigeon.permission_handler_android.BuildVersionHostApi.sdkInt', + codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { // ignore message final int output = api.sdkInt(); return [output]; @@ -604,7 +721,8 @@ abstract class BuildVersionTestHostApi { /// /// See https://developer.android.com/reference/android/app/AlarmManager. abstract class AlarmManagerTestHostApi { - static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => TestDefaultBinaryMessengerBinding.instance; + static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => + TestDefaultBinaryMessengerBinding.instance; static const MessageCodec codec = StandardMessageCodec(); /// Called to check if the application can schedule exact alarms. @@ -612,17 +730,22 @@ abstract class AlarmManagerTestHostApi { /// See https://developer.android.com/reference/android/app/AlarmManager#canScheduleExactAlarms(). bool canScheduleExactAlarms(String instanceId); - static void setup(AlarmManagerTestHostApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(AlarmManagerTestHostApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.AlarmManagerHostApi.canScheduleExactAlarms', codec, + 'dev.flutter.pigeon.permission_handler_android.AlarmManagerHostApi.canScheduleExactAlarms', + codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.permission_handler_android.AlarmManagerHostApi.canScheduleExactAlarms was null.'); + 'Argument for dev.flutter.pigeon.permission_handler_android.AlarmManagerHostApi.canScheduleExactAlarms was null.'); final List args = (message as List?)!; final String? arg_instanceId = (args[0] as String?); assert(arg_instanceId != null, @@ -643,7 +766,8 @@ abstract class AlarmManagerTestHostApi { /// /// See https://developer.android.com/reference/android/content/pm/PackageManager. abstract class PackageManagerTestHostApi { - static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => TestDefaultBinaryMessengerBinding.instance; + static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => + TestDefaultBinaryMessengerBinding.instance; static const MessageCodec codec = StandardMessageCodec(); /// Checks whether the calling package is allowed to request package installs through package installer. @@ -656,12 +780,14 @@ abstract class PackageManagerTestHostApi { /// Use [getPackageInfoWithInfoFlags] when long flags are needed. /// /// See https://developer.android.com/reference/android/content/pm/PackageManager#getPackageInfo(java.lang.String,%20int). - String? getPackageInfoWithFlags(String instanceId, String packageName, int flags); + String? getPackageInfoWithFlags( + String instanceId, String packageName, int flags); /// Retrieve overall information about an application package that is installed on the system. /// /// See https://developer.android.com/reference/android/content/pm/PackageManager#getPackageInfo(java.lang.String,%20android.content.pm.PackageManager.PackageInfoFlags). - String? getPackageInfoWithInfoFlags(String instanceId, String packageName, String flagsInstanceId); + String? getPackageInfoWithInfoFlags( + String instanceId, String packageName, String flagsInstanceId); /// Check whether the given feature name is one of the available features as returned by getSystemAvailableFeatures(). /// @@ -671,24 +797,36 @@ abstract class PackageManagerTestHostApi { /// 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). - List queryIntentActivitiesWithFlags(String instanceId, String intentInstanceId, int flags); + List queryIntentActivitiesWithFlags( + String instanceId, String intentInstanceId, int flags); /// 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,%20android.content.pm.ResolveInfoFlags). - List queryIntentActivitiesWithInfoFlags(String instanceId, String intentInstanceId, String flagsInstanceId); + List queryIntentActivitiesWithInfoFlags( + String instanceId, String intentInstanceId, String flagsInstanceId); + + /// Get a list of features that are available on the system. + /// + /// See https://developer.android.com/reference/android/content/pm/PackageManager#getSystemAvailableFeatures(). + List getSystemAvailableFeatures(String instanceId); - static void setup(PackageManagerTestHostApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(PackageManagerTestHostApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.PackageManagerHostApi.canRequestPackageInstalls', codec, + 'dev.flutter.pigeon.permission_handler_android.PackageManagerHostApi.canRequestPackageInstalls', + codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.permission_handler_android.PackageManagerHostApi.canRequestPackageInstalls was null.'); + 'Argument for dev.flutter.pigeon.permission_handler_android.PackageManagerHostApi.canRequestPackageInstalls was null.'); final List args = (message as List?)!; final String? arg_instanceId = (args[0] as String?); assert(arg_instanceId != null, @@ -700,14 +838,18 @@ abstract class PackageManagerTestHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.PackageManagerHostApi.getPackageInfoWithFlags', codec, + 'dev.flutter.pigeon.permission_handler_android.PackageManagerHostApi.getPackageInfoWithFlags', + codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.permission_handler_android.PackageManagerHostApi.getPackageInfoWithFlags was null.'); + 'Argument for dev.flutter.pigeon.permission_handler_android.PackageManagerHostApi.getPackageInfoWithFlags was null.'); final List args = (message as List?)!; final String? arg_instanceId = (args[0] as String?); assert(arg_instanceId != null, @@ -718,21 +860,26 @@ abstract class PackageManagerTestHostApi { final int? arg_flags = (args[2] as int?); assert(arg_flags != null, 'Argument for dev.flutter.pigeon.permission_handler_android.PackageManagerHostApi.getPackageInfoWithFlags was null, expected non-null int.'); - final String? output = api.getPackageInfoWithFlags(arg_instanceId!, arg_packageName!, arg_flags!); + final String? output = api.getPackageInfoWithFlags( + arg_instanceId!, arg_packageName!, arg_flags!); return [output]; }); } } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.PackageManagerHostApi.getPackageInfoWithInfoFlags', codec, + 'dev.flutter.pigeon.permission_handler_android.PackageManagerHostApi.getPackageInfoWithInfoFlags', + codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.permission_handler_android.PackageManagerHostApi.getPackageInfoWithInfoFlags was null.'); + 'Argument for dev.flutter.pigeon.permission_handler_android.PackageManagerHostApi.getPackageInfoWithInfoFlags was null.'); final List args = (message as List?)!; final String? arg_instanceId = (args[0] as String?); assert(arg_instanceId != null, @@ -743,21 +890,26 @@ abstract class PackageManagerTestHostApi { final String? arg_flagsInstanceId = (args[2] as String?); assert(arg_flagsInstanceId != null, 'Argument for dev.flutter.pigeon.permission_handler_android.PackageManagerHostApi.getPackageInfoWithInfoFlags was null, expected non-null String.'); - final String? output = api.getPackageInfoWithInfoFlags(arg_instanceId!, arg_packageName!, arg_flagsInstanceId!); + final String? output = api.getPackageInfoWithInfoFlags( + arg_instanceId!, arg_packageName!, arg_flagsInstanceId!); return [output]; }); } } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.PackageManagerHostApi.hasSystemFeature', codec, + 'dev.flutter.pigeon.permission_handler_android.PackageManagerHostApi.hasSystemFeature', + codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.permission_handler_android.PackageManagerHostApi.hasSystemFeature was null.'); + 'Argument for dev.flutter.pigeon.permission_handler_android.PackageManagerHostApi.hasSystemFeature was null.'); final List args = (message as List?)!; final String? arg_instanceId = (args[0] as String?); assert(arg_instanceId != null, @@ -765,21 +917,26 @@ abstract class PackageManagerTestHostApi { final String? arg_featureName = (args[1] as String?); assert(arg_featureName != null, 'Argument for dev.flutter.pigeon.permission_handler_android.PackageManagerHostApi.hasSystemFeature was null, expected non-null String.'); - final bool output = api.hasSystemFeature(arg_instanceId!, arg_featureName!); + final bool output = + api.hasSystemFeature(arg_instanceId!, arg_featureName!); return [output]; }); } } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.PackageManagerHostApi.queryIntentActivitiesWithFlags', codec, + 'dev.flutter.pigeon.permission_handler_android.PackageManagerHostApi.queryIntentActivitiesWithFlags', + codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.permission_handler_android.PackageManagerHostApi.queryIntentActivitiesWithFlags was null.'); + 'Argument for dev.flutter.pigeon.permission_handler_android.PackageManagerHostApi.queryIntentActivitiesWithFlags was null.'); final List args = (message as List?)!; final String? arg_instanceId = (args[0] as String?); assert(arg_instanceId != null, @@ -790,21 +947,26 @@ abstract class PackageManagerTestHostApi { final int? arg_flags = (args[2] as int?); assert(arg_flags != null, 'Argument for dev.flutter.pigeon.permission_handler_android.PackageManagerHostApi.queryIntentActivitiesWithFlags was null, expected non-null int.'); - final List output = api.queryIntentActivitiesWithFlags(arg_instanceId!, arg_intentInstanceId!, arg_flags!); + final List output = api.queryIntentActivitiesWithFlags( + arg_instanceId!, arg_intentInstanceId!, arg_flags!); return [output]; }); } } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.PackageManagerHostApi.queryIntentActivitiesWithInfoFlags', codec, + 'dev.flutter.pigeon.permission_handler_android.PackageManagerHostApi.queryIntentActivitiesWithInfoFlags', + codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.permission_handler_android.PackageManagerHostApi.queryIntentActivitiesWithInfoFlags was null.'); + 'Argument for dev.flutter.pigeon.permission_handler_android.PackageManagerHostApi.queryIntentActivitiesWithInfoFlags was null.'); final List args = (message as List?)!; final String? arg_instanceId = (args[0] as String?); assert(arg_instanceId != null, @@ -815,7 +977,32 @@ abstract class PackageManagerTestHostApi { final String? arg_flagsInstanceId = (args[2] as String?); assert(arg_flagsInstanceId != null, 'Argument for dev.flutter.pigeon.permission_handler_android.PackageManagerHostApi.queryIntentActivitiesWithInfoFlags was null, expected non-null String.'); - final List output = api.queryIntentActivitiesWithInfoFlags(arg_instanceId!, arg_intentInstanceId!, arg_flagsInstanceId!); + final List output = api.queryIntentActivitiesWithInfoFlags( + arg_instanceId!, arg_intentInstanceId!, arg_flagsInstanceId!); + return [output]; + }); + } + } + { + final BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.permission_handler_android.PackageManagerHostApi.getSystemAvailableFeatures', + codec, + binaryMessenger: binaryMessenger); + if (api == null) { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); + } else { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.permission_handler_android.PackageManagerHostApi.getSystemAvailableFeatures was null.'); + final List args = (message as List?)!; + final String? arg_instanceId = (args[0] as String?); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.permission_handler_android.PackageManagerHostApi.getSystemAvailableFeatures was null, expected non-null String.'); + final List output = + api.getSystemAvailableFeatures(arg_instanceId!); return [output]; }); } @@ -831,7 +1018,8 @@ abstract class PackageManagerTestHostApi { /// /// See https://developer.android.com/reference/android/provider/Settings. abstract class SettingsTestHostApi { - static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => TestDefaultBinaryMessengerBinding.instance; + static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => + TestDefaultBinaryMessengerBinding.instance; static const MessageCodec codec = StandardMessageCodec(); /// Checks if the specified context can draw on top of other apps. @@ -846,17 +1034,22 @@ abstract class SettingsTestHostApi { /// See https://developer.android.com/reference/android/provider/Settings#canDrawOverlays(android.content.Context). bool canDrawOverlays(String contextInstanceId); - static void setup(SettingsTestHostApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(SettingsTestHostApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.SettingsHostApi.canDrawOverlays', codec, + 'dev.flutter.pigeon.permission_handler_android.SettingsHostApi.canDrawOverlays', + codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.permission_handler_android.SettingsHostApi.canDrawOverlays was null.'); + 'Argument for dev.flutter.pigeon.permission_handler_android.SettingsHostApi.canDrawOverlays was null.'); final List args = (message as List?)!; final String? arg_contextInstanceId = (args[0] as String?); assert(arg_contextInstanceId != null, @@ -877,7 +1070,8 @@ abstract class SettingsTestHostApi { /// /// See https://developer.android.com/reference/android/app/NotificationManager. abstract class NotificationManagerTestHostApi { - static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => TestDefaultBinaryMessengerBinding.instance; + static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => + TestDefaultBinaryMessengerBinding.instance; static const MessageCodec codec = StandardMessageCodec(); /// Checks the ability to modify notification do not disturb policy for the calling package. @@ -896,36 +1090,46 @@ abstract class NotificationManagerTestHostApi { /// See https://developer.android.com/reference/android/app/NotificationManager#areNotificationsEnabled(). bool areNotificationsEnabled(String instanceId); - static void setup(NotificationManagerTestHostApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(NotificationManagerTestHostApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.NotificationManagerHostApi.isNotificationPolicyAccessGranted', codec, + 'dev.flutter.pigeon.permission_handler_android.NotificationManagerHostApi.isNotificationPolicyAccessGranted', + codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.permission_handler_android.NotificationManagerHostApi.isNotificationPolicyAccessGranted was null.'); + 'Argument for dev.flutter.pigeon.permission_handler_android.NotificationManagerHostApi.isNotificationPolicyAccessGranted was null.'); final List args = (message as List?)!; final String? arg_instanceId = (args[0] as String?); assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.permission_handler_android.NotificationManagerHostApi.isNotificationPolicyAccessGranted was null, expected non-null String.'); - final bool output = api.isNotificationPolicyAccessGranted(arg_instanceId!); + final bool output = + api.isNotificationPolicyAccessGranted(arg_instanceId!); return [output]; }); } } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.NotificationManagerHostApi.areNotificationsEnabled', codec, + 'dev.flutter.pigeon.permission_handler_android.NotificationManagerHostApi.areNotificationsEnabled', + codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.permission_handler_android.NotificationManagerHostApi.areNotificationsEnabled was null.'); + 'Argument for dev.flutter.pigeon.permission_handler_android.NotificationManagerHostApi.areNotificationsEnabled was null.'); final List args = (message as List?)!; final String? arg_instanceId = (args[0] as String?); assert(arg_instanceId != null, @@ -946,7 +1150,8 @@ abstract class NotificationManagerTestHostApi { /// /// See https://developer.android.com/reference/android/os/Environment. abstract class EnvironmentTestHostApi { - static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => TestDefaultBinaryMessengerBinding.instance; + static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => + TestDefaultBinaryMessengerBinding.instance; static const MessageCodec codec = StandardMessageCodec(); /// Returns whether the calling app has All Files Access on the primary shared/external storage media. @@ -958,15 +1163,20 @@ abstract class EnvironmentTestHostApi { /// See https://developer.android.com/reference/android/os/Environment#isExternalStorageManager(). bool isExternalStorageManager(); - static void setup(EnvironmentTestHostApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(EnvironmentTestHostApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.EnvironmentHostApi.isExternalStorageManager', codec, + 'dev.flutter.pigeon.permission_handler_android.EnvironmentHostApi.isExternalStorageManager', + codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { // ignore message final bool output = api.isExternalStorageManager(); return [output]; @@ -984,7 +1194,8 @@ abstract class EnvironmentTestHostApi { /// /// See https://developer.android.com/reference/android/content/pm/PackageInfo. abstract class PackageInfoTestHostApi { - static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => TestDefaultBinaryMessengerBinding.instance; + static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => + TestDefaultBinaryMessengerBinding.instance; static const MessageCodec codec = StandardMessageCodec(); /// Array of all tags included under , or null if there were none. @@ -996,22 +1207,28 @@ abstract class PackageInfoTestHostApi { /// See https://developer.android.com/reference/android/content/pm/PackageInfo#requestedPermissions. List getRequestedPermissions(String instanceId); - static void setup(PackageInfoTestHostApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(PackageInfoTestHostApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.PackageInfoHostApi.getRequestedPermissions', codec, + 'dev.flutter.pigeon.permission_handler_android.PackageInfoHostApi.getRequestedPermissions', + codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.permission_handler_android.PackageInfoHostApi.getRequestedPermissions was null.'); + 'Argument for dev.flutter.pigeon.permission_handler_android.PackageInfoHostApi.getRequestedPermissions was null.'); final List args = (message as List?)!; final String? arg_instanceId = (args[0] as String?); assert(arg_instanceId != null, 'Argument for dev.flutter.pigeon.permission_handler_android.PackageInfoHostApi.getRequestedPermissions was null, expected non-null String.'); - final List output = api.getRequestedPermissions(arg_instanceId!); + final List output = + api.getRequestedPermissions(arg_instanceId!); return [output]; }); } @@ -1027,23 +1244,29 @@ abstract class PackageInfoTestHostApi { /// /// See https://developer.android.com/reference/android/content/pm/PackageManager#PackageInfoFlags. abstract class PackageInfoFlagsTestHostApi { - static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => TestDefaultBinaryMessengerBinding.instance; + static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => + TestDefaultBinaryMessengerBinding.instance; static const MessageCodec codec = StandardMessageCodec(); /// See https://developer.android.com/reference/android/content/pm/PackageManager.PackageInfoFlags#of(long). String of(int value); - static void setup(PackageInfoFlagsTestHostApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(PackageInfoFlagsTestHostApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.PackageInfoFlagsHostApi.of', codec, + 'dev.flutter.pigeon.permission_handler_android.PackageInfoFlagsHostApi.of', + codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.permission_handler_android.PackageInfoFlagsHostApi.of was null.'); + 'Argument for dev.flutter.pigeon.permission_handler_android.PackageInfoFlagsHostApi.of was null.'); final List args = (message as List?)!; final int? arg_value = (args[0] as int?); assert(arg_value != null, @@ -1064,23 +1287,29 @@ abstract class PackageInfoFlagsTestHostApi { /// /// See https://developer.android.com/reference/android/content/pm/PackageManager#ResolveInfoFlags. abstract class ResolveInfoFlagsTestHostApi { - static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => TestDefaultBinaryMessengerBinding.instance; + static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => + TestDefaultBinaryMessengerBinding.instance; static const MessageCodec codec = StandardMessageCodec(); /// See https://developer.android.com/reference/android/content/pm/PackageManager.ResolveInfoFlags#of(long). String of(int value); - static void setup(ResolveInfoFlagsTestHostApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(ResolveInfoFlagsTestHostApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.ResolveInfoFlagsHostApi.of', codec, + 'dev.flutter.pigeon.permission_handler_android.ResolveInfoFlagsHostApi.of', + codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.permission_handler_android.ResolveInfoFlagsHostApi.of was null.'); + 'Argument for dev.flutter.pigeon.permission_handler_android.ResolveInfoFlagsHostApi.of was null.'); final List args = (message as List?)!; final int? arg_value = (args[0] as int?); assert(arg_value != null, @@ -1101,23 +1330,29 @@ abstract class ResolveInfoFlagsTestHostApi { /// /// See https://developer.android.com/reference/android/content/pm/PackageManager#ApplicationInfoFlags. abstract class ApplicationInfoFlagsTestHostApi { - static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => TestDefaultBinaryMessengerBinding.instance; + static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => + TestDefaultBinaryMessengerBinding.instance; static const MessageCodec codec = StandardMessageCodec(); /// See https://developer.android.com/reference/android/content/pm/PackageManager.ApplicationInfoFlags#of(long). String of(int value); - static void setup(ApplicationInfoFlagsTestHostApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(ApplicationInfoFlagsTestHostApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.ApplicationInfoFlagsHostApi.of', codec, + 'dev.flutter.pigeon.permission_handler_android.ApplicationInfoFlagsHostApi.of', + codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.permission_handler_android.ApplicationInfoFlagsHostApi.of was null.'); + 'Argument for dev.flutter.pigeon.permission_handler_android.ApplicationInfoFlagsHostApi.of was null.'); final List args = (message as List?)!; final int? arg_value = (args[0] as int?); assert(arg_value != null, @@ -1138,23 +1373,29 @@ abstract class ApplicationInfoFlagsTestHostApi { /// /// See https://developer.android.com/reference/android/content/pm/PackageManager#ComponentInfoFlags. abstract class ComponentInfoFlagsTestHostApi { - static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => TestDefaultBinaryMessengerBinding.instance; + static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => + TestDefaultBinaryMessengerBinding.instance; static const MessageCodec codec = StandardMessageCodec(); /// See https://developer.android.com/reference/android/content/pm/PackageManager.ComponentInfoFlags#of(long). String of(int value); - static void setup(ComponentInfoFlagsTestHostApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(ComponentInfoFlagsTestHostApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.permission_handler_android.ComponentInfoFlagsHostApi.of', codec, + 'dev.flutter.pigeon.permission_handler_android.ComponentInfoFlagsHostApi.of', + codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.permission_handler_android.ComponentInfoFlagsHostApi.of was null.'); + 'Argument for dev.flutter.pigeon.permission_handler_android.ComponentInfoFlagsHostApi.of was null.'); final List args = (message as List?)!; final int? arg_value = (args[0] as int?); assert(arg_value != null, @@ -1166,3 +1407,371 @@ abstract class ComponentInfoFlagsTestHostApi { } } } + +/// 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. +abstract class TelephonyManagerTestHostApi { + static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => + TestDefaultBinaryMessengerBinding.instance; + static const MessageCodec codec = StandardMessageCodec(); + + /// 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(). + int getPhoneType(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). + int getSimState(String instanceId); + + static void setup(TelephonyManagerTestHostApi? api, + {BinaryMessenger? binaryMessenger}) { + { + final BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.permission_handler_android.TelephonyManagerHostApi.getPhoneType', + codec, + binaryMessenger: binaryMessenger); + if (api == null) { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); + } else { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.permission_handler_android.TelephonyManagerHostApi.getPhoneType was null.'); + final List args = (message as List?)!; + final String? arg_instanceId = (args[0] as String?); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.permission_handler_android.TelephonyManagerHostApi.getPhoneType was null, expected non-null String.'); + final int output = api.getPhoneType(arg_instanceId!); + return [output]; + }); + } + } + { + final BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.permission_handler_android.TelephonyManagerHostApi.getSimState', + codec, + binaryMessenger: binaryMessenger); + if (api == null) { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); + } else { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.permission_handler_android.TelephonyManagerHostApi.getSimState was null.'); + final List args = (message as List?)!; + final String? arg_instanceId = (args[0] as String?); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.permission_handler_android.TelephonyManagerHostApi.getSimState was null, expected non-null String.'); + final int output = api.getSimState(arg_instanceId!); + return [output]; + }); + } + } + } +} + +/// 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. +abstract class LocationManagerTestHostApi { + static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => + TestDefaultBinaryMessengerBinding.instance; + static const MessageCodec codec = StandardMessageCodec(); + + /// Returns the current enabled/disabled status of location updates. + /// + /// See https://developer.android.com/reference/android/location/LocationManager#isLocationEnabled(). + bool isLocationEnabled(String instanceId); + + static void setup(LocationManagerTestHostApi? api, + {BinaryMessenger? binaryMessenger}) { + { + final BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.permission_handler_android.LocationManagerHostApi.isLocationEnabled', + codec, + binaryMessenger: binaryMessenger); + if (api == null) { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); + } else { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.permission_handler_android.LocationManagerHostApi.isLocationEnabled was null.'); + final List args = (message as List?)!; + final String? arg_instanceId = (args[0] as String?); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.permission_handler_android.LocationManagerHostApi.isLocationEnabled was null, expected non-null String.'); + final bool output = api.isLocationEnabled(arg_instanceId!); + return [output]; + }); + } + } + } +} + +/// 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. +abstract class BluetoothAdapterTestHostApi { + static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => + TestDefaultBinaryMessengerBinding.instance; + static const MessageCodec codec = StandardMessageCodec(); + + /// 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(). + 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(). + bool isEnabled(String instanceId); + + static void setup(BluetoothAdapterTestHostApi? api, + {BinaryMessenger? binaryMessenger}) { + { + final BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.permission_handler_android.BluetoothAdapterHostApi.getDefaultAdapter', + codec, + binaryMessenger: binaryMessenger); + if (api == null) { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); + } else { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { + // ignore message + final String output = api.getDefaultAdapter(); + return [output]; + }); + } + } + { + final BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.permission_handler_android.BluetoothAdapterHostApi.isEnabled', + codec, + binaryMessenger: binaryMessenger); + if (api == null) { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); + } else { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.permission_handler_android.BluetoothAdapterHostApi.isEnabled was null.'); + final List args = (message as List?)!; + final String? arg_instanceId = (args[0] as String?); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.permission_handler_android.BluetoothAdapterHostApi.isEnabled was null, expected non-null String.'); + final bool output = api.isEnabled(arg_instanceId!); + return [output]; + }); + } + } + } +} + +/// 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. +abstract class BluetoothManagerTestHostApi { + static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => + TestDefaultBinaryMessengerBinding.instance; + static const MessageCodec codec = StandardMessageCodec(); + + /// Get the BLUETOOTH Adapter for this device. + /// + /// See https://developer.android.com/reference/android/bluetooth/BluetoothManager#getAdapter(). + String getAdapter(String instanceId); + + static void setup(BluetoothManagerTestHostApi? api, + {BinaryMessenger? binaryMessenger}) { + { + final BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.permission_handler_android.BluetoothManagerHostApi.getAdapter', + codec, + binaryMessenger: binaryMessenger); + if (api == null) { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); + } else { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.permission_handler_android.BluetoothManagerHostApi.getAdapter was null.'); + final List args = (message as List?)!; + final String? arg_instanceId = (args[0] as String?); + assert(arg_instanceId != null, + 'Argument for dev.flutter.pigeon.permission_handler_android.BluetoothManagerHostApi.getAdapter was null, expected non-null String.'); + final String output = api.getAdapter(arg_instanceId!); + return [output]; + }); + } + } + } +} + +abstract class ContentResolverTestHostApi { + static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => + TestDefaultBinaryMessengerBinding.instance; + static const MessageCodec codec = StandardMessageCodec(); + + /// 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). + int? getInt(String contentResolverInstanceId, 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). + int getIntWithDefault( + String contentResolverInstanceId, String name, int 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). + String? getString(String contentResolverInstanceId, String name); + + static void setup(ContentResolverTestHostApi? api, + {BinaryMessenger? binaryMessenger}) { + { + final BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.permission_handler_android.SettingsSecureHostApi.getInt', + codec, + binaryMessenger: binaryMessenger); + if (api == null) { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); + } else { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.permission_handler_android.SettingsSecureHostApi.getInt was null.'); + final List args = (message as List?)!; + final String? arg_contentResolverInstanceId = (args[0] as String?); + assert(arg_contentResolverInstanceId != null, + 'Argument for dev.flutter.pigeon.permission_handler_android.SettingsSecureHostApi.getInt was null, expected non-null String.'); + final String? arg_name = (args[1] as String?); + assert(arg_name != null, + 'Argument for dev.flutter.pigeon.permission_handler_android.SettingsSecureHostApi.getInt was null, expected non-null String.'); + final int? output = + api.getInt(arg_contentResolverInstanceId!, arg_name!); + return [output]; + }); + } + } + { + final BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.permission_handler_android.SettingsSecureHostApi.getIntWithDefault', + codec, + binaryMessenger: binaryMessenger); + if (api == null) { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); + } else { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.permission_handler_android.SettingsSecureHostApi.getIntWithDefault was null.'); + final List args = (message as List?)!; + final String? arg_contentResolverInstanceId = (args[0] as String?); + assert(arg_contentResolverInstanceId != null, + 'Argument for dev.flutter.pigeon.permission_handler_android.SettingsSecureHostApi.getIntWithDefault was null, expected non-null String.'); + final String? arg_name = (args[1] as String?); + assert(arg_name != null, + 'Argument for dev.flutter.pigeon.permission_handler_android.SettingsSecureHostApi.getIntWithDefault was null, expected non-null String.'); + final int? arg_defaultValue = (args[2] as int?); + assert(arg_defaultValue != null, + 'Argument for dev.flutter.pigeon.permission_handler_android.SettingsSecureHostApi.getIntWithDefault was null, expected non-null int.'); + final int output = api.getIntWithDefault( + arg_contentResolverInstanceId!, arg_name!, arg_defaultValue!); + return [output]; + }); + } + } + { + final BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.permission_handler_android.SettingsSecureHostApi.getString', + codec, + binaryMessenger: binaryMessenger); + if (api == null) { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); + } else { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.permission_handler_android.SettingsSecureHostApi.getString was null.'); + final List args = (message as List?)!; + final String? arg_contentResolverInstanceId = (args[0] as String?); + assert(arg_contentResolverInstanceId != null, + 'Argument for dev.flutter.pigeon.permission_handler_android.SettingsSecureHostApi.getString was null, expected non-null String.'); + final String? arg_name = (args[1] as String?); + assert(arg_name != null, + 'Argument for dev.flutter.pigeon.permission_handler_android.SettingsSecureHostApi.getString was null, expected non-null String.'); + final String? output = + api.getString(arg_contentResolverInstanceId!, arg_name!); + return [output]; + }); + } + } + } +}