Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
51d4ab33
Commit
51d4ab33
authored
May 27, 2016
by
Todd Volkert
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix install for iOS simulator, and add ability to uninstall (#4223)
parent
1a05b696
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
86 additions
and
36 deletions
+86
-36
android_device.dart
packages/flutter_tools/lib/src/android/android_device.dart
+16
-0
drive.dart
packages/flutter_tools/lib/src/commands/drive.dart
+2
-0
install.dart
packages/flutter_tools/lib/src/commands/install.dart
+5
-2
device.dart
packages/flutter_tools/lib/src/device.dart
+6
-3
devices.dart
packages/flutter_tools/lib/src/ios/devices.dart
+27
-13
simulators.dart
packages/flutter_tools/lib/src/ios/simulators.dart
+30
-18
No files found.
packages/flutter_tools/lib/src/android/android_device.dart
View file @
51d4ab33
...
...
@@ -232,6 +232,22 @@ class AndroidDevice extends Device {
return
true
;
}
@override
bool
uninstallApp
(
ApplicationPackage
app
)
{
if
(!
_checkForSupportedAdbVersion
()
||
!
_checkForSupportedAndroidVersion
())
return
false
;
String
uninstallOut
=
runCheckedSync
(
adbCommandForDevice
(<
String
>[
'uninstall'
,
app
.
id
]));
RegExp
failureExp
=
new
RegExp
(
r'^Failure.*$'
,
multiLine:
true
);
String
failure
=
failureExp
.
stringMatch
(
uninstallOut
);
if
(
failure
!=
null
)
{
printError
(
'Package uninstall error:
$failure
'
);
return
false
;
}
return
true
;
}
Future
<
Null
>
_forwardPort
(
String
service
,
int
devicePort
,
int
port
)
async
{
try
{
// Set up port forwarding for observatory.
...
...
packages/flutter_tools/lib/src/commands/drive.dart
View file @
51d4ab33
...
...
@@ -274,6 +274,8 @@ Future<int> startApp(DriveCommand command) async {
printTrace
(
'Installing application package.'
);
ApplicationPackage
package
=
command
.
applicationPackages
.
getPackageForPlatform
(
command
.
device
.
platform
);
if
(
command
.
device
.
isAppInstalled
(
package
))
command
.
device
.
uninstallApp
(
package
);
command
.
device
.
installApp
(
package
);
Map
<
String
,
dynamic
>
platformArgs
=
<
String
,
dynamic
>{};
...
...
packages/flutter_tools/lib/src/commands/install.dart
View file @
51d4ab33
...
...
@@ -34,8 +34,11 @@ bool installApp(Device device, ApplicationPackage package) {
if
(
package
==
null
)
return
false
;
if
(
device
.
isAppInstalled
(
package
))
return
true
;
if
(
device
.
isAppInstalled
(
package
))
{
printStatus
(
'Uninstalling old version...'
);
if
(!
device
.
uninstallApp
(
package
))
printError
(
'Warning: uninstalling old version failed'
);
}
return
device
.
installApp
(
package
);
}
packages/flutter_tools/lib/src/device.dart
View file @
51d4ab33
...
...
@@ -149,9 +149,15 @@ abstract class Device {
/// Whether it is an emulated device running on localhost.
bool
get
isLocalEmulator
;
/// Check if a version of the given app is already installed
bool
isAppInstalled
(
ApplicationPackage
app
);
/// Install an app package on the current device
bool
installApp
(
ApplicationPackage
app
);
/// Uninstall an app package from the current device
bool
uninstallApp
(
ApplicationPackage
app
);
/// Check if the device is supported by Flutter
bool
isSupported
();
...
...
@@ -159,9 +165,6 @@ abstract class Device {
// supported by Flutter, and, if not, why.
String
supportMessage
()
=>
isSupported
()
?
"Supported"
:
"Unsupported"
;
/// Check if the current version of the given app is already installed
bool
isAppInstalled
(
ApplicationPackage
app
);
TargetPlatform
get
platform
;
/// Get the log reader for this device.
...
...
packages/flutter_tools/lib/src/ios/devices.dart
View file @
51d4ab33
...
...
@@ -124,11 +124,12 @@ class IOSDevice extends Device {
}
@override
bool
i
nstallApp
(
ApplicationPackage
app
)
{
bool
i
sAppInstalled
(
ApplicationPackage
app
)
{
try
{
IOSApp
iosApp
=
app
;
runCheckedSync
(<
String
>[
installerPath
,
'-i'
,
iosApp
.
deviceBundlePath
]);
return
true
;
String
apps
=
runCheckedSync
(<
String
>[
installerPath
,
'--list-apps'
]);
if
(
new
RegExp
(
app
.
id
,
multiLine:
true
).
hasMatch
(
apps
))
{
return
true
;
}
}
catch
(
e
)
{
return
false
;
}
...
...
@@ -136,21 +137,35 @@ class IOSDevice extends Device {
}
@override
bool
isSupported
()
=>
true
;
bool
installApp
(
ApplicationPackage
app
)
{
IOSApp
iosApp
=
app
;
Directory
bundle
=
new
Directory
(
iosApp
.
deviceBundlePath
);
if
(!
bundle
.
existsSync
())
{
printError
(
"Could not find application bundle at
${bundle.path}
; have you run 'flutter build ios'?"
);
return
false
;
}
try
{
runCheckedSync
(<
String
>[
installerPath
,
'-i'
,
iosApp
.
deviceBundlePath
]);
return
true
;
}
catch
(
e
)
{
return
false
;
}
}
@override
bool
isAppInstalled
(
ApplicationPackage
app
)
{
bool
uninstallApp
(
ApplicationPackage
app
)
{
try
{
String
apps
=
runCheckedSync
(<
String
>[
installerPath
,
'--list-apps'
]);
if
(
new
RegExp
(
app
.
id
,
multiLine:
true
).
hasMatch
(
apps
))
{
return
true
;
}
runCheckedSync
(<
String
>[
installerPath
,
'-U'
,
app
.
id
]);
return
true
;
}
catch
(
e
)
{
return
false
;
}
return
false
;
}
@override
bool
isSupported
()
=>
true
;
@override
Future
<
LaunchResult
>
startApp
(
ApplicationPackage
app
,
...
...
@@ -174,8 +189,7 @@ class IOSDevice extends Device {
// Step 2: Check that the application exists at the specified path.
IOSApp
iosApp
=
app
;
Directory
bundle
=
new
Directory
(
iosApp
.
deviceBundlePath
);
bool
bundleExists
=
bundle
.
existsSync
();
if
(!
bundleExists
)
{
if
(!
bundle
.
existsSync
())
{
printError
(
'Could not find the built application bundle at
${bundle.path}
.'
);
return
new
LaunchResult
.
failed
();
}
...
...
packages/flutter_tools/lib/src/ios/simulators.dart
View file @
51d4ab33
...
...
@@ -274,10 +274,24 @@ class SimControl {
bool
_isAnyConnected
()
=>
getConnectedDevices
().
isNotEmpty
;
bool
isInstalled
(
String
appId
)
{
return
exitsHappy
(<
String
>[
_xcrunPath
,
'simctl'
,
'get_app_container'
,
'booted'
,
appId
,
]);
}
void
install
(
String
deviceId
,
String
appPath
)
{
runCheckedSync
(<
String
>[
_xcrunPath
,
'simctl'
,
'install'
,
deviceId
,
appPath
]);
}
void
uninstall
(
String
deviceId
,
String
appId
)
{
runCheckedSync
(<
String
>[
_xcrunPath
,
'simctl'
,
'uninstall'
,
deviceId
,
appId
]);
}
void
launch
(
String
deviceId
,
String
appIdentifier
,
[
List
<
String
>
launchArgs
])
{
List
<
String
>
args
=
<
String
>[
_xcrunPath
,
'simctl'
,
'launch'
,
deviceId
,
appIdentifier
];
if
(
launchArgs
!=
null
)
...
...
@@ -361,6 +375,11 @@ class IOSSimulator extends Device {
return
path
.
join
(
simulatorPath
,
'data'
);
}
@override
bool
isAppInstalled
(
ApplicationPackage
app
)
{
return
SimControl
.
instance
.
isInstalled
(
app
.
id
);
}
@override
bool
installApp
(
ApplicationPackage
app
)
{
try
{
...
...
@@ -372,6 +391,16 @@ class IOSSimulator extends Device {
}
}
@override
bool
uninstallApp
(
ApplicationPackage
app
)
{
try
{
SimControl
.
instance
.
uninstall
(
id
,
app
.
id
);
return
true
;
}
catch
(
e
)
{
return
false
;
}
}
@override
bool
isSupported
()
{
if
(!
Platform
.
isMacOS
)
{
...
...
@@ -423,17 +452,6 @@ class IOSSimulator extends Device {
return
_supportMessage
!=
null
?
_supportMessage
:
"Unknown"
;
}
@override
bool
isAppInstalled
(
ApplicationPackage
app
)
{
try
{
// TODO(tvolkert): This logic is wrong; simulatorHomeDirectory always exists
String
simulatorHomeDirectory
=
_getSimulatorAppHomeDirectory
(
app
);
return
FileSystemEntity
.
isDirectorySync
(
simulatorHomeDirectory
);
}
catch
(
e
)
{
return
false
;
}
}
@override
Future
<
LaunchResult
>
startApp
(
ApplicationPackage
app
,
...
...
@@ -505,13 +523,7 @@ class IOSSimulator extends Device {
}
bool
_applicationIsInstalledAndRunning
(
ApplicationPackage
app
)
{
bool
isInstalled
=
exitsHappy
(<
String
>[
'xcrun'
,
'simctl'
,
'get_app_container'
,
'booted'
,
app
.
id
,
]);
bool
isInstalled
=
isAppInstalled
(
app
);
bool
isRunning
=
exitsHappy
(<
String
>[
'/usr/bin/killall'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment