Skip to content

Commit 2c4b6e0

Browse files
committed
Send files to the app folder
1 parent 2031753 commit 2c4b6e0

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

source/services/Builder.Services.ADB.pas

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,11 @@ TADBService = class(TInterfacedObject, IADBServices)
4646
procedure RunSubprocess(const ACmd: string; const AArgs, AEnvVars: TArray<string>);
4747

4848
//File helpers
49-
function SendFile(const ALocalFilePath, ARemoteFilePath: string): boolean;
49+
function SendFile(const ALocalFilePath, ARemoteFilePath: string): boolean; overload;
5050
procedure RemoveFile(const ARemoteFilePath: string);
5151
function ExtractZip(const ARemoteFilePath, ARemoteDir: string): boolean;
52+
//File helper for apps
53+
function SendFile(const APackageName, ALocalFilePath, ARemoteFilePath: string): boolean; overload;
5254
//Folder helpers
5355
function CreateDirectory(const ARemoteDir: string): boolean;
5456
procedure DeleteDirectory(const ARemoteDir: string);
@@ -74,7 +76,8 @@ implementation
7476

7577
uses
7678
System.SyncObjs,
77-
Builder.Exception;
79+
Builder.Exception,
80+
Builder.Paths;
7881

7982
{ TADBService }
8083

@@ -94,6 +97,34 @@ function TADBService.GetActiveDevice: string;
9497
Result := FActiveDevice;
9598
end;
9699

100+
function TADBService.SendFile(const APackageName, ALocalFilePath,
101+
ARemoteFilePath: string): boolean;
102+
begin
103+
Result := ExecCmd(GetEnvironment().AdbLocation, [
104+
'-s',
105+
GetActiveDevice(),
106+
'push',
107+
ALocalFilePath,
108+
TBuilderRemotePaths.GetTmpPath()],
109+
[]) = EXIT_SUCCESS;
110+
111+
if not Result then
112+
Exit;
113+
114+
var LTmpFilePath := TBuilderRemotePaths.GetTmpPath() + '/' + TPath.GetFileName(ALocalFilePath);
115+
var LAppFilePath := TBuilderRemotePaths.GetAppFilesPath(APackageName) + '/'+ ARemoteFilePath;
116+
117+
Result := ExecCmd(GetEnvironment().AdbLocation, [
118+
'-s',
119+
GetActiveDevice(),
120+
'exec-out',
121+
Format('run-as %s', [APackageName]),
122+
'cp',
123+
LTmpFilePath,
124+
LAppFilePath],
125+
[]) = EXIT_SUCCESS;
126+
end;
127+
97128
procedure TADBService.SetActiveDevice(const ADeviceName: string);
98129
begin
99130
FActiveDevice := ADeviceName;

0 commit comments

Comments
 (0)