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
1c2747ce
Commit
1c2747ce
authored
Feb 29, 2016
by
Matt Perry
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2269 from mpcomplete/rm.updater
Remove unused updater package.
parents
ed345073
eaee8915
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
0 additions
and
245 deletions
+0
-245
AndroidManifest.xml
examples/material_gallery/android/AndroidManifest.xml
+0
-4
.gitignore
packages/updater/.gitignore
+0
-3
main.dart
packages/updater/lib/main.dart
+0
-126
pipe_to_file.dart
packages/updater/lib/pipe_to_file.dart
+0
-64
version.dart
packages/updater/lib/version.dart
+0
-32
pubspec.yaml
packages/updater/pubspec.yaml
+0
-16
No files found.
examples/material_gallery/android/AndroidManifest.xml
View file @
1c2747ce
...
@@ -15,9 +15,5 @@
...
@@ -15,9 +15,5 @@
<category
android:name=
"android.intent.category.LAUNCHER"
/>
<category
android:name=
"android.intent.category.LAUNCHER"
/>
</intent-filter>
</intent-filter>
</activity>
</activity>
<service
android:name=
"org.domokit.sky.shell.UpdateService"
android:exported=
"false"
android:process=
":remote"
/>
</application>
</application>
</manifest>
</manifest>
packages/updater/.gitignore
deleted
100644 → 0
View file @
ed345073
.idea
.pub/
pubspec.lock
packages/updater/lib/main.dart
deleted
100644 → 0
View file @
ed345073
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:async'
;
import
'dart:io'
;
import
'package:mojo/core.dart'
;
import
'package:flutter/http.dart'
as
http
;
import
'package:flutter/services.dart'
;
import
'package:flx/bundle.dart'
;
import
'package:sky_services/updater/update_service.mojom.dart'
;
import
'package:path/path.dart'
as
path
;
import
'package:yaml/yaml.dart'
as
yaml
;
import
'pipe_to_file.dart'
;
import
'version.dart'
;
const
String
kManifestFile
=
'flutter.yaml'
;
const
String
kBundleFile
=
'app.flx'
;
UpdateServiceProxy
_initUpdateService
(
)
{
UpdateServiceProxy
updateService
=
new
UpdateServiceProxy
.
unbound
();
shell
.
connectToService
(
null
,
updateService
);
return
updateService
;
}
final
UpdateServiceProxy
_updateService
=
_initUpdateService
();
String
cachedDataDir
=
null
;
Future
<
String
>
getDataDir
()
async
{
if
(
cachedDataDir
==
null
)
cachedDataDir
=
await
getAppDataDir
();
return
cachedDataDir
;
}
class
UpdateFailure
extends
Error
{
UpdateFailure
(
this
.
_message
);
String
_message
;
String
toString
()
=>
_message
;
}
class
UpdateTask
{
UpdateTask
();
Future
run
()
async
{
try
{
await
_runImpl
();
}
on
UpdateFailure
catch
(
e
)
{
print
(
'Update failed:
$e
'
);
}
catch
(
e
,
stackTrace
)
{
print
(
'Update failed:
$e
'
);
print
(
'Stack:
$stackTrace
'
);
}
finally
{
_updateService
.
ptr
.
notifyUpdateCheckComplete
();
}
}
Future
_runImpl
()
async
{
_dataDir
=
await
getDataDir
();
await
_readLocalManifest
();
yaml
.
YamlMap
remoteManifest
=
await
_fetchManifest
();
if
(!
_shouldUpdate
(
remoteManifest
))
{
print
(
'Update skipped. No new version.'
);
return
;
}
await
_fetchBundle
();
await
_validateBundle
();
await
_replaceBundle
();
print
(
'Update success.'
);
}
Map
_currentManifest
;
String
_dataDir
;
String
_tempPath
;
Future
_readLocalManifest
()
async
{
String
bundlePath
=
path
.
join
(
_dataDir
,
kBundleFile
);
Bundle
bundle
=
await
Bundle
.
readHeader
(
bundlePath
);
_currentManifest
=
bundle
.
manifest
;
}
Future
<
yaml
.
YamlMap
>
_fetchManifest
()
async
{
String
manifestUrl
=
_currentManifest
[
'update-url'
]
+
'/'
+
kManifestFile
;
String
manifestData
=
(
await
http
.
get
(
manifestUrl
)).
body
;
return
yaml
.
loadYaml
(
manifestData
,
sourceUrl:
manifestUrl
);
}
bool
_shouldUpdate
(
yaml
.
YamlMap
remoteManifest
)
{
Version
currentVersion
=
new
Version
(
_currentManifest
[
'version'
]);
Version
remoteVersion
=
new
Version
(
remoteManifest
[
'version'
]);
return
(
currentVersion
<
remoteVersion
);
}
Future
_fetchBundle
()
async
{
// TODO(mpcomplete): Use the cache dir. We need an equivalent of mkstemp().
_tempPath
=
path
.
join
(
_dataDir
,
'tmp.skyx'
);
String
bundleUrl
=
_currentManifest
[
'update-url'
]
+
'/'
+
kBundleFile
;
UrlResponse
response
=
await
fetchUrl
(
bundleUrl
);
int
result
=
await
PipeToFile
.
copyToFile
(
response
.
body
,
_tempPath
);
if
(
result
!=
MojoResult
.
kOk
)
throw
new
UpdateFailure
(
'Failure fetching new package:
${response.statusLine}
'
);
}
Future
_validateBundle
()
async
{
Bundle
bundle
=
await
Bundle
.
readHeader
(
_tempPath
);
if
(
bundle
==
null
)
throw
new
UpdateFailure
(
'Remote package not a valid FLX file.'
);
if
(
bundle
.
manifest
[
'key'
]
!=
_currentManifest
[
'key'
])
throw
new
UpdateFailure
(
'Remote package key does not match.'
);
if
(!
await
bundle
.
verifyContent
())
throw
new
UpdateFailure
(
'Invalid package signature or hash. This package has been tampered with.'
);
}
Future
_replaceBundle
()
async
{
String
bundlePath
=
path
.
join
(
_dataDir
,
kBundleFile
);
await
new
File
(
_tempPath
).
rename
(
bundlePath
);
}
}
void
main
(
)
{
UpdateTask
task
=
new
UpdateTask
();
task
.
run
();
}
packages/updater/lib/pipe_to_file.dart
deleted
100644 → 0
View file @
ed345073
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:async'
;
import
'dart:io'
;
import
'dart:typed_data'
;
import
'package:mojo/core.dart'
;
// Helper class to drain the contents of a mojo data pipe to a file.
class
PipeToFile
{
MojoDataPipeConsumer
_consumer
;
MojoEventSubscription
_events
;
IOSink
_outputStream
;
PipeToFile
(
this
.
_consumer
,
String
outputPath
)
{
_events
=
new
MojoEventSubscription
(
_consumer
.
handle
);
_outputStream
=
new
File
(
outputPath
).
openWrite
();
}
Future
<
int
>
_doRead
()
async
{
ByteData
thisRead
=
_consumer
.
beginRead
();
if
(
thisRead
==
null
)
{
throw
'Data pipe beginRead failed:
${_consumer.status}
'
;
}
// TODO(mpcomplete): Should I worry about the _eventStream listen callback
// being invoked again before this completes?
await
_outputStream
.
add
(
thisRead
.
buffer
.
asUint8List
());
return
_consumer
.
endRead
(
thisRead
.
lengthInBytes
);
}
Future
<
int
>
drain
()
{
Completer
<
int
>
completer
=
new
Completer
();
_events
.
subscribe
((
int
signal
)
{
(()
async
{
if
(
MojoHandleSignals
.
isReadable
(
signal
))
{
int
result
=
await
_doRead
();
if
(
result
!=
MojoResult
.
kOk
)
{
_events
.
close
();
_events
=
null
;
_outputStream
.
close
();
completer
.
complete
(
result
);
}
else
{
_events
.
enableReadEvents
();
}
}
else
if
(
MojoHandleSignals
.
isPeerClosed
(
signal
))
{
_events
.
close
();
_events
=
null
;
_outputStream
.
close
();
completer
.
complete
(
MojoResult
.
kOk
);
}
else
{
throw
'Unexpected handle event:
${MojoHandleSignals.string(signal)}
'
;
}
})();
});
return
completer
.
future
;
}
static
Future
<
int
>
copyToFile
(
MojoDataPipeConsumer
consumer
,
String
outputPath
)
{
PipeToFile
drainer
=
new
PipeToFile
(
consumer
,
outputPath
);
return
drainer
.
drain
();
}
}
packages/updater/lib/version.dart
deleted
100644 → 0
View file @
ed345073
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:math'
;
// This class represents a dot-separated version string. Used for comparing
// versions.
// Usage: assert(new Version('1.1.0') < new Version('1.2.1'));
class
Version
{
Version
(
String
versionStr
)
:
_parts
=
versionStr
.
split
(
'.'
).
map
((
String
val
)
=>
int
.
parse
(
val
)).
toList
();
List
<
int
>
_parts
;
bool
operator
<(
Version
other
)
=>
_compare
(
other
)
<
0
;
bool
operator
==(
dynamic
other
)
=>
other
is
Version
&&
_compare
(
other
)
==
0
;
bool
operator
>(
Version
other
)
=>
_compare
(
other
)
>
0
;
int
_compare
(
Version
other
)
{
int
length
=
min
(
_parts
.
length
,
other
.
_parts
.
length
);
for
(
int
i
=
0
;
i
<
length
;
++
i
)
{
if
(
_parts
[
i
]
<
other
.
_parts
[
i
])
return
-
1
;
if
(
_parts
[
i
]
>
other
.
_parts
[
i
])
return
1
;
}
return
_parts
.
length
-
other
.
_parts
.
length
;
// results in 1.0 < 1.0.0
}
int
get
hashCode
=>
_parts
.
fold
(
373
,
(
int
acc
,
int
part
)
=>
37
*
acc
+
part
);
}
packages/updater/pubspec.yaml
deleted
100644 → 0
View file @
ed345073
name
:
updater
author
:
Flutter Authors <flutter-dev@googlegroups.com>
description
:
An autoupdater for Flutter
homepage
:
http://flutter.io
dependencies
:
path
:
^1.3.0
yaml
:
^2.1.3
# TODO(abarth): Updater should not depend on flutter
flutter
:
path
:
../flutter
flx
:
path
:
../flx
environment
:
sdk
:
'
>=1.12.0
<2.0.0'
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