Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sxychenjing
engine
提交
3bcd6a8f
E
engine
项目概览
sxychenjing
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
engine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
3bcd6a8f
编写于
6月 19, 2019
作者:
M
Matt Carroll
提交者:
GitHub
6月 19, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Android Embedding Refactor PR34: Fill in missing nullability annotations. (#9384)
上级
e8e9ba29
变更
28
隐藏空白更改
内联
并排
Showing
28 changed file
with
182 addition
and
93 deletion
+182
-93
shell/platform/android/io/flutter/embedding/android/AndroidKeyProcessor.java
...oid/io/flutter/embedding/android/AndroidKeyProcessor.java
+2
-0
shell/platform/android/io/flutter/embedding/android/AndroidTouchProcessor.java
...d/io/flutter/embedding/android/AndroidTouchProcessor.java
+2
-2
shell/platform/android/io/flutter/embedding/android/FlutterActivity.java
...android/io/flutter/embedding/android/FlutterActivity.java
+6
-2
shell/platform/android/io/flutter/embedding/android/FlutterFragment.java
...android/io/flutter/embedding/android/FlutterFragment.java
+2
-2
shell/platform/android/io/flutter/embedding/android/FlutterSurfaceView.java
...roid/io/flutter/embedding/android/FlutterSurfaceView.java
+3
-3
shell/platform/android/io/flutter/embedding/android/FlutterTextureView.java
...roid/io/flutter/embedding/android/FlutterTextureView.java
+5
-5
shell/platform/android/io/flutter/embedding/android/FlutterView.java
...orm/android/io/flutter/embedding/android/FlutterView.java
+13
-10
shell/platform/android/io/flutter/embedding/engine/FlutterEngine.java
...rm/android/io/flutter/embedding/engine/FlutterEngine.java
+2
-0
shell/platform/android/io/flutter/embedding/engine/FlutterEngineAndroidLifecycle.java
...utter/embedding/engine/FlutterEngineAndroidLifecycle.java
+1
-0
shell/platform/android/io/flutter/embedding/engine/FlutterEnginePluginRegistry.java
...flutter/embedding/engine/FlutterEnginePluginRegistry.java
+27
-3
shell/platform/android/io/flutter/embedding/engine/FlutterJNI.java
...tform/android/io/flutter/embedding/engine/FlutterJNI.java
+33
-20
shell/platform/android/io/flutter/embedding/engine/FlutterShellArgs.java
...android/io/flutter/embedding/engine/FlutterShellArgs.java
+1
-0
shell/platform/android/io/flutter/embedding/engine/dart/DartExecutor.java
...ndroid/io/flutter/embedding/engine/dart/DartExecutor.java
+5
-2
shell/platform/android/io/flutter/embedding/engine/dart/DartMessenger.java
...droid/io/flutter/embedding/engine/dart/DartMessenger.java
+1
-1
shell/platform/android/io/flutter/embedding/engine/dart/PlatformMessageHandler.java
...flutter/embedding/engine/dart/PlatformMessageHandler.java
+5
-2
shell/platform/android/io/flutter/embedding/engine/plugins/activity/ActivityControlSurface.java
...dding/engine/plugins/activity/ActivityControlSurface.java
+2
-1
shell/platform/android/io/flutter/embedding/engine/renderer/FlutterRenderer.java
...io/flutter/embedding/engine/renderer/FlutterRenderer.java
+9
-6
shell/platform/android/io/flutter/embedding/engine/systemchannels/AccessibilityChannel.java
...embedding/engine/systemchannels/AccessibilityChannel.java
+1
-1
shell/platform/android/io/flutter/embedding/engine/systemchannels/LocalizationChannel.java
.../embedding/engine/systemchannels/LocalizationChannel.java
+1
-1
shell/platform/android/io/flutter/embedding/engine/systemchannels/NavigationChannel.java
...er/embedding/engine/systemchannels/NavigationChannel.java
+2
-2
shell/platform/android/io/flutter/embedding/engine/systemchannels/PlatformChannel.java
...tter/embedding/engine/systemchannels/PlatformChannel.java
+11
-2
shell/platform/android/io/flutter/embedding/engine/systemchannels/PlatformViewsChannel.java
...embedding/engine/systemchannels/PlatformViewsChannel.java
+3
-3
shell/platform/android/io/flutter/embedding/engine/systemchannels/SettingsChannel.java
...tter/embedding/engine/systemchannels/SettingsChannel.java
+14
-6
shell/platform/android/io/flutter/embedding/engine/systemchannels/TextInputChannel.java
...ter/embedding/engine/systemchannels/TextInputChannel.java
+2
-1
shell/platform/android/io/flutter/plugin/common/BasicMessageChannel.java
...android/io/flutter/plugin/common/BasicMessageChannel.java
+15
-10
shell/platform/android/io/flutter/plugin/common/BinaryMessenger.java
...orm/android/io/flutter/plugin/common/BinaryMessenger.java
+7
-5
shell/platform/android/io/flutter/plugin/common/MessageCodec.java
...atform/android/io/flutter/plugin/common/MessageCodec.java
+6
-2
shell/platform/android/io/flutter/plugin/common/MethodChannel.java
...tform/android/io/flutter/plugin/common/MethodChannel.java
+1
-1
未找到文件。
shell/platform/android/io/flutter/embedding/android/AndroidKeyProcessor.java
浏览文件 @
3bcd6a8f
...
...
@@ -13,7 +13,9 @@ import io.flutter.embedding.engine.systemchannels.KeyEventChannel;
import
io.flutter.plugin.editing.TextInputPlugin
;
public
class
AndroidKeyProcessor
{
@NonNull
private
final
KeyEventChannel
keyEventChannel
;
@NonNull
private
final
TextInputPlugin
textInputPlugin
;
private
int
combiningCharacter
;
...
...
shell/platform/android/io/flutter/embedding/android/AndroidTouchProcessor.java
浏览文件 @
3bcd6a8f
...
...
@@ -89,7 +89,7 @@ public class AndroidTouchProcessor {
* Sends the given {@link MotionEvent} data to Flutter in a format that
* Flutter understands.
*/
public
boolean
onTouchEvent
(
MotionEvent
event
)
{
public
boolean
onTouchEvent
(
@NonNull
MotionEvent
event
)
{
int
pointerCount
=
event
.
getPointerCount
();
// Prepare a data packet of the appropriate size and order.
...
...
@@ -145,7 +145,7 @@ public class AndroidTouchProcessor {
* Generic motion events include joystick movement, mouse hover, track pad touches, scroll wheel
* movements, etc.
*/
public
boolean
onGenericMotionEvent
(
MotionEvent
event
)
{
public
boolean
onGenericMotionEvent
(
@NonNull
MotionEvent
event
)
{
// Method isFromSource is only available in API 18+ (Jelly Bean MR2)
// Mouse hover support is not implemented for API < 18.
boolean
isPointerEvent
=
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
JELLY_BEAN_MR2
...
...
shell/platform/android/io/flutter/embedding/android/FlutterActivity.java
浏览文件 @
3bcd6a8f
...
...
@@ -87,16 +87,19 @@ public class FlutterActivity extends FragmentActivity implements OnFirstFrameRen
private
static
final
String
TAG_FLUTTER_FRAGMENT
=
"flutter_fragment"
;
// TODO(mattcarroll): replace ID with R.id when build system supports R.java
private
static
final
int
FRAGMENT_CONTAINER_ID
=
609893468
;
// random number
@Nullable
private
FlutterFragment
flutterFragment
;
// Used to cover the Activity until the 1st frame is rendered so as to
// avoid a brief black flicker from a SurfaceView version of FlutterView.
@Nullable
private
View
coverView
;
/**
* Creates an {@link Intent} that launches a {@code FlutterActivity}, which executes
* a {@code main()} Dart entrypoint, and displays the "/" route as Flutter's initial route.
*/
@NonNull
public
static
Intent
createDefaultIntent
(
@NonNull
Context
launchContext
)
{
return
createBuilder
().
build
(
launchContext
);
}
...
...
@@ -105,6 +108,7 @@ public class FlutterActivity extends FragmentActivity implements OnFirstFrameRen
* Creates an {@link IntentBuilder}, which can be used to configure an {@link Intent} to
* launch a {@code FlutterActivity}.
*/
@NonNull
public
static
IntentBuilder
createBuilder
()
{
return
new
IntentBuilder
(
FlutterActivity
.
class
);
}
...
...
@@ -178,7 +182,7 @@ public class FlutterActivity extends FragmentActivity implements OnFirstFrameRen
}
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
protected
void
onCreate
(
@Nullable
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
configureWindowForTransparency
();
setContentView
(
createFragmentContainer
());
...
...
@@ -368,7 +372,7 @@ public class FlutterActivity extends FragmentActivity implements OnFirstFrameRen
}
@Override
protected
void
onNewIntent
(
Intent
intent
)
{
protected
void
onNewIntent
(
@NonNull
Intent
intent
)
{
// Forward Intents to our FlutterFragment in case it cares.
flutterFragment
.
onNewIntent
(
intent
);
}
...
...
shell/platform/android/io/flutter/embedding/android/FlutterFragment.java
浏览文件 @
3bcd6a8f
...
...
@@ -331,7 +331,7 @@ public class FlutterFragment extends Fragment {
}
@Override
public
void
onAttach
(
Context
context
)
{
public
void
onAttach
(
@NonNull
Context
context
)
{
super
.
onAttach
(
context
);
initializeFlutter
(
getContextCompat
());
...
...
@@ -438,7 +438,7 @@ public class FlutterFragment extends Fragment {
@Nullable
@Override
public
View
onCreateView
(
LayoutInflater
inflater
,
@Nullable
ViewGroup
container
,
@Nullable
Bundle
savedInstanceState
)
{
public
View
onCreateView
(
@NonNull
LayoutInflater
inflater
,
@Nullable
ViewGroup
container
,
@Nullable
Bundle
savedInstanceState
)
{
Log
.
v
(
TAG
,
"Creating FlutterView."
);
flutterView
=
new
FlutterView
(
getContext
(),
getRenderMode
(),
getTransparencyMode
());
flutterView
.
addOnFirstFrameRenderedListener
(
onFirstFrameRenderedListener
);
...
...
shell/platform/android/io/flutter/embedding/android/FlutterSurfaceView.java
浏览文件 @
3bcd6a8f
...
...
@@ -50,7 +50,7 @@ public class FlutterSurfaceView extends SurfaceView implements FlutterRenderer.R
// FlutterRenderer, and then on to the JNI bridge over to native Flutter code.
private
final
SurfaceHolder
.
Callback
surfaceCallback
=
new
SurfaceHolder
.
Callback
()
{
@Override
public
void
surfaceCreated
(
SurfaceHolder
holder
)
{
public
void
surfaceCreated
(
@NonNull
SurfaceHolder
holder
)
{
Log
.
v
(
TAG
,
"SurfaceHolder.Callback.surfaceCreated()"
);
isSurfaceAvailableForRendering
=
true
;
...
...
@@ -60,7 +60,7 @@ public class FlutterSurfaceView extends SurfaceView implements FlutterRenderer.R
}
@Override
public
void
surfaceChanged
(
SurfaceHolder
holder
,
int
format
,
int
width
,
int
height
)
{
public
void
surfaceChanged
(
@NonNull
SurfaceHolder
holder
,
int
format
,
int
width
,
int
height
)
{
Log
.
v
(
TAG
,
"SurfaceHolder.Callback.surfaceChanged()"
);
if
(
isAttachedToFlutterRenderer
)
{
changeSurfaceSize
(
width
,
height
);
...
...
@@ -68,7 +68,7 @@ public class FlutterSurfaceView extends SurfaceView implements FlutterRenderer.R
}
@Override
public
void
surfaceDestroyed
(
SurfaceHolder
holder
)
{
public
void
surfaceDestroyed
(
@NonNull
SurfaceHolder
holder
)
{
Log
.
v
(
TAG
,
"SurfaceHolder.Callback.surfaceDestroyed()"
);
isSurfaceAvailableForRendering
=
false
;
...
...
shell/platform/android/io/flutter/embedding/android/FlutterTextureView.java
浏览文件 @
3bcd6a8f
...
...
@@ -61,7 +61,7 @@ public class FlutterTextureView extends TextureView implements FlutterRenderer.R
}
@Override
public
void
onSurfaceTextureSizeChanged
(
SurfaceTexture
surface
,
int
width
,
int
height
)
{
public
void
onSurfaceTextureSizeChanged
(
@NonNull
SurfaceTexture
surface
,
int
width
,
int
height
)
{
Log
.
v
(
TAG
,
"SurfaceTextureListener.onSurfaceTextureSizeChanged()"
);
if
(
isAttachedToFlutterRenderer
)
{
changeSurfaceSize
(
width
,
height
);
...
...
@@ -69,12 +69,12 @@ public class FlutterTextureView extends TextureView implements FlutterRenderer.R
}
@Override
public
void
onSurfaceTextureUpdated
(
SurfaceTexture
surface
)
{
public
void
onSurfaceTextureUpdated
(
@NonNull
SurfaceTexture
surface
)
{
// Invoked every time a new frame is available. We don't care.
}
@Override
public
boolean
onSurfaceTextureDestroyed
(
SurfaceTexture
surface
)
{
public
boolean
onSurfaceTextureDestroyed
(
@NonNull
SurfaceTexture
surface
)
{
Log
.
v
(
TAG
,
"SurfaceTextureListener.onSurfaceTextureDestroyed()"
);
isSurfaceAvailableForRendering
=
false
;
...
...
@@ -93,14 +93,14 @@ public class FlutterTextureView extends TextureView implements FlutterRenderer.R
/**
* Constructs a {@code FlutterTextureView} programmatically, without any XML attributes.
*/
public
FlutterTextureView
(
Context
context
)
{
public
FlutterTextureView
(
@NonNull
Context
context
)
{
this
(
context
,
null
);
}
/**
* Constructs a {@code FlutterTextureView} in an XML-inflation-compliant manner.
*/
public
FlutterTextureView
(
Context
context
,
AttributeSet
attrs
)
{
public
FlutterTextureView
(
@NonNull
Context
context
,
@Nullable
AttributeSet
attrs
)
{
super
(
context
,
attrs
);
init
();
}
...
...
shell/platform/android/io/flutter/embedding/android/FlutterView.java
浏览文件 @
3bcd6a8f
...
...
@@ -238,7 +238,7 @@ public class FlutterView extends FrameLayout {
* change, device language change, device text scale factor change, etc.
*/
@Override
protected
void
onConfigurationChanged
(
Configuration
newConfig
)
{
protected
void
onConfigurationChanged
(
@NonNull
Configuration
newConfig
)
{
super
.
onConfigurationChanged
(
newConfig
);
Log
.
v
(
TAG
,
"Configuration changed. Sending locales and user settings to Flutter."
);
sendLocalesToFlutter
(
newConfig
);
...
...
@@ -280,7 +280,8 @@ public class FlutterView extends FrameLayout {
@Override
@TargetApi
(
20
)
@RequiresApi
(
20
)
public
final
WindowInsets
onApplyWindowInsets
(
WindowInsets
insets
)
{
@NonNull
public
final
WindowInsets
onApplyWindowInsets
(
@NonNull
WindowInsets
insets
)
{
WindowInsets
newInsets
=
super
.
onApplyWindowInsets
(
insets
);
// Status bar (top) and left/right system insets should partially obscure the content (padding).
...
...
@@ -315,7 +316,7 @@ public class FlutterView extends FrameLayout {
*/
@Override
@SuppressWarnings
(
"deprecation"
)
protected
boolean
fitSystemWindows
(
Rect
insets
)
{
protected
boolean
fitSystemWindows
(
@NonNull
Rect
insets
)
{
if
(
Build
.
VERSION
.
SDK_INT
<=
Build
.
VERSION_CODES
.
KITKAT
)
{
// Status bar, left/right system insets partially obscure content (padding).
viewportMetrics
.
paddingTop
=
insets
.
top
;
...
...
@@ -358,7 +359,8 @@ public class FlutterView extends FrameLayout {
* rather than spread that logic throughout this {@code FlutterView}.
*/
@Override
public
InputConnection
onCreateInputConnection
(
EditorInfo
outAttrs
)
{
@Nullable
public
InputConnection
onCreateInputConnection
(
@NonNull
EditorInfo
outAttrs
)
{
if
(!
isAttachedToFlutterEngine
())
{
return
super
.
onCreateInputConnection
(
outAttrs
);
}
...
...
@@ -380,7 +382,7 @@ public class FlutterView extends FrameLayout {
* character.
*/
@Override
public
boolean
onKeyUp
(
int
keyCode
,
KeyEvent
event
)
{
public
boolean
onKeyUp
(
int
keyCode
,
@NonNull
KeyEvent
event
)
{
if
(!
isAttachedToFlutterEngine
())
{
return
super
.
onKeyUp
(
keyCode
,
event
);
}
...
...
@@ -403,7 +405,7 @@ public class FlutterView extends FrameLayout {
* character.
*/
@Override
public
boolean
onKeyDown
(
int
keyCode
,
KeyEvent
event
)
{
public
boolean
onKeyDown
(
int
keyCode
,
@NonNull
KeyEvent
event
)
{
if
(!
isAttachedToFlutterEngine
())
{
return
super
.
onKeyDown
(
keyCode
,
event
);
}
...
...
@@ -419,7 +421,7 @@ public class FlutterView extends FrameLayout {
* method forwards all {@link MotionEvent} data from Android to Flutter.
*/
@Override
public
boolean
onTouchEvent
(
MotionEvent
event
)
{
public
boolean
onTouchEvent
(
@NonNull
MotionEvent
event
)
{
if
(!
isAttachedToFlutterEngine
())
{
return
super
.
onTouchEvent
(
event
);
}
...
...
@@ -444,7 +446,7 @@ public class FlutterView extends FrameLayout {
* method forwards all {@link MotionEvent} data from Android to Flutter.
*/
@Override
public
boolean
onGenericMotionEvent
(
MotionEvent
event
)
{
public
boolean
onGenericMotionEvent
(
@NonNull
MotionEvent
event
)
{
boolean
handled
=
isAttachedToFlutterEngine
()
&&
androidTouchProcessor
.
onGenericMotionEvent
(
event
);
return
handled
?
true
:
super
.
onGenericMotionEvent
(
event
);
}
...
...
@@ -461,7 +463,7 @@ public class FlutterView extends FrameLayout {
* processed here for accessibility purposes.
*/
@Override
public
boolean
onHoverEvent
(
MotionEvent
event
)
{
public
boolean
onHoverEvent
(
@NonNull
MotionEvent
event
)
{
if
(!
isAttachedToFlutterEngine
())
{
return
super
.
onHoverEvent
(
event
);
}
...
...
@@ -477,6 +479,7 @@ public class FlutterView extends FrameLayout {
//-------- Start: Accessibility -------
@Override
@Nullable
public
AccessibilityNodeProvider
getAccessibilityNodeProvider
()
{
if
(
accessibilityBridge
!=
null
&&
accessibilityBridge
.
isAccessibilityEnabled
())
{
return
accessibilityBridge
;
...
...
@@ -661,7 +664,7 @@ public class FlutterView extends FrameLayout {
* FlutterEngine must be non-null when this method is invoked.
*/
@SuppressWarnings
(
"deprecation"
)
private
void
sendLocalesToFlutter
(
Configuration
config
)
{
private
void
sendLocalesToFlutter
(
@NonNull
Configuration
config
)
{
List
<
Locale
>
locales
=
new
ArrayList
<>();
if
(
Build
.
VERSION
.
SDK_INT
>=
android
.
os
.
Build
.
VERSION_CODES
.
N
)
{
LocaleList
localeList
=
config
.
getLocales
();
...
...
shell/platform/android/io/flutter/embedding/engine/FlutterEngine.java
浏览文件 @
3bcd6a8f
...
...
@@ -88,7 +88,9 @@ public class FlutterEngine implements LifecycleOwner {
@NonNull
private
final
TextInputChannel
textInputChannel
;
@NonNull
private
final
Set
<
EngineLifecycleListener
>
engineLifecycleListeners
=
new
HashSet
<>();
@NonNull
private
final
EngineLifecycleListener
engineLifecycleListener
=
new
EngineLifecycleListener
()
{
@SuppressWarnings
(
"unused"
)
public
void
onPreEngineRestart
()
{
...
...
shell/platform/android/io/flutter/embedding/engine/FlutterEngineAndroidLifecycle.java
浏览文件 @
3bcd6a8f
...
...
@@ -40,6 +40,7 @@ final class FlutterEngineAndroidLifecycle extends LifecycleRegistry {
private
Lifecycle
backingLifecycle
;
private
boolean
isDestroyed
=
false
;
@NonNull
private
final
LifecycleObserver
forwardingObserver
=
new
DefaultLifecycleObserver
()
{
@Override
public
void
onCreate
(
@NonNull
LifecycleOwner
owner
)
{
...
...
shell/platform/android/io/flutter/embedding/engine/FlutterEnginePluginRegistry.java
浏览文件 @
3bcd6a8f
...
...
@@ -43,31 +43,46 @@ class FlutterEnginePluginRegistry implements PluginRegistry,
private
static
final
String
TAG
=
"EnginePluginRegistry"
;
// PluginRegistry
@NonNull
private
final
Map
<
Class
<?
extends
FlutterPlugin
>,
FlutterPlugin
>
plugins
=
new
HashMap
<>();
// Standard FlutterPlugin
@NonNull
private
final
FlutterPlugin
.
FlutterPluginBinding
pluginBinding
;
@NonNull
private
final
FlutterEngineAndroidLifecycle
flutterEngineAndroidLifecycle
;
// ActivityAware
@NonNull
private
final
Map
<
Class
<?
extends
FlutterPlugin
>,
ActivityAware
>
activityAwarePlugins
=
new
HashMap
<>();
@Nullable
private
Activity
activity
;
@Nullable
private
FlutterEngineActivityPluginBinding
activityPluginBinding
;
private
boolean
isWaitingForActivityReattachment
=
false
;
// ServiceAware
@NonNull
private
final
Map
<
Class
<?
extends
FlutterPlugin
>,
ServiceAware
>
serviceAwarePlugins
=
new
HashMap
<>();
@Nullable
private
Service
service
;
@Nullable
private
FlutterEngineServicePluginBinding
servicePluginBinding
;
// BroadcastReceiver
@NonNull
private
final
Map
<
Class
<?
extends
FlutterPlugin
>,
BroadcastReceiverAware
>
broadcastReceiverAwarePlugins
=
new
HashMap
<>();
@Nullable
private
BroadcastReceiver
broadcastReceiver
;
@Nullable
private
FlutterEngineBroadcastReceiverPluginBinding
broadcastReceiverPluginBinding
;
// ContentProvider
@NonNull
private
final
Map
<
Class
<?
extends
FlutterPlugin
>,
ContentProviderAware
>
contentProviderAwarePlugins
=
new
HashMap
<>();
@Nullable
private
ContentProvider
contentProvider
;
@Nullable
private
FlutterEngineContentProviderPluginBinding
contentProviderPluginBinding
;
FlutterEnginePluginRegistry
(
...
...
@@ -329,7 +344,7 @@ class FlutterEnginePluginRegistry implements PluginRegistry,
}
@Override
public
boolean
onActivityResult
(
int
requestCode
,
int
resultCode
,
@N
onNull
Intent
data
)
{
public
boolean
onActivityResult
(
int
requestCode
,
int
resultCode
,
@N
ullable
Intent
data
)
{
Log
.
v
(
TAG
,
"Forwarding onActivityResult() to plugins."
);
if
(
isAttachedToActivity
())
{
return
activityPluginBinding
.
onActivityResult
(
requestCode
,
resultCode
,
data
);
...
...
@@ -486,10 +501,15 @@ class FlutterEnginePluginRegistry implements PluginRegistry,
//----- End ContentProviderControlSurface -----
private
static
class
FlutterEngineActivityPluginBinding
implements
ActivityPluginBinding
{
@NonNull
private
final
Activity
activity
;
@NonNull
private
final
Set
<
io
.
flutter
.
plugin
.
common
.
PluginRegistry
.
RequestPermissionsResultListener
>
onRequestPermissionsResultListeners
=
new
HashSet
<>();
@NonNull
private
final
Set
<
io
.
flutter
.
plugin
.
common
.
PluginRegistry
.
ActivityResultListener
>
onActivityResultListeners
=
new
HashSet
<>();
@NonNull
private
final
Set
<
io
.
flutter
.
plugin
.
common
.
PluginRegistry
.
NewIntentListener
>
onNewIntentListeners
=
new
HashSet
<>();
@NonNull
private
final
Set
<
io
.
flutter
.
plugin
.
common
.
PluginRegistry
.
UserLeaveHintListener
>
onUserLeaveHintListeners
=
new
HashSet
<>();
public
FlutterEngineActivityPluginBinding
(
@NonNull
Activity
activity
)
{
...
...
@@ -556,7 +576,7 @@ class FlutterEnginePluginRegistry implements PluginRegistry,
* Invoked by the {@link FlutterEngine} that owns this {@code ActivityPluginBinding} when its
* associated {@link Activity} has its {@code onActivityResult(...)} method invoked.
*/
boolean
onActivityResult
(
int
requestCode
,
int
resultCode
,
@N
onNull
Intent
data
)
{
boolean
onActivityResult
(
int
requestCode
,
int
resultCode
,
@N
ullable
Intent
data
)
{
boolean
didConsumeResult
=
false
;
for
(
io
.
flutter
.
plugin
.
common
.
PluginRegistry
.
ActivityResultListener
listener
:
onActivityResultListeners
)
{
didConsumeResult
=
listener
.
onActivityResult
(
requestCode
,
resultCode
,
data
)
||
didConsumeResult
;
...
...
@@ -620,15 +640,17 @@ class FlutterEnginePluginRegistry implements PluginRegistry,
}
private
static
class
FlutterEngineServicePluginBinding
implements
ServicePluginBinding
{
@NonNull
private
final
Service
service
;
@NonNull
private
final
Set
<
ServiceAware
.
OnModeChangeListener
>
onModeChangeListeners
=
new
HashSet
<>();
FlutterEngineServicePluginBinding
(
@NonNull
Service
service
)
{
this
.
service
=
service
;
}
@NonNull
@Override
@NonNull
public
Service
getService
()
{
return
service
;
}
...
...
@@ -657,6 +679,7 @@ class FlutterEnginePluginRegistry implements PluginRegistry,
}
private
static
class
FlutterEngineBroadcastReceiverPluginBinding
implements
BroadcastReceiverPluginBinding
{
@NonNull
private
final
BroadcastReceiver
broadcastReceiver
;
FlutterEngineBroadcastReceiverPluginBinding
(
@NonNull
BroadcastReceiver
broadcastReceiver
)
{
...
...
@@ -671,6 +694,7 @@ class FlutterEnginePluginRegistry implements PluginRegistry,
}
private
static
class
FlutterEngineContentProviderPluginBinding
implements
ContentProviderPluginBinding
{
@NonNull
private
final
ContentProvider
contentProvider
;
FlutterEngineContentProviderPluginBinding
(
@NonNull
ContentProvider
contentProvider
)
{
...
...
shell/platform/android/io/flutter/embedding/engine/FlutterJNI.java
浏览文件 @
3bcd6a8f
...
...
@@ -94,21 +94,30 @@ public class FlutterJNI {
private
static
final
String
TAG
=
"FlutterJNI"
;
// This is set from native code via JNI.
@Nullable
private
static
String
observatoryUri
;
@UiThread
public
static
native
boolean
nativeGetIsSoftwareRenderingEnabled
();
@Nullable
public
static
String
getObservatoryUri
()
{
return
observatoryUri
;
}
@Nullable
private
Long
nativePlatformViewId
;
@Nullable
private
FlutterRenderer
.
RenderSurface
renderSurface
;
@Nullable
private
AccessibilityDelegate
accessibilityDelegate
;
@Nullable
private
PlatformMessageHandler
platformMessageHandler
;
@NonNull
private
final
Set
<
EngineLifecycleListener
>
engineLifecycleListeners
=
new
HashSet
<>();
@NonNull
private
final
Set
<
OnFirstFrameRenderedListener
>
firstFrameListeners
=
new
HashSet
<>();
@NonNull
private
final
Looper
mainLooper
;
// cached to avoid synchronization on repeat access.
public
FlutterJNI
()
{
...
...
@@ -139,7 +148,7 @@ public class FlutterJNI {
nativePlatformViewId
=
nativeAttach
(
this
,
isBackgroundView
);
}
private
native
long
nativeAttach
(
FlutterJNI
flutterJNI
,
boolean
isBackgroundView
);
private
native
long
nativeAttach
(
@NonNull
FlutterJNI
flutterJNI
,
boolean
isBackgroundView
);
/**
* Detaches this {@code FlutterJNI} instance from Flutter's native engine, which precludes
...
...
@@ -246,7 +255,7 @@ public class FlutterJNI {
nativeSurfaceCreated
(
nativePlatformViewId
,
surface
);
}
private
native
void
nativeSurfaceCreated
(
long
nativePlatformViewId
,
Surface
surface
);
private
native
void
nativeSurfaceCreated
(
long
nativePlatformViewId
,
@NonNull
Surface
surface
);
/**
* Call this method when the {@link Surface} changes that was previously registered with
...
...
@@ -341,14 +350,14 @@ public class FlutterJNI {
* Sends a packet of pointer data to Flutter's engine.
*/
@UiThread
public
void
dispatchPointerDataPacket
(
ByteBuffer
buffer
,
int
position
)
{
public
void
dispatchPointerDataPacket
(
@NonNull
ByteBuffer
buffer
,
int
position
)
{
ensureRunningOnMainThread
();
ensureAttachedToNative
();
nativeDispatchPointerDataPacket
(
nativePlatformViewId
,
buffer
,
position
);
}
private
native
void
nativeDispatchPointerDataPacket
(
long
nativePlatformViewId
,
ByteBuffer
buffer
,
@NonNull
ByteBuffer
buffer
,
int
position
);
//------ End Touch Interaction Support ---
...
...
@@ -377,7 +386,7 @@ public class FlutterJNI {
*/
@SuppressWarnings
(
"unused"
)
@UiThread
private
void
updateSemantics
(
ByteBuffer
buffer
,
String
[]
strings
)
{
private
void
updateSemantics
(
@NonNull
ByteBuffer
buffer
,
@NonNull
String
[]
strings
)
{
ensureRunningOnMainThread
();
if
(
accessibilityDelegate
!=
null
)
{
accessibilityDelegate
.
updateSemantics
(
buffer
,
strings
);
...
...
@@ -395,7 +404,7 @@ public class FlutterJNI {
*/
@SuppressWarnings
(
"unused"
)
@UiThread
private
void
updateCustomAccessibilityActions
(
ByteBuffer
buffer
,
String
[]
strings
)
{
private
void
updateCustomAccessibilityActions
(
@NonNull
ByteBuffer
buffer
,
@NonNull
String
[]
strings
)
{
ensureRunningOnMainThread
();
if
(
accessibilityDelegate
!=
null
)
{
accessibilityDelegate
.
updateCustomAccessibilityActions
(
buffer
,
strings
);
...
...
@@ -434,7 +443,7 @@ public class FlutterJNI {
* {@link #dispatchSemanticsAction(int, AccessibilityBridge.Action, Object)}.
*/
@UiThread
public
void
dispatchSemanticsAction
(
int
id
,
int
action
,
ByteBuffer
args
,
int
argsPosition
)
{
public
void
dispatchSemanticsAction
(
int
id
,
int
action
,
@Nullable
ByteBuffer
args
,
int
argsPosition
)
{
ensureRunningOnMainThread
();
ensureAttachedToNative
();
nativeDispatchSemanticsAction
(
nativePlatformViewId
,
id
,
action
,
args
,
argsPosition
);
...
...
@@ -444,7 +453,7 @@ public class FlutterJNI {
long
nativePlatformViewId
,
int
id
,
int
action
,
ByteBuffer
args
,
@Nullable
ByteBuffer
args
,
int
argsPosition
);
...
...
@@ -478,13 +487,13 @@ public class FlutterJNI {
* texture within Flutter's UI.
*/
@UiThread
public
void
registerTexture
(
long
textureId
,
SurfaceTexture
surfaceTexture
)
{
public
void
registerTexture
(
long
textureId
,
@NonNull
SurfaceTexture
surfaceTexture
)
{
ensureRunningOnMainThread
();
ensureAttachedToNative
();
nativeRegisterTexture
(
nativePlatformViewId
,
textureId
,
surfaceTexture
);
}
private
native
void
nativeRegisterTexture
(
long
nativePlatformViewId
,
long
textureId
,
SurfaceTexture
surfaceTexture
);
private
native
void
nativeRegisterTexture
(
long
nativePlatformViewId
,
long
textureId
,
@NonNull
SurfaceTexture
surfaceTexture
);
/**
* Call this method to inform Flutter that a texture previously registered with
...
...
@@ -580,8 +589,9 @@ public class FlutterJNI {
}
// Called by native.
// TODO(mattcarroll): determine if message is nonull or nullable
@SuppressWarnings
(
"unused"
)
private
void
handlePlatformMessage
(
final
String
channel
,
byte
[]
message
,
final
int
replyId
)
{
private
void
handlePlatformMessage
(
@NonNull
final
String
channel
,
byte
[]
message
,
final
int
replyId
)
{
if
(
platformMessageHandler
!=
null
)
{
platformMessageHandler
.
handleMessageFromDart
(
channel
,
message
,
replyId
);
}
...
...
@@ -589,6 +599,7 @@ public class FlutterJNI {
}
// Called by native to respond to a platform message that we sent.
// TODO(mattcarroll): determine if reply is nonull or nullable
@SuppressWarnings
(
"unused"
)
private
void
handlePlatformMessageResponse
(
int
replyId
,
byte
[]
reply
)
{
if
(
platformMessageHandler
!=
null
)
{
...
...
@@ -602,7 +613,7 @@ public class FlutterJNI {
* {@code channel}.
*/
@UiThread
public
void
dispatchEmptyPlatformMessage
(
String
channel
,
int
responseId
)
{
public
void
dispatchEmptyPlatformMessage
(
@NonNull
String
channel
,
int
responseId
)
{
ensureRunningOnMainThread
();
if
(
isAttached
())
{
nativeDispatchEmptyPlatformMessage
(
nativePlatformViewId
,
channel
,
responseId
);
...
...
@@ -614,7 +625,7 @@ public class FlutterJNI {
// Send an empty platform message to Dart.
private
native
void
nativeDispatchEmptyPlatformMessage
(
long
nativePlatformViewId
,
String
channel
,
@NonNull
String
channel
,
int
responseId
);
...
...
@@ -622,7 +633,7 @@ public class FlutterJNI {
* Sends a reply {@code message} from Android to Flutter over the given {@code channel}.
*/
@UiThread
public
void
dispatchPlatformMessage
(
String
channel
,
ByteBuffer
message
,
int
position
,
int
responseId
)
{
public
void
dispatchPlatformMessage
(
@NonNull
String
channel
,
@Nullable
ByteBuffer
message
,
int
position
,
int
responseId
)
{
ensureRunningOnMainThread
();
if
(
isAttached
())
{
nativeDispatchPlatformMessage
(
...
...
@@ -640,8 +651,8 @@ public class FlutterJNI {
// Send a data-carrying platform message to Dart.
private
native
void
nativeDispatchPlatformMessage
(
long
nativePlatformViewId
,
String
channel
,
ByteBuffer
message
,
@NonNull
String
channel
,
@Nullable
ByteBuffer
message
,
int
position
,
int
responseId
);
...
...
@@ -665,7 +676,7 @@ public class FlutterJNI {
// TODO(mattcarroll): differentiate between channel responses and platform responses.
@UiThread
public
void
invokePlatformMessageResponseCallback
(
int
responseId
,
ByteBuffer
message
,
int
position
)
{
public
void
invokePlatformMessageResponseCallback
(
int
responseId
,
@Nullable
ByteBuffer
message
,
int
position
)
{
ensureRunningOnMainThread
();
if
(
isAttached
())
{
nativeInvokePlatformMessageResponseCallback
(
...
...
@@ -683,7 +694,7 @@ public class FlutterJNI {
private
native
void
nativeInvokePlatformMessageResponseCallback
(
long
nativePlatformViewId
,
int
responseId
,
ByteBuffer
message
,
@Nullable
ByteBuffer
message
,
int
position
);
//------- End Platform Message Support ----
...
...
@@ -718,6 +729,7 @@ public class FlutterJNI {
}
//----- End Engine Lifecycle Support ----
// TODO(mattcarroll): determine if this is nonull or nullable
@UiThread
public
Bitmap
getBitmap
()
{
ensureRunningOnMainThread
();
...
...
@@ -725,6 +737,7 @@ public class FlutterJNI {
return
nativeGetBitmap
(
nativePlatformViewId
);
}
// TODO(mattcarroll): determine if this is nonull or nullable
private
native
Bitmap
nativeGetBitmap
(
long
nativePlatformViewId
);
private
void
ensureRunningOnMainThread
()
{
...
...
@@ -749,7 +762,7 @@ public class FlutterJNI {
* Implementers are expected to maintain an Android-side cache of custom accessibility actions.
* This method provides new actions to add to that cache.
*/
void
updateCustomAccessibilityActions
(
ByteBuffer
buffer
,
String
[]
strings
);
void
updateCustomAccessibilityActions
(
@NonNull
ByteBuffer
buffer
,
@NonNull
String
[]
strings
);
/**
* Sends new {@code SemanticsNode} information from Flutter to Android.
...
...
@@ -757,6 +770,6 @@ public class FlutterJNI {
* Implementers are expected to maintain an Android-side cache of Flutter's semantics tree.
* This method provides updates from Flutter for the Android-side semantics tree cache.
*/
void
updateSemantics
(
ByteBuffer
buffer
,
String
[]
strings
);
void
updateSemantics
(
@NonNull
ByteBuffer
buffer
,
@NonNull
String
[]
strings
);
}
}
shell/platform/android/io/flutter/embedding/engine/FlutterShellArgs.java
浏览文件 @
3bcd6a8f
...
...
@@ -92,6 +92,7 @@ public class FlutterShellArgs {
return
new
FlutterShellArgs
(
args
);
}
@NonNull
private
Set
<
String
>
args
;
/**
...
...
shell/platform/android/io/flutter/embedding/engine/dart/DartExecutor.java
浏览文件 @
3bcd6a8f
...
...
@@ -45,7 +45,9 @@ public class DartExecutor implements BinaryMessenger {
@NonNull
private
final
DartMessenger
messenger
;
private
boolean
isApplicationRunning
=
false
;
@Nullable
private
String
isolateServiceId
;
@Nullable
private
IsolateServiceIdListener
isolateServiceIdListener
;
private
final
BinaryMessenger
.
BinaryMessageHandler
isolateChannelMessageHandler
=
...
...
@@ -206,6 +208,7 @@ public class DartExecutor implements BinaryMessenger {
* Returns an identifier for this executor's primary isolate. This identifier can be used
* in queries to the Dart service protocol.
*/
@Nullable
public
String
getIsolateServiceId
()
{
return
isolateServiceId
;
}
...
...
@@ -214,14 +217,14 @@ public class DartExecutor implements BinaryMessenger {
* Callback interface invoked when the isolate identifier becomes available.
*/
interface
IsolateServiceIdListener
{
void
onIsolateServiceIdAvailable
(
String
isolateServiceId
);
void
onIsolateServiceIdAvailable
(
@NonNull
String
isolateServiceId
);
}
/**
* Set a listener that will be notified when an isolate identifier is available for this
* executor's primary isolate.
*/
public
void
setIsolateServiceIdListener
(
IsolateServiceIdListener
listener
)
{
public
void
setIsolateServiceIdListener
(
@Nullable
IsolateServiceIdListener
listener
)
{
isolateServiceIdListener
=
listener
;
if
(
isolateServiceIdListener
!=
null
&&
isolateServiceId
!=
null
)
{
isolateServiceIdListener
.
onIsolateServiceIdAvailable
(
isolateServiceId
);
...
...
shell/platform/android/io/flutter/embedding/engine/dart/DartMessenger.java
浏览文件 @
3bcd6a8f
...
...
@@ -130,7 +130,7 @@ class DartMessenger implements BinaryMessenger, PlatformMessageHandler {
}
@Override
public
void
reply
(
ByteBuffer
reply
)
{
public
void
reply
(
@Nullable
ByteBuffer
reply
)
{
if
(
done
.
getAndSet
(
true
))
{
throw
new
IllegalStateException
(
"Reply already submitted"
);
}
...
...
shell/platform/android/io/flutter/embedding/engine/dart/PlatformMessageHandler.java
浏览文件 @
3bcd6a8f
...
...
@@ -4,12 +4,15 @@
package
io.flutter.embedding.engine.dart
;
import
android.support.annotation.NonNull
;
import
android.support.annotation.Nullable
;
/**
* WARNING: THIS CLASS IS EXPERIMENTAL. DO NOT SHIP A DEPENDENCY ON THIS CODE.
* IF YOU USE IT, WE WILL BREAK YOU.
*/
public
interface
PlatformMessageHandler
{
void
handleMessageFromDart
(
final
String
channel
,
byte
[]
message
,
final
int
replyId
);
void
handleMessageFromDart
(
@NonNull
final
String
channel
,
@Nullable
byte
[]
message
,
final
int
replyId
);
void
handlePlatformMessageResponse
(
int
replyId
,
byte
[]
reply
);
void
handlePlatformMessageResponse
(
int
replyId
,
@Nullable
byte
[]
reply
);
}
shell/platform/android/io/flutter/embedding/engine/plugins/activity/ActivityControlSurface.java
浏览文件 @
3bcd6a8f
...
...
@@ -8,6 +8,7 @@ import android.app.Activity;
import
android.arch.lifecycle.Lifecycle
;
import
android.content.Intent
;
import
android.support.annotation.NonNull
;
import
android.support.annotation.Nullable
;
/**
* Control surface through which an {@link Activity} attaches to a {@link FlutterEngine}.
...
...
@@ -82,7 +83,7 @@ public interface ActivityControlSurface {
* <p>
* Returns true if one or more plugins utilized this {@link Activity} result.
*/
boolean
onActivityResult
(
int
requestCode
,
int
resultCode
,
Intent
data
);
boolean
onActivityResult
(
int
requestCode
,
int
resultCode
,
@Nullable
Intent
data
);
/**
* Call this method from the {@link Activity} that is attached to this {@code ActivityControlSurface}'s
...
...
shell/platform/android/io/flutter/embedding/engine/renderer/FlutterRenderer.java
浏览文件 @
3bcd6a8f
...
...
@@ -105,10 +105,11 @@ public class FlutterRenderer implements TextureRegistry {
final
class
SurfaceTextureRegistryEntry
implements
TextureRegistry
.
SurfaceTextureEntry
{
private
final
long
id
;
@NonNull
private
final
SurfaceTexture
surfaceTexture
;
private
boolean
released
;
SurfaceTextureRegistryEntry
(
long
id
,
SurfaceTexture
surfaceTexture
)
{
SurfaceTextureRegistryEntry
(
long
id
,
@NonNull
SurfaceTexture
surfaceTexture
)
{
this
.
id
=
id
;
this
.
surfaceTexture
=
surfaceTexture
;
...
...
@@ -127,7 +128,7 @@ public class FlutterRenderer implements TextureRegistry {
private
SurfaceTexture
.
OnFrameAvailableListener
onFrameListener
=
new
SurfaceTexture
.
OnFrameAvailableListener
()
{
@Override
public
void
onFrameAvailable
(
SurfaceTexture
texture
)
{
public
void
onFrameAvailable
(
@NonNull
SurfaceTexture
texture
)
{
if
(
released
)
{
// Even though we make sure to unregister the callback before releasing, as of Android O
// SurfaceTexture has a data race when accessing the callback, so the callback may
...
...
@@ -139,6 +140,7 @@ public class FlutterRenderer implements TextureRegistry {
};
@Override
@NonNull
public
SurfaceTexture
surfaceTexture
()
{
return
surfaceTexture
;
}
...
...
@@ -162,7 +164,7 @@ public class FlutterRenderer implements TextureRegistry {
//------ END TextureRegistry IMPLEMENTATION ----
// TODO(mattcarroll): describe the native behavior that this invokes
public
void
surfaceCreated
(
Surface
surface
)
{
public
void
surfaceCreated
(
@NonNull
Surface
surface
)
{
flutterJNI
.
onSurfaceCreated
(
surface
);
}
...
...
@@ -201,17 +203,18 @@ public class FlutterRenderer implements TextureRegistry {
}
// TODO(mattcarroll): describe the native behavior that this invokes
// TODO(mattcarroll): determine if this is nullable or nonnull
public
Bitmap
getBitmap
()
{
return
flutterJNI
.
getBitmap
();
}
// TODO(mattcarroll): describe the native behavior that this invokes
public
void
dispatchPointerDataPacket
(
ByteBuffer
buffer
,
int
position
)
{
public
void
dispatchPointerDataPacket
(
@NonNull
ByteBuffer
buffer
,
int
position
)
{
flutterJNI
.
dispatchPointerDataPacket
(
buffer
,
position
);
}
// TODO(mattcarroll): describe the native behavior that this invokes
private
void
registerTexture
(
long
textureId
,
SurfaceTexture
surfaceTexture
)
{
private
void
registerTexture
(
long
textureId
,
@NonNull
SurfaceTexture
surfaceTexture
)
{
flutterJNI
.
registerTexture
(
textureId
,
surfaceTexture
);
}
...
...
@@ -243,7 +246,7 @@ public class FlutterRenderer implements TextureRegistry {
// TODO(mattcarroll): describe the native behavior that this invokes
public
void
dispatchSemanticsAction
(
int
id
,
int
action
,
ByteBuffer
args
,
@Nullable
ByteBuffer
args
,
int
argsPosition
)
{
flutterJNI
.
dispatchSemanticsAction
(
id
,
...
...
shell/platform/android/io/flutter/embedding/engine/systemchannels/AccessibilityChannel.java
浏览文件 @
3bcd6a8f
...
...
@@ -30,7 +30,7 @@ public class AccessibilityChannel {
private
final
BasicMessageChannel
.
MessageHandler
<
Object
>
parsingMessageHandler
=
new
BasicMessageChannel
.
MessageHandler
<
Object
>()
{
@Override
public
void
onMessage
(
Object
message
,
BasicMessageChannel
.
Reply
<
Object
>
reply
)
{
public
void
onMessage
(
@Nullable
Object
message
,
@NonNull
BasicMessageChannel
.
Reply
<
Object
>
reply
)
{
// If there is no handler to respond to this message then we don't need to
// parse it. Return.
if
(
handler
==
null
)
{
...
...
shell/platform/android/io/flutter/embedding/engine/systemchannels/LocalizationChannel.java
浏览文件 @
3bcd6a8f
...
...
@@ -32,7 +32,7 @@ public class LocalizationChannel {
/**
* Send the given {@code locales} to Dart.
*/
public
void
sendLocales
(
List
<
Locale
>
locales
)
{
public
void
sendLocales
(
@NonNull
List
<
Locale
>
locales
)
{
Log
.
v
(
TAG
,
"Sending Locales to Flutter."
);
List
<
String
>
data
=
new
ArrayList
<>();
for
(
Locale
locale
:
locales
)
{
...
...
shell/platform/android/io/flutter/embedding/engine/systemchannels/NavigationChannel.java
浏览文件 @
3bcd6a8f
...
...
@@ -25,12 +25,12 @@ public class NavigationChannel {
this
.
channel
=
new
MethodChannel
(
dartExecutor
,
"flutter/navigation"
,
JSONMethodCodec
.
INSTANCE
);
}
public
void
setInitialRoute
(
String
initialRoute
)
{
public
void
setInitialRoute
(
@NonNull
String
initialRoute
)
{
Log
.
v
(
TAG
,
"Sending message to set initial route to '"
+
initialRoute
+
"'"
);
channel
.
invokeMethod
(
"setInitialRoute"
,
initialRoute
);
}
public
void
pushRoute
(
String
route
)
{
public
void
pushRoute
(
@NonNull
String
route
)
{
Log
.
v
(
TAG
,
"Sending message to push route '"
+
route
+
"'"
);
channel
.
invokeMethod
(
"pushRoute"
,
route
);
}
...
...
shell/platform/android/io/flutter/embedding/engine/systemchannels/PlatformChannel.java
浏览文件 @
3bcd6a8f
...
...
@@ -35,7 +35,7 @@ public class PlatformChannel {
private
final
MethodChannel
.
MethodCallHandler
parsingMethodCallHandler
=
new
MethodChannel
.
MethodCallHandler
()
{
@Override
public
void
onMethodCall
(
MethodCall
call
,
MethodChannel
.
Result
result
)
{
public
void
onMethodCall
(
@NonNull
MethodCall
call
,
@NonNull
MethodChannel
.
Result
result
)
{
if
(
platformMessageHandler
==
null
)
{
// If no explicit PlatformMessageHandler has been registered then we don't
// need to forward this call to an API. Return.
...
...
@@ -257,6 +257,7 @@ public class PlatformChannel {
return
ActivityInfo
.
SCREEN_ORIENTATION_PORTRAIT
;
}
@NonNull
private
AppSwitcherDescription
decodeAppSwitcherDescription
(
@NonNull
JSONObject
encodedDescription
)
throws
JSONException
{
int
color
=
encodedDescription
.
getInt
(
"primaryColor"
);
if
(
color
!=
0
)
{
// 0 means color isn't set, use system default
...
...
@@ -272,6 +273,7 @@ public class PlatformChannel {
* @throws JSONException if {@code encodedSystemUiOverlay} does not contain expected keys and value types.
* @throws NoSuchFieldException if any of the given encoded overlay names are invalid.
*/
@NonNull
private
List
<
SystemUiOverlay
>
decodeSystemUiOverlays
(
@NonNull
JSONArray
encodedSystemUiOverlay
)
throws
JSONException
,
NoSuchFieldException
{
List
<
SystemUiOverlay
>
overlays
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
encodedSystemUiOverlay
.
length
();
++
i
)
{
...
...
@@ -295,6 +297,7 @@ public class PlatformChannel {
* @throws JSONException if {@code encodedStyle} does not contain expected keys and value types.
* @throws NoSuchFieldException if any provided brightness name is invalid.
*/
@NonNull
private
SystemChromeStyle
decodeSystemChromeStyle
(
@NonNull
JSONObject
encodedStyle
)
throws
JSONException
,
NoSuchFieldException
{
Brightness
systemNavigationBarIconBrightness
=
null
;
// TODO(mattcarroll): add color annotation
...
...
@@ -425,6 +428,7 @@ public class PlatformChannel {
public
enum
SoundType
{
CLICK
(
"SystemSoundType.click"
);
@NonNull
static
SoundType
fromValue
(
@NonNull
String
encodedName
)
throws
NoSuchFieldException
{
for
(
SoundType
soundType
:
SoundType
.
values
())
{
if
(
soundType
.
encodedName
.
equals
(
encodedName
))
{
...
...
@@ -453,6 +457,7 @@ public class PlatformChannel {
HEAVY_IMPACT
(
"HapticFeedbackType.heavyImpact"
),
SELECTION_CLICK
(
"HapticFeedbackType.selectionClick"
);
@NonNull
static
HapticFeedbackType
fromValue
(
@Nullable
String
encodedName
)
throws
NoSuchFieldException
{
for
(
HapticFeedbackType
feedbackType
:
HapticFeedbackType
.
values
())
{
if
((
feedbackType
.
encodedName
==
null
&&
encodedName
==
null
)
...
...
@@ -480,6 +485,7 @@ public class PlatformChannel {
LANDSCAPE_LEFT
(
"DeviceOrientation.landscapeLeft"
),
LANDSCAPE_RIGHT
(
"DeviceOrientation.landscapeRight"
);
@NonNull
static
DeviceOrientation
fromValue
(
@NonNull
String
encodedName
)
throws
NoSuchFieldException
{
for
(
DeviceOrientation
orientation
:
DeviceOrientation
.
values
())
{
if
(
orientation
.
encodedName
.
equals
(
encodedName
))
{
...
...
@@ -508,6 +514,7 @@ public class PlatformChannel {
TOP_OVERLAYS
(
"SystemUiOverlay.top"
),
BOTTOM_OVERLAYS
(
"SystemUiOverlay.bottom"
);
@NonNull
static
SystemUiOverlay
fromValue
(
@NonNull
String
encodedName
)
throws
NoSuchFieldException
{
for
(
SystemUiOverlay
overlay
:
SystemUiOverlay
.
values
())
{
if
(
overlay
.
encodedName
.
equals
(
encodedName
))
{
...
...
@@ -578,6 +585,7 @@ public class PlatformChannel {
LIGHT
(
"Brightness.light"
),
DARK
(
"Brightness.dark"
);
@NonNull
static
Brightness
fromValue
(
@NonNull
String
encodedName
)
throws
NoSuchFieldException
{
for
(
Brightness
brightness
:
Brightness
.
values
())
{
if
(
brightness
.
encodedName
.
equals
(
encodedName
))
{
...
...
@@ -601,7 +609,8 @@ public class PlatformChannel {
public
enum
ClipboardContentFormat
{
PLAIN_TEXT
(
"text/plain"
);
static
ClipboardContentFormat
fromValue
(
String
encodedName
)
throws
NoSuchFieldException
{
@NonNull
static
ClipboardContentFormat
fromValue
(
@NonNull
String
encodedName
)
throws
NoSuchFieldException
{
for
(
ClipboardContentFormat
format
:
ClipboardContentFormat
.
values
())
{
if
(
format
.
encodedName
.
equals
(
encodedName
))
{
return
format
;
...
...
shell/platform/android/io/flutter/embedding/engine/systemchannels/PlatformViewsChannel.java
浏览文件 @
3bcd6a8f
...
...
@@ -38,7 +38,7 @@ public class PlatformViewsChannel {
private
final
MethodChannel
.
MethodCallHandler
parsingHandler
=
new
MethodChannel
.
MethodCallHandler
()
{
@Override
public
void
onMethodCall
(
MethodCall
call
,
MethodChannel
.
Result
result
)
{
public
void
onMethodCall
(
@NonNull
MethodCall
call
,
@NonNull
MethodChannel
.
Result
result
)
{
// If there is no handler to respond to this message then we don't need to
// parse it. Return.
if
(
handler
==
null
)
{
...
...
@@ -70,7 +70,7 @@ public class PlatformViewsChannel {
}
}
private
void
create
(
MethodCall
call
,
MethodChannel
.
Result
result
)
{
private
void
create
(
@NonNull
MethodCall
call
,
@NonNull
MethodChannel
.
Result
result
)
{
Map
<
String
,
Object
>
createArgs
=
call
.
arguments
();
PlatformViewCreationRequest
request
=
new
PlatformViewCreationRequest
(
(
int
)
createArgs
.
get
(
"id"
),
...
...
@@ -187,7 +187,7 @@ public class PlatformViewsChannel {
}
}
private
void
clearFocus
(
MethodCall
call
,
MethodChannel
.
Result
result
)
{
private
void
clearFocus
(
@NonNull
MethodCall
call
,
@NonNull
MethodChannel
.
Result
result
)
{
int
viewId
=
call
.
arguments
();
try
{
handler
.
clearFocus
(
viewId
);
...
...
shell/platform/android/io/flutter/embedding/engine/systemchannels/SettingsChannel.java
浏览文件 @
3bcd6a8f
...
...
@@ -17,35 +17,42 @@ public class SettingsChannel {
private
static
final
String
TEXT_SCALE_FACTOR
=
"textScaleFactor"
;
private
static
final
String
ALWAYS_USE_24_HOUR_FORMAT
=
"alwaysUse24HourFormat"
;
private
static
final
String
PLATFORM_BRIGHTNESS
=
"platformBrightness"
;
@NonNull
public
final
BasicMessageChannel
<
Object
>
channel
;
public
SettingsChannel
(
@NonNull
DartExecutor
dartExecutor
)
{
this
.
channel
=
new
BasicMessageChannel
<>(
dartExecutor
,
CHANNEL_NAME
,
JSONMessageCodec
.
INSTANCE
);
}
@NonNull
public
MessageBuilder
startMessage
()
{
return
new
MessageBuilder
(
channel
);
}
public
static
class
MessageBuilder
{
@NonNull
private
final
BasicMessageChannel
<
Object
>
channel
;
@NonNull
private
Map
<
String
,
Object
>
message
=
new
HashMap
<>();
MessageBuilder
(
@NonNull
BasicMessageChannel
<
Object
>
channel
)
{
this
.
channel
=
channel
;
}
@NonNull
public
MessageBuilder
setTextScaleFactor
(
float
textScaleFactor
)
{
message
.
put
(
TEXT_SCALE_FACTOR
,
textScaleFactor
);
return
this
;
}
@NonNull
public
MessageBuilder
setUse24HourFormat
(
boolean
use24HourFormat
)
{
message
.
put
(
ALWAYS_USE_24_HOUR_FORMAT
,
use24HourFormat
);
return
this
;
}
@NonNull
public
MessageBuilder
setPlatformBrightness
(
@NonNull
PlatformBrightness
brightness
)
{
message
.
put
(
PLATFORM_BRIGHTNESS
,
brightness
.
name
);
return
this
;
...
...
@@ -69,7 +76,8 @@ public class SettingsChannel {
public
enum
PlatformBrightness
{
light
(
"light"
),
dark
(
"dark"
);
@NonNull
public
String
name
;
PlatformBrightness
(
@NonNull
String
name
)
{
...
...
shell/platform/android/io/flutter/embedding/engine/systemchannels/TextInputChannel.java
浏览文件 @
3bcd6a8f
...
...
@@ -41,7 +41,7 @@ public class TextInputChannel {
private
final
MethodChannel
.
MethodCallHandler
parsingMethodHandler
=
new
MethodChannel
.
MethodCallHandler
()
{
@Override
public
void
onMethodCall
(
MethodCall
call
,
MethodChannel
.
Result
result
)
{
public
void
onMethodCall
(
@NonNull
MethodCall
call
,
@NonNull
MethodChannel
.
Result
result
)
{
if
(
textInputMethodHandler
==
null
)
{
// If no explicit TextInputMethodHandler has been registered then we don't
// need to forward this call to an API. Return.
...
...
@@ -278,6 +278,7 @@ public class TextInputChannel {
);
}
@NonNull
private
static
Integer
inputActionFromTextInputAction
(
@NonNull
String
inputAction
)
{
switch
(
inputAction
)
{
case
"TextInputAction.newline"
:
...
...
shell/platform/android/io/flutter/plugin/common/BasicMessageChannel.java
浏览文件 @
3bcd6a8f
...
...
@@ -4,6 +4,8 @@
package
io.flutter.plugin.common
;
import
android.support.annotation.NonNull
;
import
android.support.annotation.Nullable
;
import
android.support.annotation.UiThread
;
import
android.util.Log
;
import
java.nio.ByteBuffer
;
...
...
@@ -28,8 +30,11 @@ import io.flutter.plugin.common.BinaryMessenger.BinaryMessageHandler;
public
final
class
BasicMessageChannel
<
T
>
{
private
static
final
String
TAG
=
"BasicMessageChannel#"
;
@NonNull
private
final
BinaryMessenger
messenger
;
@NonNull
private
final
String
name
;
@NonNull
private
final
MessageCodec
<
T
>
codec
;
/**
...
...
@@ -40,7 +45,7 @@ public final class BasicMessageChannel<T> {
* @param name a channel name String.
* @param codec a {@link MessageCodec}.
*/
public
BasicMessageChannel
(
BinaryMessenger
messenger
,
String
name
,
MessageCodec
<
T
>
codec
)
{
public
BasicMessageChannel
(
@NonNull
BinaryMessenger
messenger
,
@NonNull
String
name
,
@NonNull
MessageCodec
<
T
>
codec
)
{
if
(
BuildConfig
.
DEBUG
)
{
if
(
messenger
==
null
)
{
Log
.
e
(
TAG
,
"Parameter messenger must not be null."
);
...
...
@@ -62,7 +67,7 @@ public final class BasicMessageChannel<T> {
*
* @param message the message, possibly null.
*/
public
void
send
(
T
message
)
{
public
void
send
(
@Nullable
T
message
)
{
send
(
message
,
null
);
}
...
...
@@ -75,7 +80,7 @@ public final class BasicMessageChannel<T> {
* @param callback a {@link Reply} callback, possibly null.
*/
@UiThread
public
void
send
(
T
message
,
final
Reply
<
T
>
callback
)
{
public
void
send
(
@Nullable
T
message
,
@Nullable
final
Reply
<
T
>
callback
)
{
messenger
.
send
(
name
,
codec
.
encodeMessage
(
message
),
callback
==
null
?
null
:
new
IncomingReplyHandler
(
callback
));
}
...
...
@@ -92,7 +97,7 @@ public final class BasicMessageChannel<T> {
* @param handler a {@link MessageHandler}, or null to deregister.
*/
@UiThread
public
void
setMessageHandler
(
final
MessageHandler
<
T
>
handler
)
{
public
void
setMessageHandler
(
@Nullable
final
MessageHandler
<
T
>
handler
)
{
messenger
.
setMessageHandler
(
name
,
handler
==
null
?
null
:
new
IncomingMessageHandler
(
handler
));
}
...
...
@@ -119,7 +124,7 @@ public final class BasicMessageChannel<T> {
* @param message the message, possibly null.
* @param reply a {@link Reply} for sending a single message reply back to Flutter.
*/
void
onMessage
(
T
message
,
Reply
<
T
>
reply
);
void
onMessage
(
@Nullable
T
message
,
@NonNull
Reply
<
T
>
reply
);
}
/**
...
...
@@ -133,18 +138,18 @@ public final class BasicMessageChannel<T> {
*
* @param reply the reply, possibly null.
*/
void
reply
(
T
reply
);
void
reply
(
@Nullable
T
reply
);
}
private
final
class
IncomingReplyHandler
implements
BinaryReply
{
private
final
Reply
<
T
>
callback
;
private
IncomingReplyHandler
(
Reply
<
T
>
callback
)
{
private
IncomingReplyHandler
(
@NonNull
Reply
<
T
>
callback
)
{
this
.
callback
=
callback
;
}
@Override
public
void
reply
(
ByteBuffer
reply
)
{
public
void
reply
(
@Nullable
ByteBuffer
reply
)
{
try
{
callback
.
reply
(
codec
.
decodeMessage
(
reply
));
}
catch
(
RuntimeException
e
)
{
...
...
@@ -156,12 +161,12 @@ public final class BasicMessageChannel<T> {
private
final
class
IncomingMessageHandler
implements
BinaryMessageHandler
{
private
final
MessageHandler
<
T
>
handler
;
private
IncomingMessageHandler
(
MessageHandler
<
T
>
handler
)
{
private
IncomingMessageHandler
(
@NonNull
MessageHandler
<
T
>
handler
)
{
this
.
handler
=
handler
;
}
@Override
public
void
onMessage
(
ByteBuffer
message
,
final
BinaryReply
callback
)
{
public
void
onMessage
(
@Nullable
ByteBuffer
message
,
@NonNull
final
BinaryReply
callback
)
{
try
{
handler
.
onMessage
(
codec
.
decodeMessage
(
message
),
new
Reply
<
T
>()
{
@Override
...
...
shell/platform/android/io/flutter/plugin/common/BinaryMessenger.java
浏览文件 @
3bcd6a8f
...
...
@@ -4,6 +4,8 @@
package
io.flutter.plugin.common
;
import
android.support.annotation.NonNull
;
import
android.support.annotation.Nullable
;
import
android.support.annotation.UiThread
;
import
java.nio.ByteBuffer
;
...
...
@@ -32,7 +34,7 @@ public interface BinaryMessenger {
* between position zero and current position, or null.
*/
@UiThread
void
send
(
String
channel
,
ByteBuffer
message
);
void
send
(
@NonNull
String
channel
,
@Nullable
ByteBuffer
message
);
/**
* Sends a binary message to the Flutter application, optionally expecting a reply.
...
...
@@ -46,7 +48,7 @@ public interface BinaryMessenger {
* message, possibly null.
*/
@UiThread
void
send
(
String
channel
,
ByteBuffer
message
,
BinaryReply
callback
);
void
send
(
@NonNull
String
channel
,
@Nullable
ByteBuffer
message
,
@Nullable
BinaryReply
callback
);
/**
* Registers a handler to be invoked when the Flutter application sends a message
...
...
@@ -62,7 +64,7 @@ public interface BinaryMessenger {
* @param handler a {@link BinaryMessageHandler} to be invoked on incoming messages, or null.
*/
@UiThread
void
setMessageHandler
(
String
channel
,
BinaryMessageHandler
handler
);
void
setMessageHandler
(
@NonNull
String
channel
,
@Nullable
BinaryMessageHandler
handler
);
/**
* Handler for incoming binary messages from Flutter.
...
...
@@ -82,7 +84,7 @@ public interface BinaryMessenger {
* @param reply A {@link BinaryReply} used for submitting a reply back to Flutter.
*/
@UiThread
void
onMessage
(
ByteBuffer
message
,
BinaryReply
reply
);
void
onMessage
(
@Nullable
ByteBuffer
message
,
@NonNull
BinaryReply
reply
);
}
/**
...
...
@@ -99,6 +101,6 @@ public interface BinaryMessenger {
* Reply receivers can read from the buffer directly.
*/
@UiThread
void
reply
(
ByteBuffer
reply
);
void
reply
(
@Nullable
ByteBuffer
reply
);
}
}
shell/platform/android/io/flutter/plugin/common/MessageCodec.java
浏览文件 @
3bcd6a8f
...
...
@@ -4,6 +4,8 @@
package
io.flutter.plugin.common
;
import
android.support.annotation.Nullable
;
import
java.nio.ByteBuffer
;
/**
...
...
@@ -19,7 +21,8 @@ public interface MessageCodec<T> {
* @return a ByteBuffer containing the encoding between position 0 and
* the current position, or null, if message is null.
*/
ByteBuffer
encodeMessage
(
T
message
);
@Nullable
ByteBuffer
encodeMessage
(
@Nullable
T
message
);
/**
* Decodes the specified message from binary.
...
...
@@ -28,5 +31,6 @@ public interface MessageCodec<T> {
* @return a T value representation of the bytes between the given buffer's current
* position and its limit, or null, if message is null.
*/
T
decodeMessage
(
ByteBuffer
message
);
@Nullable
T
decodeMessage
(
@Nullable
ByteBuffer
message
);
}
shell/platform/android/io/flutter/plugin/common/MethodChannel.java
浏览文件 @
3bcd6a8f
...
...
@@ -142,7 +142,7 @@ public final class MethodChannel {
* @param result A {@link Result} used for submitting the result of the call.
*/
@UiThread
void
onMethodCall
(
MethodCall
call
,
Result
result
);
void
onMethodCall
(
@NonNull
MethodCall
call
,
@NonNull
Result
result
);
}
/**
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录