Programming Guide
The Galaxy Performance SDK enables you to develop applications that can request and respond to system resource availability.
Prerequisites
To enable your application to use the Galaxy Performance SDK functionalities:
-
Add the Galaxy Performance SDK library to your application project:
- In Android Studio, copy the Galaxy Performance SDK ".jar" file to the “libs” folder in the project. Right-click the file and select "Add as Library".
- In Eclipse:
a. Right-click the project and select "Properties > Java Build Path > Libraries".
b. Select "Add External JARs", select the Galaxy Performance SDK ".jar" file on your computer, and select "Open".
c. In the "Order and Export" tab, fill the checkbox for the Galaxy Performance SDK library.
d. Apply your changes.
- In Android Studio, copy the Galaxy Performance SDK ".jar" file to the “libs” folder in the project. Right-click the file and select "Add as Library".
-
To use the Socket to communicate with the system daemon, the application has to request permission to modify the Internet settings in the “AndroidManifest.xml” file:
<uses-permission android:name="android.permission.INTERNET"/>
Managing Hardware Resource Usage
-
Import the Galaxy Performance SDK classes:
import com.samsung.sdk.sperf.CustomParams; import com.samsung.sdk.sperf.PerformanceManager; import com.samsung.sdk.sperf.SPerf;
-
To use the Galaxy Performance SDK features in the application, initialize the
SPerf
class:SPerf.setDebugModeEnabled(true); // optional - default is false SPerf.initialize(this.getApplicationContext());
-
To control system resource usage, create an instance of the
PerformanceManager
class:PerformanceManager pm = PerformanceManager.getInstance();
-
To start a preset performance control defined in the Galaxy Performance SDK library:
pm.start(PRESET_TYPE_GPU, 3000);
The following table lists the available presets:
Preset Description PRESET_TYPE_CPU CPU intensive scenario PRESET_TYPE_GPU GPU intensive scenario PRESET_TYPE_BUS I/O or memory access-intensive scenario To use multiple presets simultaneously, you can combine them with the vertical bar character. For example,
PRESET_TYPE_CPU | PRESET_TYPE_BUS
. -
To define a custom performance control parameter, add the parameter, its value, and its timeout duration to a
CustomParams
class instance. TheCustomParams
class instance is reusable, as long as the controlled parameter is the same.CustomParams params = new CustomParams(); params.add(CustomParams.TYPE_CPU_MIN, 2, 3000);
-
To start a custom performance control:
pm.start(params);
-
A performance control automatically stops when the timeout duration is reached. To stop all currently running performance controls:
pm.stop();