private (Java_Object[], Java_Object) GetConstructorArgs(Context context)
    {
        if (Build.VERSION.SdkInt > BuildVersionCodes.P)
        {
            return(null, null);
        }

        if (_constructorArgsField == null)
        {
            _constructorArgsField = Java_Class.FromType(typeof(LayoutInflater)).GetDeclaredField("mConstructorArgs");

            _constructorArgsField.Accessible = true;
        }

        var constructorArgs = (Java_Object[])_constructorArgsField.Get(this);

        Java_Object previousContext = null;

        if (constructorArgs != null)
        {
            previousContext = constructorArgs?[0];

            constructorArgs[0] = context;

            _constructorArgsField.Set(this, constructorArgs);
        }

        return(constructorArgs, previousContext);
    }
Beispiel #2
0
        void GetFrontSizes()
        {
            CameraManager manager = (CameraManager)Context.GetSystemService(Context.CameraService);

            CameraCharacteristics characteristics = manager.GetCameraCharacteristics(frontCameraId);

            StreamConfigurationMap map = (StreamConfigurationMap)characteristics.Get(CameraCharacteristics.ScalerStreamConfigurationMap);

            frontCameraSizes = map.GetOutputSizes(Class.FromType(typeof(SurfaceTexture)));
        }
    private void SetPrivateFactory()
    {
        // LayoutInflater in Android versions greater than Honeycomb uses a private factory.
        // Make sure that our custom layout inflater uses our private factory.

        if (!_hasSetPrivateFactory && InterceptingService.PrivateFactoryInjection)
        {
            if (Context is IFactory2 factory2)
            {
                var setPrivateFactoryMethod = Java_Class.FromType(typeof(LayoutInflater)).GetMethod("setPrivateFactory", Java_Class.FromType(typeof(IFactory2)));

                setPrivateFactoryMethod.Accessible = true;

                setPrivateFactoryMethod.TryInvoke(this, new PrivateViewPumpFactory2(factory2, this));
            }

            _hasSetPrivateFactory = true;
        }
    }