0

I am trying to update a mobile app I am working on without additional user input. The app is supposed to run without any users having access to the device and I need a way to update it. Since it will run on dozens of devices at once, just manually swapping it out is sadly not an option, as is making use of the PlayStore.

So far I have this code that allows me to initiate the update, but the user still needs to confirm it each time.

procedure TForm1.StartActivityA(const AFileName: string);
var
  Intent: JIntent;
  Data: Jnet_Uri;
begin
  try
    Intent := TJIntent.Create;
    Intent.setAction(TJIntent.JavaClass.ACTION_VIEW);

    Intent.setFlags(TJIntent.JavaClass.FLAG_GRANT_READ_URI_PERMISSION);

    Data := TAndroidHelper.JFileToJURI(TJFile.JavaClass.init(StringToJString(AFileName)));
    Intent.setDataAndType(Data, StringToJString('application/vnd.android.package-archive'));

    TAndroidHelper.Activity.startActivity(Intent);
  except
    on E: Exception do
    begin
      TDialogService.ShowMessage(e.message);
    end;
  end;
end;

Since the devices the app is supposed to run on won't be accessible for user input, I am searching for a solution that allows me to do what I described (preferable while also closing and restarting the app, but I haven't gotten that far yet. Any pointers towards that would also be appreciated).

I found this post and this post about installing/updating an app on Android silently, but I can't figure out how to execute the commands in Delphi code. This one makes it look like it might be possible to do it with the code I have now, if the device is rooted, but I am not sure I understand it correctly.

And as far as I understand it, executing commands like this requires the device to be rooted. Is that correct?

Is this the correct approach or is there another one (ideally without the need to root the device, but I can manage, if there is no other way)?

This is the prompt I want to avoid: Confirmation prompt

  • [Android Enterprise Management](https://www.android.com/enterprise/management/) has some things that might be of interest. – Brian Mar 10 '22 at 17:22
  • If I understand it correctly, every device I want to update would need an account to be managed with that. While that looks very interesting for other projects, I am afraid it is not practical here, because the devices will only be used to run the app and setting up dozens or hundreds of accounts seems a bit excessive. Thank you for the pointer, though. I will look into it more closely as a fallback. – Nils Eilers Mar 11 '22 at 09:15
  • A collegue mentioned switching out the so-file to update the app as a possible alternative, but couldn't get into more detail. Might that be an option? I have never messed with so-files directly. How would I go about doing it that way? – Nils Eilers Mar 14 '22 at 08:14
  • I got to a point where I am trying to replace the so-file in the data/app/com.myapp/lib/arm directory, but can't figure out how to get the required permission when doing it from my Delphi app. I was able to replace the files with Total Commander so my thinking is, that there is some way to get the permission to do it with any map. Or does Total Commander function differently in that regard? – Nils Eilers Mar 16 '22 at 12:15

0 Answers0