예제 #1
0
 public static void Info(
     string message,
     [CallerFilePath] string file   = "",
     [CallerMemberName] string func = "",
     [CallerLineNumber] int line    = 0)
 {
     InternalLog.Info(LogTag, message, file, func, line);
 }
예제 #2
0
        protected override void OnCreate()
        {
            base.OnCreate();

            // Read engine arguments passed from the tool.
            ParseEngineArgs();
            InternalLog.Info(LogTag, $"switches: {string.Join(" ", EngineArgs)}");

            // Get the screen size of the currently running device.
            if (!Information.TryGetValue("http://tizen.org/feature/screen.width", out int width) ||
                !Information.TryGetValue("http://tizen.org/feature/screen.height", out int height))
            {
                InternalLog.Error(LogTag, "Could not obtain the screen size.");
                return;
            }
            var windowProperties = new FlutterWindowProperties
            {
                width  = width,
                height = height
            };

            // Get paths to resources required for launch.
            string resPath     = Current.DirectoryInfo.Resource;
            string assetsPath  = $"{resPath}/flutter_assets";
            string icuDataPath = $"{resPath}/icudtl.dat";
            string arch        = RuntimeInformation.ProcessArchitecture switch
            {
                Architecture.X86 => "x86",
                Architecture.X64 => "x64",
                Architecture.Arm => "arm",
                Architecture.Arm64 => "aarch64",
                _ => "",
            };
            string aotLibPath = $"{resPath}/../lib/{arch}/libapp.so";

            using var switches = new StringArray(EngineArgs);
            var engineProperties = new FlutterEngineProperties
            {
                assets_path      = assetsPath,
                icu_data_path    = icuDataPath,
                aot_library_path = aotLibPath,
                switches         = switches.Handle,
                switches_count   = (uint)switches.Length,
            };

            Handle = FlutterCreateWindow(ref windowProperties, ref engineProperties);
            if (Handle.IsInvalid)
            {
                throw new Exception("Could not launch a Flutter application.");
            }
        }
예제 #3
0
            private void ReleaseUnusedResourceCaches()
            {
                if (m_UnretainedResourceCaches.Count <= 0)
                {
                    return;
                }

                bool releaseAll = true;

                // We need all resources (AssetBundles) that have dependencies between each other to be released/unloaded at the same time;
                // Otherwise, there will be occasional but confusing asset missing issues.
                // Here we use the simplest strategy. Once all unretained resources can be released safely, we do it all. Otherwise, we don't release any.
                foreach (var resourceCache in m_UnretainedResourceCaches)
                {
                    if (!resourceCache.CanRelease())
                    {
                        InternalLog.Info($"[AssetModule.Loader ReleaseUnusedResourceCaches] Cannot release {resourceCache.Path}. Drop.");
                        releaseAll = false;
                        break;
                    }
                }

                if (!releaseAll)
                {
                    return;
                }

                InternalLog.Info($"[AssetModule.Loader ReleaseUnusedResourceCaches] Release {m_UnretainedResourceCaches.Count} resources.");
                foreach (var resourceCache in m_UnretainedResourceCaches)
                {
                    // if (resourceCache.Status.ToString().StartsWith("Waiting"))
                    // {
                    //     InternalLog.Warning($"{resourceCache.Status}, {resourceCache.Path}");
                    // }
                    m_ResourceCaches.Remove(resourceCache.Path);
                    m_WaitingForSlotResourceCaches.Remove(resourceCache);
                    resourceCache.Reset();
                    m_ResourceCachePool.Release(resourceCache);
                }

                m_UnretainedResourceCaches.Clear();
            }
예제 #4
0
        protected DtoServiceProxy CreateDtoService(string accountName)
        {
            if (string.IsNullOrEmpty(accountName))
            {
                throw new ResponseCodeException(ResponseCode.EmptyAccountName, "Не указан AccountName");
            }

            Uri apiUrl = null;

            if (!string.IsNullOrEmpty(Config.Access.Url))
            {
                try
                {
                    apiUrl = new Uri(Config.Access.Url);
                }
                catch (UriFormatException exception)
                {
                    throw new ResponseCodeException(ResponseCode.ApiUrlFormatError, "Неверный формат адреса Api: " + exception.Message);
                }
            }
            else
            {
                try
                {
                    apiUrl = ApiHelper.GetApiUrl(accountName);
                }
                catch (UriFormatException exception)
                {
                    throw new ResponseCodeException(ResponseCode.AccountNameFormatError, "Неверный формат имени аккаунта: " + exception.Message);
                }
            }

            InternalLog.Info("ApiUrl: " + apiUrl.AbsoluteUri);

            var dtoService = new DtoServiceProxy(apiUrl);

            return(dtoService);
        }
예제 #5
0
        private void ParseEngineArgs()
        {
            string appId    = Current.ApplicationInfo.ApplicationId;
            string tempPath = $"/home/owner/share/tmp/sdk_tools/{appId}.rpm";

            if (!File.Exists(tempPath))
            {
                return;
            }
            try
            {
                var lines = File.ReadAllText(tempPath).Trim().Split("\n");
                foreach (string line in lines)
                {
                    InternalLog.Info(LogTag, $"Enabled: {line}");
                    EngineArgs.Add(line);
                }
                File.Delete(tempPath);
            }
            catch (Exception ex)
            {
                InternalLog.Warn(LogTag, $"Error while processing a file: {ex}");
            }
        }
예제 #6
0
        protected override void OnCreate()
        {
            base.OnCreate();

            // Read the current platform version and choose a Tizen 4.0 embedder if applicable.
            Information.TryGetValue("http://tizen.org/feature/platform.version", out PlatformVersion);

            // Read engine arguments passed from the tool.
            ParseEngineArgs();
            InternalLog.Info(LogTag, $"switches: {string.Join(" ", EngineArgs)}");

            // Get the screen size of the currently running device.
            if (!Information.TryGetValue("http://tizen.org/feature/screen.width", out int width) ||
                !Information.TryGetValue("http://tizen.org/feature/screen.height", out int height))
            {
                InternalLog.Error(LogTag, "Could not obtain the screen size.");
                return;
            }
            var windowProperties = new FlutterWindowProperties
            {
                width  = width,
                height = height
            };

            // Get paths to resources required for launch.
            string resPath     = Current.DirectoryInfo.Resource;
            string assetsPath  = $"{resPath}/flutter_assets";
            string icuDataPath = $"{resPath}/icudtl.dat";
            string arch        = RuntimeInformation.ProcessArchitecture switch
            {
                Architecture.X86 => "x86",
                Architecture.X64 => "x64",
                Architecture.Arm => "arm",
                Architecture.Arm64 => "aarch64",
                _ => "",
            };
            string aotLibPath = $"{resPath}/../lib/{arch}/libapp.so";

            using var switches = new StringArray(EngineArgs);
            var engineProperties = new FlutterEngineProperties
            {
                assets_path      = assetsPath,
                icu_data_path    = icuDataPath,
                aot_library_path = aotLibPath,
                switches         = switches.Handle,
                switches_count   = (uint)switches.Length,
            };

            // This check is not actually required, but we want to make sure that libflutter_engine.so is loaded
            // before a call to FlutterCreateWindow() is made to avoid library loading issues on TV emulator.
            if (FlutterEngineRunsAOTCompiledDartCode())
            {
                InternalLog.Debug(LogTag, "Running in AOT mode.");
            }

            Handle = FlutterCreateWindow(ref windowProperties, ref engineProperties);
            if (Handle.IsInvalid)
            {
                throw new Exception("Could not launch a Flutter application.");
            }
        }