I am trying to modify the Form on the Component provided by the user:
@SimpleFunction
public void InitialiseTest(Component component) throws NoSuchFieldException, IllegalAccessException {
Field field = getName("form", component);
field.setAccessible(true);
FForm fForm = new FForm();
fForm.init(activity);
field.set(component, fForm);
TestLoad();
}
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.
case REPL_ASSET:
form.assertPermission(READ_EXTERNAL_STORAGE);
mediaPlayer.setDataSource(form.getAssetPath(mediaPath)); // <<---- error
return;