@@ -46,9 +46,11 @@ TADBService = class(TInterfacedObject, IADBServices)
46
46
procedure RunSubprocess (const ACmd: string; const AArgs, AEnvVars: TArray<string>);
47
47
48
48
// File helpers
49
- function SendFile (const ALocalFilePath, ARemoteFilePath: string): boolean;
49
+ function SendFile (const ALocalFilePath, ARemoteFilePath: string): boolean; overload;
50
50
procedure RemoveFile (const ARemoteFilePath: string);
51
51
function ExtractZip (const ARemoteFilePath, ARemoteDir: string): boolean;
52
+ // File helper for apps
53
+ function SendFile (const APackageName, ALocalFilePath, ARemoteFilePath: string): boolean; overload;
52
54
// Folder helpers
53
55
function CreateDirectory (const ARemoteDir: string): boolean;
54
56
procedure DeleteDirectory (const ARemoteDir: string);
@@ -74,7 +76,8 @@ implementation
74
76
75
77
uses
76
78
System.SyncObjs,
77
- Builder.Exception;
79
+ Builder.Exception,
80
+ Builder.Paths;
78
81
79
82
{ TADBService }
80
83
@@ -94,6 +97,34 @@ function TADBService.GetActiveDevice: string;
94
97
Result := FActiveDevice;
95
98
end ;
96
99
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
+
97
128
procedure TADBService.SetActiveDevice (const ADeviceName: string);
98
129
begin
99
130
FActiveDevice := ADeviceName;
0 commit comments