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:

  1. 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".
      Figure: Add the library to Android Studio
    • 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".
      Figure: External JAR added to Libraries tab
      c. In the "Order and Export" tab, fill the checkbox for the Galaxy Performance SDK library.
      Figure: Enable the Galaxy Performance SDK library
      d. Apply your changes.
  2. 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

  1. Import the Galaxy Performance SDK classes:

     import com.samsung.sdk.sperf.CustomParams;
     import com.samsung.sdk.sperf.PerformanceManager;
     import com.samsung.sdk.sperf.SPerf;
    
  2. 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());
    
  3. To control system resource usage, create an instance of the PerformanceManager class:

     PerformanceManager pm = PerformanceManager.getInstance();
    
  4. 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.

  5. To define a custom performance control parameter, add the parameter, its value, and its timeout duration to a CustomParams class instance. The CustomParams 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);
    
  6. To start a custom performance control:

    pm.start(params);
    
  7. A performance control automatically stops when the timeout duration is reached. To stop all currently running performance controls:

    pm.stop();