/MiBridge

Primary LanguageJavaApache License 2.0Apache-2.0

MiBridge
MiSpeed

Powerful yet simple to use .

GNU/Linux Build Status Windows Build Status MacOS Build Status Nightly Build

MiSpeed

Other language versions

简体中文

Index

Our Purpose

All for users, make users getting the best experience!

Introduction

Xiaomi Application Accelerator (MiSpeed) provides developers with the interface to apply for system resources,
which can improve the performance of developers in key application scenarios and enhance the user experience.

Our Advantages

  • Lightweight Access
    Accessing through JAR file, the size is only a few KB, which will not burden developers' applications.
  • Fast System Communication
    Communicate with the system layer directly through binder, request system resources, fast and efficient.
  • Scenario Customization
    Provide different levels of system resources in different scenarios.

Access Note

MiBridge.jar
  You can import this jar.
TestMiBridge
  Inclued:
  mibridge: Source code of MiBridge.jar
  app: Testing application code.

Applying for debugging permission

Please provide the following information and send it to xiaomi-mispeed-support@xiaomi.com to apply for debugging permission.
Subject:xx Company,Applying for MiSpeed debugging permission。

PackageName CompanyName Requestor Device model MIUI version VAID num
com.mi.testmibridge Xx Tony Redmi K20 Pro MIUI 11 20.3.5 Beta ec8ec830b8e8031c

We will reply you with an authentication code for debugging.

Note: What is VAID, how to get it?

  1. VAID means Vender Anonymous Device ID
  2. Refer http://msa-alliance.cn/col.jsp?id=120
  3. You can refer to the example in TestMiBridge. (Testing getVAID)

Support Devices

Use maven dependency

1.Configure the Maven repository address of Xiaomi App Accelerator

Open the Android Studio project-level "build.gradle" file. Configure the Maven repository address of Xiaomi App Accelerator in "allprojects > repositories".

allprojects {
 repositories {
        ...
  //增加小米应用加速器的Maven仓库地址
  maven {
    url "https://repos.xiaomi.com/maven"
    credentials {
      username 'mi-bridge'
      password 'AKCp8nH4XbDQshne9w5PgaLroZ7kozqtAPo6Kw6pfZLBWzPEtAJoFzU73RHryxXkmcL5biUL2'
      }
    }
  }
}

2. Add compilation dependencies

Open the app-level "build.gradle" file.

dependencies {
    ...
    //1.0.xx is the version number of mibridge. Subsequent upgrades should also modify the corresponding version number.
    implementation "com.xiaomi.mibridge:mibridge:1.0.18"
    ...
}

APIs

Permission apis

  1. boolean checkDebugPermission(Context context, String pkg, int uid, String auth_key)
    Description:Check whether the application has debugging permission.

    parameters:
    context : application context
    pkg : Package Name
    uid : android.os.Process.myUid()
    auth_key : authentication code

    return value:
    true : Permission granted
    false : Permission not granted

  2. boolean checkPermission(String pkg, int uid)
    Description:Check whether the application has formal permission,please refer 3.Applying for fromal permission
    After obtaining the formal permission, use this interface to check the permission without using the authentication code.

    parameters:
    pkg : Package Name
    uid : android.os.Process.myUid()

    return value:
    true: Permission granted
    false: Permission not granted

APIs for request system resouce

  1. int requestCpuHighFreq(int uid, int level, int timeoutms)
    Description: Reqeust CPU frequency

    parameters:
    uid : android.os.Process.myUid()
    level : Expected cpu frequency level,system will set different CPU frequency according to different models

    Level Explanation (take Xiaomi 8 as an example)
    1 Level 1 Set the CPU frequency to MAX
    2 Level 2 Set the CPU frequency to higher
    example:Xiaomi 8, Set big core at least 2.2GHz, little core at least 1.5GHz
    3 Level 3 Set the CPU frequency to above normal
    example:Xiaomi 8, Set big core at least 1.9GHz, little core at least 1.0GHz

    Attention:Please using Level 1 with caution。Level 1 scenarios is limited to 5,
    Level 2 is limited to 20,Level 3 no limits。
    timeoutms : duration

    return value:
    0: Success
    -1: Fail
    -2: Permission not granted!

  2. int cancelCpuHighFreq(int uid)
    Description:Cancle cpu frequency request

    parameters:
    uid : android.os.Process.myUid()

    return value:
    0: Success
    -1: Fail
    -2: Permission not granted!

  3. int requestThreadPriority(int uid, int req_tid, int timeoutms)
    Description:Request thread for higher priority, running in big core.

    parameters:
    uid : android.os.Process.myUid()
    req_tid : thread id
    timeoutms : duration

    return value:
    0: Success
    -1: Fail
    -2: Permission not granted!

  4. int cancelThreadPriority (int uid, int req_tid)
    Description:Cancel request

    parameters:
    uid : android.os.Process.myUid()
    req_tid : thread id

    return value:
    0: Success
    -1: Fail
    -2: Permission not granted!

Applying for fromal permission

Please provide the following information and send it to xiaomi-mispeed-support@xiaomi.com to apply for formal permission.
Subject:xx Company,Applying for MiSpeed formal permission。
Note:To apply for formal permission,relevant business agreements need to be signed.
1. APIs using scenarios

Scenarios Cpu level Thread priority Timeout (ms)
Open xx activity 1 0 100
Scroll in xx activity 2 0 1000
Scenario 3 3 1 500
Scenario4 1 0 100
Scenario 5 0 1 2000

2. Performance Test

Scenarios Detail test Before After Diff
Open xx activity the duration of open activity 100 ms 80 ms 20%
Scroll drop frames 10% 6% 40%
Scenario 3 Test 3 .. .. ..

Note:We will also do performance test according to the scenarios provided by you.

3. Power consumption test

Scenarios Before After Diff
Scenario 1 1000 mA 1050 mA 50
Scenario 2 .. .. ..

Note:We will also do power consumption test according to the scenarios provided by you.

More cooperation

More APIs will be supported in the future
requestGpuHighFreq,requestIOHighFreq,requestMemory,requestNetwork and so on.

Other supports that can be provided in the future
Provide more support for your application (e.g. memory leak detection), improve the performance of the application, and improve the user satisfaction.