• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 package io.flutter.embedding.engine.systemchannels;
6 
7 import android.support.annotation.NonNull;
8 
9 import java.util.HashMap;
10 import java.util.Map;
11 
12 import io.flutter.Log;
13 import io.flutter.embedding.engine.dart.DartExecutor;
14 import io.flutter.plugin.common.BasicMessageChannel;
15 import io.flutter.plugin.common.JSONMessageCodec;
16 
17 /**
18  * TODO(mattcarroll): fill in javadoc for SystemChannel.
19  */
20 public class SystemChannel {
21   private static final String TAG = "SystemChannel";
22 
23   @NonNull
24   public final BasicMessageChannel<Object> channel;
25 
SystemChannel(@onNull DartExecutor dartExecutor)26   public SystemChannel(@NonNull DartExecutor dartExecutor) {
27     this.channel = new BasicMessageChannel<>(dartExecutor, "flutter/system", JSONMessageCodec.INSTANCE);
28   }
29 
sendMemoryPressureWarning()30   public void sendMemoryPressureWarning() {
31     Log.v(TAG, "Sending memory pressure warning to Flutter.");
32     Map<String, Object> message = new HashMap<>(1);
33     message.put("type", "memoryPressure");
34     channel.send(message);
35   }
36 
37 }
38