[Android_CN_OAID] the unique identification solution for Android devices can be used as an alternative to the unified SDK of Mobile Security Alliance (miit_mdid_xxx.aar).

Posted by souravsasi123 on Wed, 09 Feb 2022 02:43:35 +0100

Android_CN_OAID

The unique identification solution for Android devices can be used as an alternative to the mobile security alliance unified SDK (miit_mdid_xxx.aar). This project provides portable interfaces for major domestic mobile phone manufacturers to obtain OAID (open anonymous device identification) and overseas mobile phone platforms to obtain AAID (Android advertising identification). In addition, it also provides access methods for common device identification such as IMEI/MEID, AndroidID, WidevineID, PseudoID and GUID.

Access guidance

Latest version | Update log | Java Doc

Dependency configuration

allprojects {
    repositories {
        maven { url 'https://www.jitpack.io' }
    }
}
dependencies {
    implementation 'com.github.gzu-liyujiang:Android_CN_OAID:4.1.2'
}

Since 4.1.1, read has been added by default_ PHONE_ STATE,WRITE_SETTINGS and WRITE_EXTERNAL_STORAGE permission to adapt to the lower version of Android system. In order to protect users' privacy according to the principle of minimum necessity, if IMEI and GUID are not used in the project, they can be found in androidmanifest Add the following code to XML to remove relevant permissions:

<manifest>
    <uses-permission
        android:name="android.permission.READ_PHONE_STATE"
        tools:node="remove" />
    <uses-permission
        android:name="android.permission.WRITE_SETTINGS"
        tools:node="remove" />
</manifest>

Code example

Obtain multiple possible device identifiers and introduce them in combination with the server Byzantine fault tolerance scheme Obtain reliable and stable equipment unique identification:

  • Usage 1: get the device identifier in real time
        final StringBuilder builder = new StringBuilder();
        builder.append("UniqueID: ");
        // Get the unique ID of the device. Only systems before Android 10 are supported. Read is required_ PHONE_ State permission, may be empty
        String uniqueID = DeviceID.getUniqueID(this);
        if (TextUtils.isEmpty(uniqueID)) {
            builder.append("DID/IMEI/MEID Acquisition failed");
        } else {
            builder.append(uniqueID);
        }
        builder.append("\n");
        builder.append("AndroidID: ");
        // Get Android ID, which may be empty
        String androidID = DeviceID.getAndroidID(this);
        if (TextUtils.isEmpty(androidID)) {
            builder.append("AndroidID Acquisition failed");
        } else {
            builder.append(androidID);
        }
        builder.append("\n");
        builder.append("WidevineID: ");
        // Get the digital rights management ID, which may be empty
        String widevineID = DeviceID.getWidevineID(this);
        if (TextUtils.isEmpty(widevineID)) {
            builder.append("WidevineID Acquisition failed");
        } else {
            builder.append(widevineID);
        }
        builder.append("\n");
        builder.append("PseudoID: ");
        // Obtain the forged ID and generate it according to the hardware information. It will not be empty, and there is a high probability that it will be repeated
        builder.append(DeviceID.getPseudoID());
        builder.append("\n");
        builder.append("GUID: ");
        // Get GUID, randomly generated, not null
        builder.append(DeviceID.getGUID(this));
        builder.append("\n");
        // Is OAID/AAID supported
        builder.append("supported:").append(DeviceID.supportedOAID(this));
        builder.append("\n");
        // Get OAID/AAID, asynchronous callback
        DeviceID.getOAID(this, new IGetter() {
            @Override
            public void onOAIDGetComplete(@NonNull String result) {
                // The OAID/AAID formats of different manufacturers are different. Hash operations such as MD5 and SHA1 can be unified
                builder.append("OAID/AAID: ").append(result);
                tvDeviceIdResult.setText(builder);
            }

            @Override
            public void onOAIDGetError(@NonNull Exception error) {
                // Failed to get OAID/AAID
                builder.append("OAID/AAID: Failure,").append(error);
                tvDeviceIdResult.setText(builder);
            }
        });
  • Usage 2: obtain the device identifier in advance (it is recommended not to exist at the same time as the usage)
    // Call prefetching in Application#onCreate. Note: do not call this method if you do not need to call 'getClientId()' and 'getOAID()'
    DeviceID.register(this);
    // Obtain equipment identification where required
    // Original value of client ID: deviceid getClientId()
    // The unified format of client ID is MD5: deviceid getClientIdMD5()
    // The uniform format of client ID is SHA1: deviceid getClientIdSHA1()
    // Original value of open anonymous device ID: deviceid getOAID()
  tvDeviceIdResult.setText(String.format("ClientID: %s", DeviceID.getClientIdMD5()));

Confusion rule

This library comes with consumer rules Pro uses the following confusion rules to avoid confusing the relevant interfaces and classes of manufacturers. If it is referenced by remote dependency, no additional configuration is required:

-keep class repeackage.com.uodis.opendevice.aidl.** { *; }
-keep interface repeackage.com.uodis.opendevice.aidl.** { *; }
-keep class repeackage.com.asus.msa.SupplementaryDID.** { *; }
-keep interface repeackage.com.asus.msa.SupplementaryDID.** { *; }
-keep class repeackage.com.bun.lib.** { *; }
-keep interface repeackage.com.bun.lib.** { *; }
-keep class repeackage.com.heytap.openid.** { *; }
-keep interface repeackage.com.heytap.openid.** { *; }
-keep class repeackage.com.samsung.android.deviceidservice.** { *; }
-keep interface repeackage.com.samsung.android.deviceidservice.** { *; }
-keep class repeackage.com.zui.deviceidservice.** { *; }
-keep interface repeackage.com.zui.deviceidservice.** { *; }

Support

Manufacturer or brandSystem or framework
HuaWei (HuaWei, Honor)HMS Core 2.6.2+ ,Google Play Service 4.0+
XiaoMi (XiaoMi, RedMi, BlackShark)MIUI 10.2+,Google Play Service 4.0+
VIVO (VIVO, IQOO)Funtouch OS 9+,Origin OS 1.0+,Google Play Service 4.0+
OPPO, RealMeColor OS 7.0+,Google Play Service 4.0+
SamsungAndroid 10+,Google Play Service 4.0+
LenovoZUI 11.4+,Google Play Service 4.0+
ASUSAndroid 10+,Google Play Service 4.0+
MeizuAndroid 10+,Google Play Service 4.0+
OnePlusAndroid 10+,Google Play Service 4.0+
NubiaAndroid 10+,Google Play Service 4.0+
Others (ZTE, HTC, Motorola,...)Freeme OS,SSUI,Google Play Service 4.0+

Note: the OAID acquisition interface of this project mainly refers to the code published by Beijing Digital alliance and reverse analysis, and refers to the SDK, HUAWEI Ads SDK and Xiaomi deviceid of mobile security alliance Jar, Google Play Services SDK, etc.

Effect preview

OAID (open anonymous device identifier)














AAID (Android ad identifier)







OAID or AAID is not supported

Hammer( Smartisan),Cool( Yulong,Coolpad),360(360),Qiku( QiKu),Hisense( Hisense),Jin Li( Gionee),
Meitu( Meitu),Candy( SOAP),Gree( Gree),Duo Wei( Doov),Yousi( Uniscope),Sharp( SHARP),LETV( LeTV),
VITU( VOTO),Acer( Acer),TCL(TCL),......

reference material

OAID is a member of the supplementary device identification system of mobile intelligent terminal, officially defined as Open Anonymous Device Identifier,
Huawei calls it Open Advertising ID and Google calls it Android Advertising ID.

Remote real machine

license agreement

Copyright (c) 2019-2021 gzu-liyujiang <1032694760@qq.com>

The software is licensed under the Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
    http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
PURPOSE.
See the Mulan PSL v2 for more details.

Topics: Java Android github Programmer