Modifying the Form of an already created Component

I am trying to modify the Form on the Component provided by the user:

  public void InitialiseTest(Component component) throws NoSuchFieldException, IllegalAccessException {
    Field field = getName("form", component);

    FForm fForm = new FForm();

    field.set(component, fForm);

I am changing the Form field and assigning it an Extended Form to get control over the methods any method calls on the form.

I am changing the value field superclass in the AndroidNonVisible component as its extended.

I managed to do it very well. But this doesn't work on the companion especially for components like Player. It failed to set the source once the form has been changed.

I looked into the sources for some time, I found that it's a loading source from the MediaUtil. It determines the source type. What I was provided was a Form and not ReplForm which was for the companion (as it was just a form, it tried to load files from the app's assets). It checks if the form is an instance of the reply form and also checks if the assets are loaded.

I needed to change the Form to ReplForm and also return true when isAssetsLoaded are called. This time I get no logged error from any MediaUtil but the Player fails to set the source.

I think the issue is of the isAssetsLoaded method as it's always true.
I assume the assets are not loaded. So how is it supposed to be loaded?

processExtrasAndData is called with intent but I don't understand it.
I'm also calling the super.onCreate.

07-30 23:39:30.283 15605 15605 E Form    : Form null ErrorOccurred, errorNumber = 701, componentType = Player, functionName = Source, messages = Unable to load song.mp3.
        mediaPlayer.setDataSource(form.getAssetPath(mediaPath)); // <<---- error
1 Like

Hi @Ewpatton, sorry to mention you, do you know what the problem is?

If this condition is not met then source will not get set.
That's the problem probably.

I guess permissions are already allowed? Do I need to also override that?

Maybe you should remove unnecessary assertions.

I don't think that's the problem because the below line gets executed and an error occurs:

Them check the file path.

I've checked that many times.

The asset name works but throws an error when I modify the form.