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
54326885
Unverified
Commit
54326885
authored
Dec 22, 2021
by
Jenn Magder
Committed by
GitHub
Dec 22, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate install command to null safety (#95433)
parent
8e9bca80
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
39 additions
and
43 deletions
+39
-43
android_device.dart
packages/flutter_tools/lib/src/android/android_device.dart
+9
-8
application_package.dart
packages/flutter_tools/lib/src/application_package.dart
+3
-3
install.dart
packages/flutter_tools/lib/src/commands/install.dart
+13
-13
device.dart
packages/flutter_tools/lib/src/device.dart
+1
-1
flutter_application_package.dart
...es/flutter_tools/lib/src/flutter_application_package.dart
+8
-13
application_package.dart
packages/flutter_tools/lib/src/ios/application_package.dart
+2
-2
xcode_project.dart
packages/flutter_tools/lib/src/xcode_project.dart
+2
-2
mac_test.dart
packages/flutter_tools/test/general.shard/ios/mac_test.dart
+1
-1
No files found.
packages/flutter_tools/lib/src/android/android_device.dart
View file @
54326885
...
...
@@ -543,6 +543,7 @@ class AndroidDevice extends Device {
return
LaunchResult
.
failed
();
}
AndroidApk
?
builtPackage
=
package
;
AndroidArch
androidArch
;
switch
(
devicePlatform
)
{
case
TargetPlatform
.
android_arm
:
...
...
@@ -587,18 +588,18 @@ class AndroidDevice extends Device {
);
// Package has been built, so we can get the updated application ID and
// activity name from the .apk.
p
ackage
=
await
ApplicationPackageFactory
.
instance
!
.
getPackageForPlatform
(
devicePlatform
,
buildInfo:
debuggingOptions
.
buildInfo
)
as
AndroidApk
;
builtP
ackage
=
await
ApplicationPackageFactory
.
instance
!
.
getPackageForPlatform
(
devicePlatform
,
buildInfo:
debuggingOptions
.
buildInfo
)
as
AndroidApk
?
;
}
// There was a failure parsing the android project information.
if
(
p
ackage
==
null
)
{
if
(
builtP
ackage
==
null
)
{
throwToolExit
(
'Problem building Android application: see above error(s).'
);
}
_logger
.
printTrace
(
"Stopping app '
${
p
ackage.name}
' on
$name
."
);
await
stopApp
(
p
ackage
,
userIdentifier:
userIdentifier
);
_logger
.
printTrace
(
"Stopping app '
${
builtP
ackage.name}
' on
$name
."
);
await
stopApp
(
builtP
ackage
,
userIdentifier:
userIdentifier
);
if
(!
await
installApp
(
p
ackage
,
userIdentifier:
userIdentifier
))
{
if
(!
await
installApp
(
builtP
ackage
,
userIdentifier:
userIdentifier
))
{
return
LaunchResult
.
failed
();
}
...
...
@@ -672,7 +673,7 @@ class AndroidDevice extends Device {
if
(
userIdentifier
!=
null
)
...<
String
>[
'--user'
,
userIdentifier
],
],
p
ackage
.
launchActivity
,
builtP
ackage
.
launchActivity
,
];
final
String
result
=
(
await
runAdbCheckedAsync
(
cmd
)).
stdout
;
// This invocation returns 0 even when it fails.
...
...
@@ -681,7 +682,7 @@ class AndroidDevice extends Device {
return
LaunchResult
.
failed
();
}
_package
=
p
ackage
;
_package
=
builtP
ackage
;
if
(!
debuggingOptions
.
debuggingEnabled
)
{
return
LaunchResult
.
succeeded
();
}
...
...
packages/flutter_tools/lib/src/application_package.dart
View file @
54326885
...
...
@@ -10,10 +10,10 @@ abstract class ApplicationPackageFactory {
static
ApplicationPackageFactory
?
get
instance
=>
context
.
get
<
ApplicationPackageFactory
>();
/// Create an [ApplicationPackage] for the given platform.
Future
<
ApplicationPackage
>
getPackageForPlatform
(
Future
<
ApplicationPackage
?
>
getPackageForPlatform
(
TargetPlatform
platform
,
{
BuildInfo
buildInfo
,
File
applicationBinary
,
BuildInfo
?
buildInfo
,
File
?
applicationBinary
,
});
}
...
...
packages/flutter_tools/lib/src/commands/install.dart
View file @
54326885
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'../android/android_device.dart'
;
import
'../application_package.dart'
;
import
'../base/common.dart'
;
...
...
@@ -18,8 +16,6 @@ class InstallCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts
usesDeviceUserOption
();
usesDeviceTimeoutOption
();
argParser
.
addFlag
(
'uninstall-only'
,
negatable:
true
,
defaultsTo:
false
,
help:
'Uninstall the app if already on the device. Skip install.'
,
);
}
...
...
@@ -33,10 +29,10 @@ class InstallCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts
@override
final
String
category
=
FlutterCommandCategory
.
tools
;
Device
device
;
Device
?
device
;
bool
get
uninstallOnly
=>
boolArg
(
'uninstall-only'
);
String
get
userIdentifier
=>
stringArg
(
FlutterOptions
.
kDeviceUser
);
String
?
get
userIdentifier
=>
stringArg
(
FlutterOptions
.
kDeviceUser
);
@override
Future
<
void
>
validateCommand
()
async
{
...
...
@@ -52,19 +48,23 @@ class InstallCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts
@override
Future
<
FlutterCommandResult
>
runCommand
()
async
{
final
ApplicationPackage
package
=
await
applicationPackages
.
getPackageForPlatform
(
await
device
.
targetPlatform
,
final
Device
targetDevice
=
device
!;
final
ApplicationPackage
?
package
=
await
applicationPackages
?.
getPackageForPlatform
(
await
targetDevice
.
targetPlatform
,
);
if
(
package
==
null
)
{
throwToolExit
(
'Could not find or build package'
);
}
if
(
uninstallOnly
)
{
await
_uninstallApp
(
package
);
await
_uninstallApp
(
package
,
targetDevice
);
}
else
{
await
_installApp
(
package
);
await
_installApp
(
package
,
targetDevice
);
}
return
FlutterCommandResult
.
success
();
}
Future
<
void
>
_uninstallApp
(
ApplicationPackage
package
)
async
{
Future
<
void
>
_uninstallApp
(
ApplicationPackage
package
,
Device
device
)
async
{
if
(
await
device
.
isAppInstalled
(
package
,
userIdentifier:
userIdentifier
))
{
globals
.
printStatus
(
'Uninstalling
$package
from
$device
...'
);
if
(!
await
device
.
uninstallApp
(
package
,
userIdentifier:
userIdentifier
))
{
...
...
@@ -75,7 +75,7 @@ class InstallCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts
}
}
Future
<
void
>
_installApp
(
ApplicationPackage
package
)
async
{
Future
<
void
>
_installApp
(
ApplicationPackage
package
,
Device
device
)
async
{
globals
.
printStatus
(
'Installing
$package
to
$device
...'
);
if
(!
await
installApp
(
device
,
package
,
userIdentifier:
userIdentifier
))
{
...
...
@@ -87,7 +87,7 @@ class InstallCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts
Future
<
bool
>
installApp
(
Device
device
,
ApplicationPackage
package
,
{
String
userIdentifier
,
String
?
userIdentifier
,
bool
uninstall
=
true
})
async
{
if
(
package
==
null
)
{
...
...
packages/flutter_tools/lib/src/device.dart
View file @
54326885
...
...
@@ -490,7 +490,7 @@ abstract class Device {
/// Specify [userIdentifier] to check if installed for a particular user (Android only).
Future
<
bool
>
isAppInstalled
(
covariant
ApplicationPackage
app
,
{
String
userIdentifier
,
String
?
userIdentifier
,
});
/// Check if the latest build of the [app] is already installed.
...
...
packages/flutter_tools/lib/src/flutter_application_package.dart
View file @
54326885
...
...
@@ -2,9 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:meta/meta.dart'
;
import
'package:process/process.dart'
;
import
'android/android_sdk.dart'
;
...
...
@@ -28,11 +25,11 @@ import 'windows/application_package.dart';
/// A package factory that supports all Flutter target platforms.
class
FlutterApplicationPackageFactory
extends
ApplicationPackageFactory
{
FlutterApplicationPackageFactory
({
@
required
AndroidSdk
androidSdk
,
@
required
ProcessManager
processManager
,
@
required
Logger
logger
,
@
required
UserMessages
userMessages
,
@
required
FileSystem
fileSystem
,
required
AndroidSdk
androidSdk
,
required
ProcessManager
processManager
,
required
Logger
logger
,
required
UserMessages
userMessages
,
required
FileSystem
fileSystem
,
})
:
_androidSdk
=
androidSdk
,
_processManager
=
processManager
,
_logger
=
logger
,
...
...
@@ -49,10 +46,10 @@ class FlutterApplicationPackageFactory extends ApplicationPackageFactory {
final
FileSystem
_fileSystem
;
@override
Future
<
ApplicationPackage
>
getPackageForPlatform
(
Future
<
ApplicationPackage
?
>
getPackageForPlatform
(
TargetPlatform
platform
,
{
BuildInfo
buildInfo
,
File
applicationBinary
,
BuildInfo
?
buildInfo
,
File
?
applicationBinary
,
})
async
{
switch
(
platform
)
{
case
TargetPlatform
.
android
:
...
...
@@ -111,7 +108,5 @@ class FlutterApplicationPackageFactory extends ApplicationPackageFactory {
case
TargetPlatform
.
windows_uwp_x64
:
return
BuildableUwpApp
(
project:
FlutterProject
.
current
().
windowsUwp
);
}
assert
(
platform
!=
null
);
return
null
;
}
}
packages/flutter_tools/lib/src/ios/application_package.dart
View file @
54326885
...
...
@@ -72,7 +72,7 @@ abstract class IOSApp extends ApplicationPackage {
);
}
static
Future
<
IOSApp
?>
fromIosProject
(
IosProject
project
,
BuildInfo
buildInfo
)
async
{
static
Future
<
IOSApp
?>
fromIosProject
(
IosProject
project
,
BuildInfo
?
buildInfo
)
async
{
if
(!
globals
.
platform
.
isMacOS
)
{
return
null
;
}
...
...
@@ -109,7 +109,7 @@ class BuildableIOSApp extends IOSApp {
:
_hostAppBundleName
=
hostAppBundleName
,
super
(
projectBundleId:
projectBundleId
);
static
Future
<
BuildableIOSApp
?>
fromProject
(
IosProject
project
,
BuildInfo
buildInfo
)
async
{
static
Future
<
BuildableIOSApp
?>
fromProject
(
IosProject
project
,
BuildInfo
?
buildInfo
)
async
{
final
String
?
hostAppBundleName
=
await
project
.
hostAppBundleName
(
buildInfo
);
final
String
?
projectBundleId
=
await
project
.
productBundleIdentifier
(
buildInfo
);
if
(
projectBundleId
!=
null
)
{
...
...
packages/flutter_tools/lib/src/xcode_project.dart
View file @
54326885
...
...
@@ -216,7 +216,7 @@ class IosProject extends XcodeBasedProject {
}
/// The bundle name of the host app, `My App.app`.
Future<String?> hostAppBundleName(BuildInfo buildInfo) async {
Future<String?> hostAppBundleName(BuildInfo
?
buildInfo) async {
if (!existsSync()) {
return null;
}
...
...
@@ -224,7 +224,7 @@ class IosProject extends XcodeBasedProject {
}
String? _hostAppBundleName;
Future<String> _parseHostAppBundleName(BuildInfo buildInfo) async {
Future<String> _parseHostAppBundleName(BuildInfo
?
buildInfo) async {
// The product name and bundle name are derived from the display name, which the user
// is instructed to change in Xcode as part of deploying to the App Store.
// https://flutter.dev/docs/deployment/ios#review-xcode-project-settings
...
...
packages/flutter_tools/test/general.shard/ios/mac_test.dart
View file @
54326885
...
...
@@ -489,7 +489,7 @@ class FakeIosProject extends Fake implements IosProject {
final File xcodeProjectInfoFile;
@override
Future<String> hostAppBundleName(BuildInfo buildInfo) async => 'UnitTestRunner.app';
Future<String> hostAppBundleName(BuildInfo
?
buildInfo) async => 'UnitTestRunner.app';
@override
Directory get xcodeProject => xcodeProjectInfoFile.fileSystem.directory('Runner.xcodeproj');
...
...
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