--- /dev/null
+/*
+* Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+using System;
+
+using Tizen.Common;
+using System.ComponentModel;
+
+namespace Tizen.System
+{
+ /// <summary>
+ /// This class represents the type of event for backends. This class can be converted from the string type.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public class PerformanceControlType
+ {
+ /// <summary>
+ /// Pre-defined event type "PreCreated".
+ /// </summary>
+ public static readonly PerformanceControlType AppLaunchHome = new PerformanceControlType("AppLaunchHome");
+
+ /// <summary>
+ /// Pre-defined event type "HomeScreen".
+ /// </summary>
+ public static readonly PerformanceControlType HomeScreen = new PerformanceControlType("HomeScreen");
+
+ private string _typeName;
+
+ /// <summary>
+ /// Initializes the PerformanceControlType class.
+ /// </summary>
+ /// <param name="name">The name of event type.</param>
+ private PerformanceControlType(string name) {
+ _typeName = name;
+ }
+
+ /// <summary>
+ /// Returns the name of event type.
+ /// </summary>
+ public override string ToString() {
+ return _typeName;
+ }
+
+ /// <summary>
+ /// Returns the hash code for event type string.
+ /// </summary>
+ public override int GetHashCode() {
+ if (_typeName == null) return 0;
+ return _typeName.GetHashCode();
+ }
+
+ /// <summary>
+ /// Determines whether this instance and a specified object.
+ /// </summary>
+ public override bool Equals(object obj) {
+ PerformanceControlType other = obj as PerformanceControlType;
+ return other != null && other._typeName == this._typeName;
+ }
+ }
+}
--- /dev/null
+/*
+* Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+using System;
+
+using Tizen.Common;
+using System.Collections.Generic;
+using System.ComponentModel;
+
+namespace Tizen.System
+{
+ /// <summary>
+ /// The PerformanceController class provides the methods to control the system resources.
+ /// </summary>
+ /// <remarks>
+ /// It supports to control cpu clock within input timeout.
+ /// </remarks>
+ /// <privilege>
+ /// </privilege>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static class PerformanceController
+ {
+ private delegate int PerformanceControlFunc(int timeout);
+ private static readonly Dictionary<PerformanceControlType, PerformanceControlFunc> PerformanceControlFunctions = new Dictionary<PerformanceControlType, PerformanceControlFunc>
+ {
+ {PerformanceControlType.AppLaunchHome, Interop.Device.DevicePmQosAppLaunchHome},
+ {PerformanceControlType.HomeScreen, Interop.Device.DevicePmQosHomeScreen},
+ /* Add Here */
+ };
+
+ /// <summary>
+ /// Increase the cpu clock within timeout.
+ /// </summary>
+ /// <param name="type">Performance Control Type</param>
+ /// <param name="timeout">Cpu clock increasing duration in milliseconds.</param>
+ /// <exception cref="ArgumentException">When an invalid parameter value is set.</exception>
+ /// <exception cref="InvalidOperationException">In case of any system error.</exception>
+ /// <exception cref="NotSupportedException">In case the device does not support this behavior.</exception>
+ /// <example>
+ /// <code>
+ /// try
+ /// {
+ /// PerformanceController.Request(PerformanceControlType.AppLaunchHome, 100);
+ /// }
+ /// Catch(Exception e)
+ /// {
+ /// }
+ /// </code>
+ /// </example>
+ public static void Request(PerformanceControlType type, int timeout) {
+ PerformanceControlFunc func = null;
+
+ if (!PerformanceControlFunctions.TryGetValue(type, out func))
+ throw new ArgumentException("Invalid Arguments");
+
+ DeviceError res = (DeviceError)func(timeout);
+
+ if (res != DeviceError.None) {
+ throw DeviceExceptionFactory.CreateException(res, "unable to transmit PmQos command.");
+ }
+ }
+ }
+}
internal static extern int DeviceAddCallback(Tizen.System.EventType type, deviceCallback cb, IntPtr data);
[DllImport(Libraries.Device, EntryPoint = "device_remove_callback", CallingConvention = CallingConvention.Cdecl)]
internal static extern int DeviceRemoveCallback(Tizen.System.EventType type, deviceCallback cb);
+
+ //PmQos
+ [DllImport(Libraries.Device, EntryPoint = "device_pmqos_app_launch_home", CallingConvention = CallingConvention.Cdecl)]
+ internal static extern int DevicePmQosAppLaunchHome(int timeout);
+ [DllImport(Libraries.Device, EntryPoint = "device_pmqos_homescreen", CallingConvention = CallingConvention.Cdecl)]
+ internal static extern int DevicePmQosHomeScreen(int timeout);
}
}