├── .gitignore ├── .idea ├── codeStyles │ └── Project.xml ├── gradle.xml ├── markdown-navigator-enh.xml ├── markdown-navigator.xml ├── misc.xml ├── runConfigurations.xml └── vcs.xml ├── 01.png ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── yr │ │ └── unique │ │ └── code │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── yr │ │ │ └── unique │ │ │ └── code │ │ │ ├── MainActivity.java │ │ │ └── utils │ │ │ ├── AppIdsUpdater.java │ │ │ ├── DeviceTypeEnum.java │ │ │ ├── OAIDHelper.java │ │ │ ├── imp │ │ │ ├── ASUSDeviceIDHelper.java │ │ │ ├── HWDeviceIDHelper.java │ │ │ ├── LenovoDeviceIDHelper.java │ │ │ ├── MeizuDeviceIDHelper.java │ │ │ ├── NubiaDeviceIDHelper.java │ │ │ ├── OnePlusDeviceIDHelper.java │ │ │ ├── OppoDeviceIDHelper.java │ │ │ ├── SamsungDeviceIDHelper.java │ │ │ ├── VivoDeviceIDHelper.java │ │ │ ├── XiaomiDeviceIDHelper.java │ │ │ └── ZTEDeviceIDHelper.java │ │ │ └── interfaces │ │ │ ├── ASUSIDInterface.java │ │ │ ├── HWIDInterface.java │ │ │ ├── LenovoIDInterface.java │ │ │ ├── OnePlusIDInterface.java │ │ │ ├── OppoIDInterface.java │ │ │ ├── SamsungIDInterface.java │ │ │ └── ZTEIDInterface.java │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ └── ic_launcher_background.xml │ │ ├── layout │ │ └── activity_main.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── yr │ └── unique │ └── code │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | /.idea/navEditor.xml 9 | /.idea/assetWizardSettings.xml 10 | .DS_Store 11 | /build 12 | /captures 13 | .externalNativeBuild 14 | .cxx 15 | -------------------------------------------------------------------------------- /.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | xmlns:android 14 | 15 | ^$ 16 | 17 | 18 | 19 |
20 |
21 | 22 | 23 | 24 | xmlns:.* 25 | 26 | ^$ 27 | 28 | 29 | BY_NAME 30 | 31 |
32 |
33 | 34 | 35 | 36 | .*:id 37 | 38 | http://schemas.android.com/apk/res/android 39 | 40 | 41 | 42 |
43 |
44 | 45 | 46 | 47 | .*:name 48 | 49 | http://schemas.android.com/apk/res/android 50 | 51 | 52 | 53 |
54 |
55 | 56 | 57 | 58 | name 59 | 60 | ^$ 61 | 62 | 63 | 64 |
65 |
66 | 67 | 68 | 69 | style 70 | 71 | ^$ 72 | 73 | 74 | 75 |
76 |
77 | 78 | 79 | 80 | .* 81 | 82 | ^$ 83 | 84 | 85 | BY_NAME 86 | 87 |
88 |
89 | 90 | 91 | 92 | .* 93 | 94 | http://schemas.android.com/apk/res/android 95 | 96 | 97 | ANDROID_ATTRIBUTE_ORDER 98 | 99 |
100 |
101 | 102 | 103 | 104 | .* 105 | 106 | .* 107 | 108 | 109 | BY_NAME 110 | 111 |
112 |
113 |
114 |
115 |
116 |
-------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 19 | 20 | -------------------------------------------------------------------------------- /.idea/markdown-navigator-enh.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /.idea/markdown-navigator.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 29 | 30 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 9 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AFinalStone/GET_OAID/97895e39ea9ccbeac4d5977559d8acf758450180/01.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #### 前言 2 | 随 Android Q 的到来,IMEI 无法获取,获取稳定的 ID 成为越来越多的开发者迫切需求。 3 | 为了解决这个问题,这里提供两种参考方案: 4 | 5 | ###### 方案一:使用手机厂联盟提供了一个全新的广告跟踪标示OAID 6 | - OAID:Open Anonymous Device Identifier 开放匿名设备标识符 7 | 8 | ###### 方案二:使用数字联盟则提供的"可信ID"的免费版CNAdlD 9 | 10 | ![OAID](/01.png) 11 | 12 | #### 标识特性 13 | ###### OAID(匿名设备标识符) 14 | 发生下述事件时,OAID(匿名设备标识符)重置: 15 | 16 | - 用户在系统设置中手动重置,匿名设备标识符将重置; 17 | - 移动智能终端恢复出厂设置时,匿名设备标识符将重置; 18 | - 匿名设备标识符自身可定期重置。 重置后生成新的匿名设备标识符,且应用只能获取新的匿名设备标识符。 19 | 20 | 移动智能终端应提供匿名设备标识符的开启\关闭受控机制,用户可以选择在系统设置中关闭匿名 设备标识符;关闭后,应用获取到的匿名设备标识符的返回值为 NO。 21 | 22 | >请注意:OAID 与IMEI 不同,IMEI 为设备标示,对于相同设备在不被篡改时,不发生变化,可以作为画像索引 key。 OAID 为广告标识,同一台设备在不同时间内,可以拥有不同的的 OAID,因此无法作为稳定的索引key 使用。详细信息参考(www.msa-alliance.cn) 23 | 24 | ###### CNAdID(稳定设备标示) 25 | CNAdID为稳定设备标示,有良好的反作弊对抗特征,详细信息以及使用方案请具体参考[中国通用广告ID官网](http://www.cnadid.cn) 26 | 27 | #### OAID 目前支持的设备厂商: 28 | | 厂商 | 版本 | 29 | | ------ | ------------------------------------- | 30 | | 小米 | MIUI10.2 及以上 | 31 | | vivo | FuntouchOS 9 及以上 | 32 | | 华为 | 全版本 | 33 | | OPPO | Color OS 7.0 及以上 | 34 | | Lenovo | ZUI 11.4 及以上 | 35 | | 华硕 | Android 10 版本 | 36 | | 魅族 | Android 10 版本 | 37 | | 三星 | Android 10 版本 | 38 | | 努比亚 | Android 10 版本 | 39 | | 中兴 | Android 10 版本 | 40 | | 一加 | Android 10 版本 | 41 | | Freeme OS | Android 10 版本 | 42 | | Ssui OS | Android 10 版本 | 43 | 44 | 关于OAID我这里会提供一个简单的案例供大家参考,当然大家也可以去[移动安全联盟官网](http://msa-alliance.cn/col.jsp?id=120)使用具体的SDK来获取自己想要的OAID。 45 | 46 | 项目地址:[传送门](https://github.com/AFinalStone/GET_OAID) 47 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 29 5 | buildToolsVersion "29.0.3" 6 | 7 | defaultConfig { 8 | applicationId "com.yr.unique.code" 9 | minSdkVersion 19 10 | targetSdkVersion 29 11 | versionCode 1 12 | versionName "1.0" 13 | 14 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 15 | } 16 | 17 | buildTypes { 18 | release { 19 | minifyEnabled false 20 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 21 | } 22 | } 23 | 24 | } 25 | 26 | dependencies { 27 | implementation fileTree(dir: 'libs', include: ['*.jar']) 28 | 29 | implementation 'com.android.support:appcompat-v7:28.0.0' 30 | implementation 'com.android.support.constraint:constraint-layout:1.1.3' 31 | testImplementation 'junit:junit:4.12' 32 | androidTestImplementation 'com.android.support.test:runner:1.0.2' 33 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' 34 | } 35 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/yr/unique/code/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.yr.unique.code; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumented test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); 23 | 24 | assertEquals("com.yr.unique.code", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/java/com/yr/unique/code/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.yr.unique.code; 2 | 3 | import android.support.annotation.NonNull; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.os.Bundle; 6 | import android.view.View; 7 | import android.widget.TextView; 8 | 9 | import com.yr.unique.code.utils.AppIdsUpdater; 10 | import com.yr.unique.code.utils.OAIDHelper; 11 | 12 | public class MainActivity extends AppCompatActivity { 13 | 14 | TextView mTvOAID; 15 | 16 | @Override 17 | protected void onCreate(Bundle savedInstanceState) { 18 | super.onCreate(savedInstanceState); 19 | setContentView(R.layout.activity_main); 20 | mTvOAID = findViewById(R.id.tv_OAID); 21 | findViewById(R.id.btn_get_OAID).setOnClickListener(new View.OnClickListener() { 22 | @Override 23 | public void onClick(View view) { 24 | OAIDHelper helper = new OAIDHelper(new AppIdsUpdater() { 25 | @Override 26 | public void OnIdsAvalid(@NonNull final String ids) { 27 | runOnUiThread(new Runnable() { 28 | @Override 29 | public void run() { 30 | mTvOAID.setText("成功获取OAID,具体值为:\n" + ids); 31 | } 32 | }); 33 | } 34 | }); 35 | helper.getOAid(MainActivity.this); 36 | } 37 | }); 38 | 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /app/src/main/java/com/yr/unique/code/utils/AppIdsUpdater.java: -------------------------------------------------------------------------------- 1 | package com.yr.unique.code.utils; 2 | 3 | import android.support.annotation.NonNull; 4 | 5 | public interface AppIdsUpdater { 6 | void OnIdsAvalid(@NonNull String ids); 7 | } -------------------------------------------------------------------------------- /app/src/main/java/com/yr/unique/code/utils/DeviceTypeEnum.java: -------------------------------------------------------------------------------- 1 | package com.yr.unique.code.utils; 2 | 3 | public enum DeviceTypeEnum { 4 | 5 | HuaShuo("华硕手机", "ASUS"), 6 | HuaWei("华为手机", "HUAWEI"), 7 | Lianxiang("联想手机", "LENOVO"), 8 | Motolora("摩托罗拉手机", "MOTOLORA"), 9 | Nubia("努比亚手机", "NUBIA"), 10 | Meizu("魅族手机", "MEIZU"), 11 | Oppo("Oppo手机", "NUBIA"), 12 | Samsung("三星手机", "SAMSUNG"), 13 | Vivo("Vivo手机", "VIVO"), 14 | XiaoMi("小米手机", "XIAOMI"), 15 | BlackShark("小米手机", "BLACKSHARK"), 16 | OnePlus("OnePlus手机", "ONEPLUS"), 17 | ZTE("中兴手机", "ZTE"); 18 | 19 | 20 | private String name; 21 | private String flag; 22 | 23 | DeviceTypeEnum(String name, String flag) { 24 | this.name = name; 25 | this.flag = flag; 26 | } 27 | 28 | public String getFlag() { 29 | return flag; 30 | } 31 | 32 | public static DeviceTypeEnum getInstance(String flag) { 33 | DeviceTypeEnum[] list = values(); 34 | for (DeviceTypeEnum item : list) { 35 | if (item.getFlag().equals(flag)) { 36 | return item; 37 | } 38 | } 39 | return null; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /app/src/main/java/com/yr/unique/code/utils/OAIDHelper.java: -------------------------------------------------------------------------------- 1 | package com.yr.unique.code.utils; 2 | 3 | import android.content.Context; 4 | import android.os.Build; 5 | import android.text.TextUtils; 6 | import android.util.Log; 7 | 8 | import com.yr.unique.code.utils.imp.ASUSDeviceIDHelper; 9 | import com.yr.unique.code.utils.imp.HWDeviceIDHelper; 10 | import com.yr.unique.code.utils.imp.LenovoDeviceIDHelper; 11 | import com.yr.unique.code.utils.imp.MeizuDeviceIDHelper; 12 | import com.yr.unique.code.utils.imp.NubiaDeviceIDHelper; 13 | import com.yr.unique.code.utils.imp.OnePlusDeviceIDHelper; 14 | import com.yr.unique.code.utils.imp.OppoDeviceIDHelper; 15 | import com.yr.unique.code.utils.imp.SamsungDeviceIDHelper; 16 | import com.yr.unique.code.utils.imp.VivoDeviceIDHelper; 17 | import com.yr.unique.code.utils.imp.XiaomiDeviceIDHelper; 18 | import com.yr.unique.code.utils.imp.ZTEDeviceIDHelper; 19 | 20 | import java.lang.reflect.Method; 21 | 22 | /** 23 | * 把各大厂商获取OADI的工具类统一封装成一个类 24 | * 25 | * @author AF 26 | * @time 2020/4/14 17:11 27 | */ 28 | public class OAIDHelper { 29 | 30 | private AppIdsUpdater mAppIdUpdateListener; 31 | 32 | public OAIDHelper(AppIdsUpdater callback) { 33 | mAppIdUpdateListener = callback; 34 | } 35 | 36 | 37 | /** 38 | * 获取各大平台的OAID 39 | * 40 | * @param context 41 | */ 42 | public void getOAid(Context context) { 43 | 44 | String oaid = null; 45 | String manufacturer = getManufacturer().toUpperCase(); 46 | Log.d("DevicesIDsHelper", "manufacturer===> " + manufacturer); 47 | if (mAppIdUpdateListener == null) { 48 | return; 49 | } 50 | 51 | if (isFreeMeOS() || isSSUIOS()) { 52 | getOAIDByNewThread(context); 53 | } 54 | DeviceTypeEnum deviceType = DeviceTypeEnum.getInstance(manufacturer); 55 | switch (deviceType) { 56 | case HuaShuo: 57 | case HuaWei: 58 | case Oppo: 59 | case OnePlus: 60 | case ZTE: 61 | getOAIDByNewThread(context); 62 | break; 63 | case Lianxiang: 64 | case Motolora: 65 | new LenovoDeviceIDHelper(context).getIdRun(mAppIdUpdateListener); 66 | break; 67 | case Nubia: 68 | oaid = new NubiaDeviceIDHelper(context).getNubiaID(); 69 | mAppIdUpdateListener.OnIdsAvalid(oaid); 70 | break; 71 | case Meizu: 72 | new MeizuDeviceIDHelper(context).getMeizuID(mAppIdUpdateListener); 73 | break; 74 | case Samsung: 75 | new SamsungDeviceIDHelper(context).getSumsungID(mAppIdUpdateListener); 76 | break; 77 | case Vivo: 78 | oaid = new VivoDeviceIDHelper(context).getOaid(); 79 | mAppIdUpdateListener.OnIdsAvalid(oaid); 80 | break; 81 | case XiaoMi: 82 | case BlackShark: 83 | oaid = new XiaomiDeviceIDHelper(context).getOAID(); 84 | mAppIdUpdateListener.OnIdsAvalid(oaid); 85 | break; 86 | } 87 | 88 | } 89 | 90 | 91 | /** 92 | * 这些平台获取OAID是耗时操作,需要放在异步线程中 93 | * 94 | * @param context 95 | */ 96 | private void getOAIDByNewThread(final Context context) { 97 | new Thread(new Runnable() { 98 | @Override 99 | public void run() { 100 | if (isFreeMeOS() || isSSUIOS()) { 101 | new ZTEDeviceIDHelper(context).getID(mAppIdUpdateListener); 102 | return; 103 | } 104 | String manufacturer = getManufacturer().toUpperCase(); 105 | DeviceTypeEnum deviceType = DeviceTypeEnum.getInstance(manufacturer); 106 | switch (deviceType) { 107 | case HuaShuo: 108 | new ASUSDeviceIDHelper(context).getID(mAppIdUpdateListener); 109 | break; 110 | case HuaWei: 111 | new HWDeviceIDHelper(context).getHWID(mAppIdUpdateListener); 112 | break; 113 | case Oppo: 114 | new OppoDeviceIDHelper(context).getID(mAppIdUpdateListener); 115 | break; 116 | case OnePlus: 117 | new OnePlusDeviceIDHelper(context).getID(mAppIdUpdateListener); 118 | break; 119 | case ZTE: 120 | new ZTEDeviceIDHelper(context).getID(mAppIdUpdateListener); 121 | break; 122 | } 123 | } 124 | }).start(); 125 | } 126 | 127 | 128 | /** 129 | * 获取当前设备硬件制造商(MANUFACTURER) 130 | * 131 | * @return 132 | */ 133 | private String getManufacturer() { 134 | return Build.MANUFACTURER.toUpperCase(); 135 | } 136 | 137 | private String getProperty(String property) { 138 | String res = null; 139 | if (property == null) { 140 | return null; 141 | } 142 | try { 143 | Class clazz = Class.forName("android.os.SystemProperties"); 144 | Method method = clazz.getMethod("get", new Class[]{String.class, String.class}); 145 | res = (String) method.invoke(clazz, new Object[]{property, "unknown"}); 146 | } catch (Exception e) { 147 | // ignore 148 | } 149 | return res; 150 | } 151 | 152 | 153 | /** 154 | * 是否是freeMe操作系统,该系统是卓易科技深度定制的Android操作系统 155 | * 156 | * @return 157 | */ 158 | public boolean isFreeMeOS() { 159 | String pro = getProperty("ro.build.freeme.label"); // "ro.build.freeme.label" 160 | if ((!TextUtils.isEmpty(pro)) && pro.equalsIgnoreCase("FREEMEOS")) { // "FreemeOS" FREEMEOS 161 | return true; 162 | } 163 | return false; 164 | } 165 | 166 | 167 | public boolean isSSUIOS() { 168 | String pro = getProperty("ro.ssui.product"); // "ro.ssui.product" 169 | if ((!TextUtils.isEmpty(pro)) && (!pro.equalsIgnoreCase("unknown"))) { 170 | return true; 171 | } 172 | return false; 173 | } 174 | 175 | 176 | } 177 | -------------------------------------------------------------------------------- /app/src/main/java/com/yr/unique/code/utils/imp/ASUSDeviceIDHelper.java: -------------------------------------------------------------------------------- 1 | package com.yr.unique.code.utils.imp; 2 | 3 | import android.content.ComponentName; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | import android.content.ServiceConnection; 7 | import android.os.IBinder; 8 | 9 | import com.yr.unique.code.utils.AppIdsUpdater; 10 | import com.yr.unique.code.utils.interfaces.ASUSIDInterface; 11 | 12 | import java.util.concurrent.LinkedBlockingQueue; 13 | 14 | /** 15 | * 华硕手机获取OAid 16 | * 17 | * @author AF 18 | * @time 2020/4/14 18:24 19 | */ 20 | public class ASUSDeviceIDHelper { 21 | 22 | private Context mContext; 23 | public final LinkedBlockingQueue linkedBlockingQueue = new LinkedBlockingQueue(1); 24 | 25 | public ASUSDeviceIDHelper(Context ctx) { 26 | mContext = ctx; 27 | } 28 | 29 | /** 30 | * 获取 OAID 并回调 31 | * 32 | * @param _listener 33 | */ 34 | public void getID(AppIdsUpdater _listener) { 35 | try { 36 | mContext.getPackageManager().getPackageInfo("com.asus.msa.SupplementaryDID", 0); 37 | } catch (Exception e) { 38 | e.printStackTrace(); 39 | } 40 | 41 | Intent intent = new Intent(); 42 | intent.setAction("com.asus.msa.action.ACCESS_DID"); 43 | ComponentName componentName = new ComponentName("com.asus.msa.SupplementaryDID", "com.asus.msa.SupplementaryDID.SupplementaryDIDService"); 44 | intent.setComponent(componentName); 45 | 46 | boolean isBin = mContext.bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE); 47 | if (isBin) { 48 | try { 49 | IBinder iBinder = linkedBlockingQueue.take(); 50 | ASUSIDInterface.ASUSID asusID = new ASUSIDInterface.ASUSID(iBinder); 51 | String asusOAID = asusID.getID(); 52 | 53 | if (_listener != null) { 54 | _listener.OnIdsAvalid(asusOAID); 55 | } 56 | } catch (Exception e) { 57 | e.printStackTrace(); 58 | } 59 | } 60 | } 61 | 62 | ServiceConnection serviceConnection = new ServiceConnection() { 63 | @Override 64 | public void onServiceConnected(ComponentName name, IBinder service) { 65 | try { 66 | linkedBlockingQueue.put(service); 67 | } catch (Exception e) { 68 | e.printStackTrace(); 69 | } 70 | } 71 | 72 | @Override 73 | public void onServiceDisconnected(ComponentName name) { 74 | } 75 | }; 76 | } 77 | -------------------------------------------------------------------------------- /app/src/main/java/com/yr/unique/code/utils/imp/HWDeviceIDHelper.java: -------------------------------------------------------------------------------- 1 | package com.yr.unique.code.utils.imp; 2 | 3 | import android.content.ComponentName; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | import android.content.ServiceConnection; 7 | import android.os.IBinder; 8 | 9 | import com.yr.unique.code.utils.AppIdsUpdater; 10 | import com.yr.unique.code.utils.interfaces.HWIDInterface; 11 | 12 | import java.util.concurrent.LinkedBlockingQueue; 13 | 14 | /** 15 | * 华为手机获取OAid 16 | * 17 | * @author AF 18 | * @time 2020/4/14 18:24 19 | */ 20 | public class HWDeviceIDHelper { 21 | 22 | private Context mContext; 23 | public final LinkedBlockingQueue linkedBlockingQueue = new LinkedBlockingQueue(1); 24 | 25 | public HWDeviceIDHelper(Context ctx) { 26 | mContext = ctx; 27 | } 28 | 29 | public void getHWID(AppIdsUpdater _listener) { 30 | try { 31 | mContext.getPackageManager().getPackageInfo("com.huawei.hwid", 0); 32 | } catch (Exception e) { 33 | e.printStackTrace(); 34 | } 35 | 36 | Intent bindIntent = new Intent("com.uodis.opendevice.OPENIDS_SERVICE"); 37 | bindIntent.setPackage("com.huawei.hwid"); 38 | boolean isBin = mContext.bindService(bindIntent, serviceConnection, Context.BIND_AUTO_CREATE); 39 | if (isBin) { 40 | try { 41 | IBinder iBinder = linkedBlockingQueue.take(); 42 | HWIDInterface.HWID hwID = new HWIDInterface.HWID(iBinder); 43 | String ids = hwID.getIDs(); 44 | boolean boos = hwID.getBoos(); 45 | 46 | if (_listener != null) { 47 | _listener.OnIdsAvalid(ids); 48 | } 49 | } catch (Exception e) { 50 | e.printStackTrace(); 51 | } finally { 52 | mContext.unbindService(serviceConnection); 53 | } 54 | } 55 | } 56 | 57 | 58 | ServiceConnection serviceConnection = new ServiceConnection() { 59 | @Override 60 | public void onServiceConnected(ComponentName name, IBinder service) { 61 | try { 62 | linkedBlockingQueue.put(service); 63 | } catch (Exception e) { 64 | e.printStackTrace(); 65 | } 66 | } 67 | 68 | @Override 69 | public void onServiceDisconnected(ComponentName name) { 70 | 71 | } 72 | }; 73 | 74 | } 75 | -------------------------------------------------------------------------------- /app/src/main/java/com/yr/unique/code/utils/imp/LenovoDeviceIDHelper.java: -------------------------------------------------------------------------------- 1 | package com.yr.unique.code.utils.imp; 2 | 3 | import android.content.ComponentName; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | import android.content.ServiceConnection; 7 | import android.os.IBinder; 8 | 9 | import com.yr.unique.code.utils.AppIdsUpdater; 10 | import com.yr.unique.code.utils.interfaces.LenovoIDInterface; 11 | 12 | /** 13 | * 联想手机获取OAid 14 | * 15 | * @author AF 16 | * @time 2020/4/14 18:25 17 | */ 18 | public class LenovoDeviceIDHelper { 19 | 20 | private Context mContext; 21 | LenovoIDInterface lenovoIDInterface; 22 | 23 | public LenovoDeviceIDHelper(Context ctx) { 24 | mContext = ctx; 25 | } 26 | 27 | public void getIdRun(AppIdsUpdater _listener) { 28 | String result = null; 29 | String pkgName = mContext.getPackageName(); 30 | Intent intent = new Intent(); 31 | intent.setClassName("com.zui.deviceidservice", "com.zui.deviceidservice.DeviceidService"); 32 | boolean seu = mContext.bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE); 33 | if (seu) { 34 | if (lenovoIDInterface != null) { 35 | String oaid = lenovoIDInterface.a(); 36 | String udid = lenovoIDInterface.b(); 37 | String aaid = lenovoIDInterface.b(pkgName); 38 | String vaid = lenovoIDInterface.b(pkgName); 39 | 40 | if (_listener != null) { 41 | _listener.OnIdsAvalid(oaid); 42 | } 43 | } 44 | } 45 | } 46 | 47 | ServiceConnection serviceConnection = new ServiceConnection() { 48 | @Override 49 | public void onServiceConnected(ComponentName name, IBinder service) { 50 | lenovoIDInterface = new LenovoIDInterface.Proxy(service); 51 | } 52 | 53 | @Override 54 | public void onServiceDisconnected(ComponentName name) { 55 | 56 | } 57 | }; 58 | } 59 | -------------------------------------------------------------------------------- /app/src/main/java/com/yr/unique/code/utils/imp/MeizuDeviceIDHelper.java: -------------------------------------------------------------------------------- 1 | package com.yr.unique.code.utils.imp; 2 | 3 | import android.content.ContentResolver; 4 | import android.content.Context; 5 | import android.content.pm.PackageManager; 6 | import android.content.pm.ProviderInfo; 7 | import android.database.Cursor; 8 | import android.net.Uri; 9 | 10 | import com.yr.unique.code.utils.AppIdsUpdater; 11 | 12 | /** 13 | * 魅族手机获取OAid 14 | * 15 | * @author AF 16 | * @time 2020/4/14 18:25 17 | */ 18 | public class MeizuDeviceIDHelper { 19 | 20 | private Context mContext; 21 | 22 | public MeizuDeviceIDHelper(Context ctx) { 23 | mContext = ctx; 24 | } 25 | 26 | 27 | private boolean isMeizuSupport() { 28 | try { 29 | PackageManager pm = mContext.getPackageManager(); 30 | if (pm != null) { 31 | ProviderInfo pi = pm.resolveContentProvider("com.meizu.flyme.openidsdk", 0); // "com.meizu.flyme.openidsdk" 32 | if (pi != null) { 33 | return true; 34 | } 35 | } 36 | } catch (Exception e) { 37 | //ignore 38 | } 39 | return false; 40 | } 41 | 42 | public void getMeizuID(AppIdsUpdater _listener) { 43 | try { 44 | mContext.getPackageManager().getPackageInfo("com.meizu.flyme.openidsdk", 0); 45 | } catch (Exception e) { 46 | e.printStackTrace(); 47 | } 48 | Uri uri = Uri.parse("content://com.meizu.flyme.openidsdk/"); 49 | 50 | Cursor cursor; 51 | ContentResolver contentResolver = mContext.getContentResolver(); 52 | try { 53 | cursor = contentResolver.query(uri, null, null, new String[]{"oaid"}, null); 54 | String oaid = getOaid(cursor); 55 | 56 | if (_listener != null) { 57 | _listener.OnIdsAvalid(oaid); 58 | } 59 | cursor.close(); 60 | } catch (Throwable t) { 61 | t.printStackTrace(); 62 | } 63 | } 64 | 65 | /** 66 | * 获取 OAID 67 | * 68 | * @param cursor 69 | * @return 70 | */ 71 | private String getOaid(Cursor cursor) { 72 | String oaid = null; 73 | if (cursor == null) { 74 | return null; 75 | } 76 | if (cursor.isClosed()) { 77 | return null; 78 | } 79 | cursor.moveToFirst(); 80 | int valueIdx = cursor.getColumnIndex("value"); 81 | if (valueIdx > 0) { 82 | oaid = cursor.getString(valueIdx); 83 | } 84 | valueIdx = cursor.getColumnIndex("code"); 85 | if (valueIdx > 0) { 86 | int codeID = cursor.getInt(valueIdx); 87 | } 88 | valueIdx = cursor.getColumnIndex("expired"); 89 | if (valueIdx > 0) { 90 | long timeC = cursor.getLong(valueIdx); 91 | } 92 | return oaid; 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /app/src/main/java/com/yr/unique/code/utils/imp/NubiaDeviceIDHelper.java: -------------------------------------------------------------------------------- 1 | package com.yr.unique.code.utils.imp; 2 | 3 | import android.content.ContentProviderClient; 4 | import android.content.Context; 5 | import android.net.Uri; 6 | import android.os.Build; 7 | import android.os.Bundle; 8 | 9 | /** 10 | * 努比亚手机获取OAid 11 | * 12 | * @author AF 13 | * @time 2020/4/14 18:26 14 | */ 15 | public class NubiaDeviceIDHelper { 16 | 17 | private Context mContent; 18 | 19 | public NubiaDeviceIDHelper(Context ctx) { 20 | mContent = ctx; 21 | } 22 | 23 | public String getNubiaID() { 24 | String oaid = null; 25 | Bundle bundle; 26 | 27 | Uri uri = Uri.parse("content://cn.nubia.identity/identity"); 28 | try { 29 | if (Build.VERSION.SDK_INT > 17) { 30 | ContentProviderClient contentProviderClient = mContent.getContentResolver().acquireContentProviderClient(uri); 31 | bundle = contentProviderClient.call("getOAID", null, null); 32 | if (contentProviderClient != null) { 33 | if (Build.VERSION.SDK_INT >= 24) { 34 | contentProviderClient.close(); 35 | } else { 36 | contentProviderClient.release(); 37 | } 38 | } 39 | } else { 40 | bundle = mContent.getContentResolver().call(uri, "getOAID", null, null); 41 | } 42 | int code = bundle.getInt("code", -1); 43 | if (code == 0) { 44 | oaid = bundle.getString("id"); 45 | return oaid; 46 | } 47 | String faledMsg = bundle.getString("message"); 48 | return oaid; 49 | } catch (Exception e) { 50 | e.printStackTrace(); 51 | } 52 | return oaid; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /app/src/main/java/com/yr/unique/code/utils/imp/OnePlusDeviceIDHelper.java: -------------------------------------------------------------------------------- 1 | package com.yr.unique.code.utils.imp; 2 | 3 | import android.annotation.SuppressLint; 4 | import android.content.ComponentName; 5 | import android.content.Context; 6 | import android.content.Intent; 7 | import android.content.ServiceConnection; 8 | import android.content.pm.PackageInfo; 9 | import android.content.pm.PackageManager; 10 | import android.content.pm.Signature; 11 | import android.os.Build; 12 | import android.os.IBinder; 13 | import android.os.Looper; 14 | import android.os.SystemClock; 15 | 16 | 17 | import com.yr.unique.code.utils.AppIdsUpdater; 18 | import com.yr.unique.code.utils.interfaces.OnePlusIDInterface; 19 | 20 | import java.security.MessageDigest; 21 | 22 | /** 23 | * 一加手机获取OAid 24 | * 25 | * @author AF 26 | * @time 2020/4/14 18:27 27 | */ 28 | public class OnePlusDeviceIDHelper { 29 | 30 | private Context mContext; 31 | public String oaid = "OUID"; 32 | private String sign; 33 | OnePlusIDInterface onePlusIDInterface; 34 | 35 | public OnePlusDeviceIDHelper(Context ctx) { 36 | mContext = ctx; 37 | } 38 | 39 | 40 | public String getID(AppIdsUpdater _listener) { 41 | 42 | String res = null; 43 | 44 | if (Looper.myLooper() == Looper.getMainLooper()) { 45 | throw new IllegalStateException("Cannot run on MainThread"); 46 | } 47 | 48 | Intent intent = new Intent(); 49 | intent.setComponent(new ComponentName("com.heytap.openid", "com.heytap.openid.IdentifyService")); 50 | intent.setAction("action.com.heytap.openid.OPEN_ID_SERVICE"); 51 | 52 | if (mContext.bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE)) { 53 | 54 | try { 55 | SystemClock.sleep(3000); 56 | } catch (Exception e) { 57 | e.printStackTrace(); 58 | } 59 | if (onePlusIDInterface != null) { 60 | String oaid = realoGetIds("OUID"); 61 | String vaid = realoGetIds("DUID"); 62 | String aaid = realoGetIds("AUID"); 63 | res = oaid; 64 | 65 | if (_listener != null) { 66 | _listener.OnIdsAvalid(oaid); 67 | } 68 | } 69 | } 70 | return res; 71 | } 72 | 73 | @SuppressLint("WrongConstant") 74 | private String realoGetIds(String str) { 75 | String res = null; 76 | 77 | String str2 = null; 78 | String pkgName = mContext.getPackageName(); 79 | if (sign == null) { 80 | Signature[] signatures; 81 | try { 82 | signatures = mContext.getPackageManager().getPackageInfo(pkgName, 64).signatures; 83 | } catch (Exception e) { 84 | e.printStackTrace(); 85 | signatures = null; 86 | } 87 | 88 | if (signatures != null && signatures.length > 0) { 89 | byte[] byteArray = signatures[0].toByteArray(); 90 | try { 91 | MessageDigest messageDigest = MessageDigest.getInstance("SHA1"); 92 | if (messageDigest != null) { 93 | byte[] digest = messageDigest.digest(byteArray); 94 | StringBuilder sb = new StringBuilder(); 95 | for (byte b : digest) { 96 | sb.append(Integer.toHexString((b & 255) | 256).substring(1, 3)); 97 | } 98 | str2 = sb.toString(); 99 | } 100 | } catch (Exception e) { 101 | e.printStackTrace(); 102 | } 103 | } 104 | sign = str2; 105 | } 106 | 107 | res = ((OnePlusIDInterface.Proxy) onePlusIDInterface).getSerID(pkgName, sign, str); 108 | return res; 109 | } 110 | 111 | ServiceConnection serviceConnection = new ServiceConnection() { 112 | @Override 113 | public void onServiceConnected(ComponentName name, IBinder service) { 114 | onePlusIDInterface = OnePlusIDInterface.Stub.genInstance(service); 115 | } 116 | 117 | @Override 118 | public void onServiceDisconnected(ComponentName name) { 119 | onePlusIDInterface = null; 120 | } 121 | }; 122 | 123 | private boolean isSupportOppo() { 124 | boolean res = true; 125 | 126 | try { 127 | PackageManager pm = mContext.getPackageManager(); 128 | String pNname = "com.heytap.openid"; 129 | 130 | PackageInfo pi = pm.getPackageInfo(pNname, 0); 131 | if (pi == null) { 132 | return false; 133 | } 134 | long ver = 0; 135 | if (Build.VERSION.SDK_INT >= 28) { 136 | ver = pi.getLongVersionCode(); 137 | } else { 138 | ver = pi.versionCode; 139 | } 140 | if (ver < 1) { 141 | return false; 142 | } 143 | } catch (Exception e) { 144 | e.printStackTrace(); 145 | } 146 | return res; 147 | } 148 | } 149 | -------------------------------------------------------------------------------- /app/src/main/java/com/yr/unique/code/utils/imp/OppoDeviceIDHelper.java: -------------------------------------------------------------------------------- 1 | package com.yr.unique.code.utils.imp; 2 | 3 | import android.annotation.SuppressLint; 4 | import android.content.ComponentName; 5 | import android.content.Context; 6 | import android.content.Intent; 7 | import android.content.ServiceConnection; 8 | import android.content.pm.PackageInfo; 9 | import android.content.pm.PackageManager; 10 | import android.content.pm.Signature; 11 | import android.os.Build; 12 | import android.os.IBinder; 13 | import android.os.Looper; 14 | import android.os.SystemClock; 15 | 16 | 17 | import com.yr.unique.code.utils.AppIdsUpdater; 18 | import com.yr.unique.code.utils.interfaces.OppoIDInterface; 19 | 20 | import java.security.MessageDigest; 21 | 22 | /** 23 | * OPPO手机获取OAid 24 | * 25 | * @author AF 26 | * @time 2020/4/14 18:27 27 | */ 28 | public class OppoDeviceIDHelper { 29 | 30 | private Context mContext; 31 | public String oaid = "OUID"; 32 | private String sign; 33 | OppoIDInterface oppoIDInterface; 34 | 35 | public OppoDeviceIDHelper(Context ctx) { 36 | mContext = ctx; 37 | } 38 | 39 | 40 | public String getID(AppIdsUpdater _listener) { 41 | 42 | String res = null; 43 | 44 | if (Looper.myLooper() == Looper.getMainLooper()) { 45 | throw new IllegalStateException("Cannot run on MainThread"); 46 | } 47 | 48 | Intent intent = new Intent(); 49 | intent.setComponent(new ComponentName("com.heytap.openid", "com.heytap.openid.IdentifyService")); 50 | intent.setAction("action.com.heytap.openid.OPEN_ID_SERVICE"); 51 | 52 | if (mContext.bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE)) { 53 | try { 54 | SystemClock.sleep(3000); 55 | } catch (Exception e) { 56 | e.printStackTrace(); 57 | } 58 | if (oppoIDInterface != null) { 59 | String oaid = realoGetIds("OUID"); 60 | String vaid = realoGetIds("DUID"); 61 | String aaid = realoGetIds("AUID"); 62 | res = oaid; 63 | 64 | if (_listener != null) { 65 | _listener.OnIdsAvalid(oaid); 66 | } 67 | } 68 | } 69 | return res; 70 | } 71 | 72 | @SuppressLint("WrongConstant") 73 | private String realoGetIds(String str) { 74 | String res = null; 75 | 76 | String str2 = null; 77 | String pkgName = mContext.getPackageName(); 78 | if (sign == null) { 79 | Signature[] signatures; 80 | try { 81 | signatures = mContext.getPackageManager().getPackageInfo(pkgName, 64).signatures; 82 | } catch (Exception e) { 83 | e.printStackTrace(); 84 | signatures = null; 85 | } 86 | 87 | if (signatures != null && signatures.length > 0) { 88 | byte[] byteArray = signatures[0].toByteArray(); 89 | try { 90 | MessageDigest messageDigest = MessageDigest.getInstance("SHA1"); 91 | if (messageDigest != null) { 92 | byte[] digest = messageDigest.digest(byteArray); 93 | StringBuilder sb = new StringBuilder(); 94 | for (byte b : digest) { 95 | sb.append(Integer.toHexString((b & 255) | 256).substring(1, 3)); 96 | } 97 | str2 = sb.toString(); 98 | } 99 | } catch (Exception e) { 100 | e.printStackTrace(); 101 | } 102 | } 103 | sign = str2; 104 | } 105 | 106 | res = ((OppoIDInterface.Proxy) oppoIDInterface).getSerID(pkgName, sign, str); 107 | return res; 108 | } 109 | 110 | ServiceConnection serviceConnection = new ServiceConnection() { 111 | @Override 112 | public void onServiceConnected(ComponentName name, IBinder service) { 113 | oppoIDInterface = OppoIDInterface.Stub.genInterface(service); 114 | } 115 | 116 | @Override 117 | public void onServiceDisconnected(ComponentName name) { 118 | oppoIDInterface = null; 119 | } 120 | }; 121 | 122 | private boolean isSupportOppo() { 123 | boolean res = true; 124 | 125 | try { 126 | PackageManager pm = mContext.getPackageManager(); 127 | String pNname = "com.heytap.openid"; 128 | 129 | PackageInfo pi = pm.getPackageInfo(pNname, 0); 130 | if (pi == null) { 131 | return false; 132 | } 133 | long ver = 0; 134 | if (Build.VERSION.SDK_INT >= 28) { 135 | ver = pi.getLongVersionCode(); 136 | } else { 137 | ver = pi.versionCode; 138 | } 139 | if (ver < 1) { 140 | return false; 141 | } 142 | } catch (Exception e) { 143 | e.printStackTrace(); 144 | } 145 | return res; 146 | } 147 | } 148 | -------------------------------------------------------------------------------- /app/src/main/java/com/yr/unique/code/utils/imp/SamsungDeviceIDHelper.java: -------------------------------------------------------------------------------- 1 | package com.yr.unique.code.utils.imp; 2 | 3 | import android.content.ComponentName; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | import android.content.ServiceConnection; 7 | import android.os.IBinder; 8 | 9 | 10 | import com.yr.unique.code.utils.AppIdsUpdater; 11 | import com.yr.unique.code.utils.interfaces.SamsungIDInterface; 12 | 13 | import java.util.concurrent.LinkedBlockingQueue; 14 | 15 | /** 16 | * 三星手机获取OAid 17 | * 18 | * @author AF 19 | * @time 2020/4/14 18:28 20 | */ 21 | public class SamsungDeviceIDHelper { 22 | 23 | private Context mContext; 24 | public final LinkedBlockingQueue linkedBlockingQueue = new LinkedBlockingQueue(1); 25 | 26 | public SamsungDeviceIDHelper(Context ctx) { 27 | mContext = ctx; 28 | } 29 | 30 | public void getSumsungID(AppIdsUpdater _listener) { 31 | try { 32 | mContext.getPackageManager().getPackageInfo("com.samsung.android.deviceidservice", 0); 33 | } catch (Exception e) { 34 | e.printStackTrace(); 35 | } 36 | 37 | Intent intent = new Intent(); 38 | intent.setClassName("com.samsung.android.deviceidservice", "com.samsung.android.deviceidservice.DeviceIdService"); 39 | boolean isBinded = mContext.bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE); 40 | if (isBinded) { 41 | try { 42 | IBinder iBinder = linkedBlockingQueue.take(); 43 | SamsungIDInterface.Proxy proxy = new SamsungIDInterface.Proxy(iBinder); // 在这里有区别,需要实际验证 44 | String oaid = proxy.getID(); 45 | if (_listener != null) { 46 | _listener.OnIdsAvalid(oaid); 47 | } 48 | } catch (Exception e) { 49 | e.printStackTrace(); 50 | } 51 | } 52 | } 53 | 54 | ServiceConnection serviceConnection = new ServiceConnection() { 55 | @Override 56 | public void onServiceConnected(ComponentName name, IBinder service) { 57 | try { 58 | linkedBlockingQueue.put(service); 59 | } catch (Exception e) { 60 | e.printStackTrace(); 61 | } 62 | } 63 | 64 | @Override 65 | public void onServiceDisconnected(ComponentName name) { 66 | 67 | } 68 | }; 69 | } 70 | -------------------------------------------------------------------------------- /app/src/main/java/com/yr/unique/code/utils/imp/VivoDeviceIDHelper.java: -------------------------------------------------------------------------------- 1 | package com.yr.unique.code.utils.imp; 2 | 3 | import android.content.Context; 4 | import android.database.Cursor; 5 | import android.net.Uri; 6 | import android.os.Bundle; 7 | import android.os.Handler; 8 | import android.os.HandlerThread; 9 | import android.os.Message; 10 | 11 | import java.lang.reflect.Method; 12 | 13 | /** 14 | * Vivo手机获取OAid 15 | * 16 | * @author AF 17 | * @time 2020/4/14 18:29 18 | */ 19 | public class VivoDeviceIDHelper { 20 | 21 | private Context mConetxt; 22 | 23 | public VivoDeviceIDHelper(Context ctx) { 24 | mConetxt = ctx; 25 | } 26 | 27 | private HandlerThread handlerThread; 28 | private Handler handler; 29 | private boolean isSupportIds = false; 30 | String oaid = null; 31 | 32 | public String getOaid() { 33 | String res = null; 34 | Uri uri = Uri.parse("content://com.vivo.vms.IdProvider/IdentifierId/OAID"); 35 | Cursor cursor = mConetxt.getContentResolver().query(uri, null, null, null, null); 36 | if (cursor != null) { 37 | if (cursor.moveToNext()) { 38 | res = cursor.getString(cursor.getColumnIndex("value")); 39 | } 40 | cursor.close(); 41 | } else { 42 | } 43 | return res; 44 | } 45 | 46 | public String loge() { 47 | String result = null; 48 | 49 | f(); 50 | isSupportIds(); 51 | 52 | if (!isSupportIds) { 53 | return null; 54 | } 55 | if (oaid != null) { 56 | return null; 57 | } 58 | timeCheck(0, null); 59 | 60 | return null; 61 | } 62 | 63 | private void timeCheck(int i, String str) { 64 | Message message = handler.obtainMessage(); 65 | message.what = 11; 66 | Bundle bundle = new Bundle(); 67 | bundle.putInt("type", 0); 68 | if (i == 1 || i == 2) { 69 | bundle.putString("appid", str); 70 | } 71 | message.setData(bundle); 72 | handler.sendMessage(message); 73 | } 74 | 75 | private String sysProperty(String v1, String v2) { 76 | String res = null; 77 | try { 78 | Class clazz = Class.forName("android.os.SystemProperties"); 79 | Method method = clazz.getMethod("get", new Class[]{String.class, String.class}); 80 | res = (String) method.invoke(clazz, new Object[]{v1, "unknown"}); 81 | } catch (Exception e) { 82 | e.printStackTrace(); 83 | return v2; 84 | } 85 | return res; 86 | } 87 | 88 | private boolean isSupportIds() { 89 | String isSupId = sysProperty("persist.sys.identifierid.supported", "0"); 90 | isSupportIds = isSupId.equals("1"); 91 | return isSupportIds; 92 | } 93 | 94 | private void f() { 95 | handlerThread = new HandlerThread("SqlWorkThread"); 96 | handlerThread.start(); 97 | handler = new Handler(handlerThread.getLooper()) { 98 | @Override 99 | public void handleMessage(Message msg) { 100 | super.handleMessage(msg); 101 | if (msg.what == 11) { 102 | int tag = msg.getData().getInt("type"); 103 | String name = msg.getData().getString("appid"); 104 | String id = getContentResolver(tag, name); 105 | } else { 106 | 107 | } 108 | } 109 | }; 110 | } 111 | 112 | private String getContentResolver(int tag, String name) { 113 | String result = null; 114 | Uri uri; 115 | switch (tag) { 116 | case 0: 117 | uri = Uri.parse("content://com.vivo.vms.IdProvider/IdentifierId/OAID"); 118 | break; 119 | case 1: 120 | uri = Uri.parse("content://com.vivo.vms.IdProvider/IdentifierId/VAID_" + name); 121 | break; 122 | case 2: 123 | uri = Uri.parse("content://com.vivo.vms.IdProvider/IdentifierId/AAID_" + name); 124 | break; 125 | default: 126 | uri = null; 127 | break; 128 | } 129 | Cursor cursor = mConetxt.getContentResolver().query(uri, null, null, null, null); 130 | if (cursor != null) { 131 | if (cursor.moveToNext()) { 132 | result = cursor.getString(cursor.getColumnIndex("value")); 133 | } 134 | cursor.close(); 135 | } else { 136 | 137 | } 138 | return result; 139 | } 140 | } 141 | -------------------------------------------------------------------------------- /app/src/main/java/com/yr/unique/code/utils/imp/XiaomiDeviceIDHelper.java: -------------------------------------------------------------------------------- 1 | package com.yr.unique.code.utils.imp; 2 | 3 | import android.content.Context; 4 | 5 | import java.lang.reflect.Method; 6 | 7 | /** 8 | * 小米手机获取OAid 9 | * 10 | * @author AF 11 | * @time 2020/4/14 18:29 12 | */ 13 | public class XiaomiDeviceIDHelper { 14 | private Context mContext; 15 | 16 | private Class idProvider; 17 | private Object idImpl; 18 | private Method udid; 19 | private Method oaid; 20 | private Method vaid; 21 | private Method aaid; 22 | 23 | 24 | public XiaomiDeviceIDHelper(Context ctx) { 25 | mContext = ctx; 26 | 27 | try { 28 | idProvider = Class.forName("com.android.id.impl.IdProviderImpl"); 29 | idImpl = idProvider.newInstance(); 30 | } catch (Exception e) { 31 | e.printStackTrace(); 32 | } 33 | 34 | try { 35 | udid = idProvider.getMethod("getDefaultUDID", new Class[]{Context.class}); 36 | } catch (Exception e) { 37 | e.printStackTrace(); 38 | } 39 | try { 40 | oaid = idProvider.getMethod("getOAID", new Class[]{Context.class}); 41 | } catch (Exception e) { 42 | e.printStackTrace(); 43 | } 44 | try { 45 | vaid = idProvider.getMethod("getVAID", new Class[]{Context.class}); 46 | } catch (Exception e) { 47 | e.printStackTrace(); 48 | } 49 | try { 50 | aaid = idProvider.getMethod("getAAID", new Class[]{Context.class}); 51 | } catch (Exception e) { 52 | e.printStackTrace(); 53 | } 54 | } 55 | 56 | private String invokeMethod(Context ctx, Method method) { 57 | String result = null; 58 | if (idImpl != null && method != null) { 59 | try { 60 | result = (String) method.invoke(idImpl, ctx); 61 | } catch (Exception e) { 62 | e.printStackTrace(); 63 | } 64 | } 65 | return result; 66 | } 67 | 68 | public String getUDID() { 69 | return invokeMethod(mContext, udid); 70 | } 71 | 72 | public String getOAID() { 73 | return invokeMethod(mContext, oaid); 74 | } 75 | 76 | public String getAAID() { 77 | return invokeMethod(mContext, aaid); 78 | } 79 | 80 | public String getVAID() { 81 | return invokeMethod(mContext, vaid); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /app/src/main/java/com/yr/unique/code/utils/imp/ZTEDeviceIDHelper.java: -------------------------------------------------------------------------------- 1 | package com.yr.unique.code.utils.imp; 2 | 3 | import android.content.ComponentName; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | import android.content.ServiceConnection; 7 | import android.os.IBinder; 8 | 9 | import com.yr.unique.code.utils.AppIdsUpdater; 10 | import com.yr.unique.code.utils.interfaces.ZTEIDInterface; 11 | 12 | import java.util.concurrent.LinkedBlockingQueue; 13 | 14 | 15 | /** 16 | * 中兴手机获取 OAid 17 | * 18 | * @author AF 19 | * @time 2020/4/14 18:29 20 | */ 21 | public class ZTEDeviceIDHelper { 22 | Context mContext; 23 | String idPkgName = "com.mdid.msa"; 24 | 25 | public ZTEDeviceIDHelper(Context ctx) { 26 | mContext = ctx; 27 | } 28 | 29 | private int checkService() { 30 | int s = 0; 31 | try { 32 | mContext.getPackageManager().getPackageInfo(idPkgName, 0); 33 | s = 1; 34 | } catch (Exception e) { 35 | e.printStackTrace(); 36 | } 37 | return s; 38 | } 39 | 40 | private void startMsaklServer(String pkgName) { 41 | if (checkService() > 0) { // 这里等于虚设 42 | // 43 | } 44 | Intent intent = new Intent(); 45 | intent.setClassName(idPkgName, "com.mdid.msa.service.MsaKlService"); 46 | intent.setAction("com.bun.msa.action.start.service"); 47 | intent.putExtra("com.bun.msa.param.pkgname", pkgName); 48 | try { 49 | intent.putExtra("com.bun.msa.param.runinset", true); 50 | if (mContext.startService(intent) != null) { 51 | return; 52 | } 53 | } catch (Exception e) { 54 | e.printStackTrace(); 55 | } 56 | } 57 | 58 | public void getID(AppIdsUpdater _listener) { 59 | try { 60 | mContext.getPackageManager().getPackageInfo(idPkgName, 0); 61 | } catch (Exception e) { 62 | e.printStackTrace(); 63 | } 64 | String pkgName = mContext.getPackageName(); 65 | startMsaklServer(pkgName); 66 | 67 | Intent v0 = new Intent(); 68 | v0.setClassName("com.mdid.msa", "com.mdid.msa.service.MsaIdService"); 69 | v0.setAction("com.bun.msa.action.bindto.service"); 70 | v0.putExtra("com.bun.msa.param.pkgname", pkgName); 71 | boolean isBin = mContext.bindService(v0, serviceConnection, Context.BIND_AUTO_CREATE); 72 | if (isBin) { 73 | try { 74 | IBinder iBinder = linkedBlockingQueue.take(); 75 | ZTEIDInterface zteidInterface = new ZTEIDInterface.Proxy(iBinder); 76 | String oaid = zteidInterface.getOAID(); 77 | 78 | if (_listener != null) { 79 | _listener.OnIdsAvalid(oaid); 80 | } 81 | 82 | mContext.unbindService(serviceConnection); 83 | } catch (Exception e) { 84 | e.printStackTrace(); 85 | } finally { 86 | mContext.unbindService(serviceConnection); 87 | } 88 | } 89 | } 90 | 91 | public final LinkedBlockingQueue linkedBlockingQueue = new LinkedBlockingQueue(1); 92 | ServiceConnection serviceConnection = new ServiceConnection() { 93 | @Override 94 | public void onServiceConnected(ComponentName name, IBinder service) { 95 | try { 96 | linkedBlockingQueue.put(service); 97 | } catch (Exception e) { 98 | e.printStackTrace(); 99 | } 100 | 101 | } 102 | 103 | @Override 104 | public void onServiceDisconnected(ComponentName name) { 105 | } 106 | }; 107 | } 108 | -------------------------------------------------------------------------------- /app/src/main/java/com/yr/unique/code/utils/interfaces/ASUSIDInterface.java: -------------------------------------------------------------------------------- 1 | package com.yr.unique.code.utils.interfaces; 2 | 3 | import android.os.IBinder; 4 | import android.os.IInterface; 5 | import android.os.Parcel; 6 | 7 | 8 | /** 9 | * 华硕手机获取OAid 10 | * 11 | * @author AF 12 | * @time 2020/4/14 18:24 13 | */ 14 | public interface ASUSIDInterface extends IInterface { 15 | 16 | String getID(); 17 | 18 | public final class ASUSID implements ASUSIDInterface { 19 | private IBinder iBinder; 20 | 21 | public ASUSID(IBinder ib) { 22 | iBinder = ib; 23 | } 24 | 25 | @Override 26 | public IBinder asBinder() { 27 | return iBinder; 28 | } 29 | 30 | @Override 31 | public String getID() { 32 | String result = null; 33 | Parcel v1 = Parcel.obtain(); 34 | Parcel v2 = Parcel.obtain(); 35 | 36 | try { 37 | v1.writeInterfaceToken("com.asus.msa.SupplementaryDID.IDidAidlInterface"); 38 | iBinder.transact(3, v1, v2, 0); 39 | v2.readException(); 40 | result = v2.readString(); 41 | } catch (Throwable e) { 42 | v1.recycle(); 43 | v2.recycle(); 44 | e.printStackTrace(); 45 | } 46 | 47 | v1.recycle(); 48 | v2.recycle(); 49 | return result; 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /app/src/main/java/com/yr/unique/code/utils/interfaces/HWIDInterface.java: -------------------------------------------------------------------------------- 1 | package com.yr.unique.code.utils.interfaces; 2 | 3 | import android.os.IBinder; 4 | import android.os.IInterface; 5 | import android.os.Parcel; 6 | 7 | 8 | /** 9 | * 华为手机获取OAid 10 | * 11 | * @author AF 12 | * @time 2020/4/14 18:24 13 | */ 14 | public interface HWIDInterface extends IInterface { 15 | 16 | String getIDs(); 17 | 18 | boolean getBoos(); 19 | 20 | public final class HWID implements HWIDInterface { 21 | private IBinder iBinder; 22 | 23 | public HWID(IBinder ib) { 24 | iBinder = ib; 25 | } 26 | 27 | @Override 28 | public IBinder asBinder() { 29 | return iBinder; 30 | } 31 | 32 | @Override 33 | public String getIDs() { 34 | String result = null; 35 | Parcel v1 = Parcel.obtain(); 36 | Parcel v2 = Parcel.obtain(); 37 | 38 | try { 39 | v1.writeInterfaceToken("com.uodis.opendevice.aidl.OpenDeviceIdentifierService"); 40 | iBinder.transact(1, v1, v2, 0); 41 | v2.readException(); 42 | result = v2.readString(); 43 | } catch (Throwable e) { 44 | v1.recycle(); 45 | v2.recycle(); 46 | e.printStackTrace(); 47 | } 48 | 49 | v1.recycle(); 50 | v2.recycle(); 51 | return result; 52 | } 53 | 54 | @Override 55 | public boolean getBoos() { 56 | boolean result = false; 57 | Parcel v1 = Parcel.obtain(); 58 | Parcel v2 = Parcel.obtain(); 59 | try { 60 | v1.writeInterfaceToken("com.uodis.opendevice.aidl.OpenDeviceIdentifierService"); 61 | iBinder.transact(1, v1, v2, 0); 62 | v2.readException(); 63 | int read = v2.readInt(); 64 | if (read == 0) { 65 | result = true; 66 | } 67 | } catch (Throwable e) { 68 | v1.recycle(); 69 | v2.recycle(); 70 | } 71 | v1.recycle(); 72 | v2.recycle(); 73 | return result; 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /app/src/main/java/com/yr/unique/code/utils/interfaces/LenovoIDInterface.java: -------------------------------------------------------------------------------- 1 | package com.yr.unique.code.utils.interfaces; 2 | 3 | import android.os.Binder; 4 | import android.os.IBinder; 5 | import android.os.IInterface; 6 | import android.os.Parcel; 7 | import android.os.RemoteException; 8 | 9 | 10 | /** 11 | * 联想手机获取OAid 12 | * 13 | * @author AF 14 | * @time 2020/4/14 18:25 15 | */ 16 | public interface LenovoIDInterface extends IInterface { 17 | 18 | String a(); 19 | 20 | String a(String arg1); 21 | 22 | String b(); 23 | 24 | String b(String arg1); 25 | 26 | boolean c(); 27 | 28 | public abstract class Stub extends Binder implements LenovoIDInterface { 29 | 30 | @Override 31 | protected boolean onTransact(int code, Parcel data, Parcel reply, int flags) throws RemoteException { 32 | String str = "com.zui.deviceidservice.IDeviceidInterface"; 33 | switch (code) { 34 | case 1: 35 | data.enforceInterface(str); 36 | str = a(); 37 | reply.writeNoException(); 38 | reply.writeString(str); 39 | return true; 40 | case 2: 41 | data.enforceInterface(str); 42 | str = b(); 43 | reply.writeNoException(); 44 | reply.writeString(str); 45 | return true; 46 | case 3: 47 | data.enforceInterface(str); 48 | boolean c = c(); 49 | reply.writeNoException(); 50 | reply.writeInt(c ? 1 : 0); 51 | return true; 52 | case 4: 53 | data.enforceInterface(str); 54 | str = a(data.readString()); 55 | reply.writeNoException(); 56 | reply.writeString(str); 57 | return true; 58 | case 5: 59 | data.enforceInterface(str); 60 | str = b(data.readString()); 61 | reply.writeNoException(); 62 | reply.writeString(str); 63 | return true; 64 | case 1598968902: 65 | reply.writeString(str); 66 | return true; 67 | default: 68 | return super.onTransact(code, data, reply, flags); 69 | 70 | } 71 | 72 | } 73 | 74 | public static LenovoIDInterface getInstance(IBinder iBinder) { 75 | if (iBinder == null) { 76 | return null; 77 | } 78 | IInterface iInterface = iBinder.queryLocalInterface("com.zui.deviceidservice.IDeviceidInterface"); 79 | if (iInterface == null || !(iInterface instanceof LenovoIDInterface)) { 80 | return new Stub.Proxy(iBinder); 81 | } else { 82 | return (LenovoIDInterface) iInterface; 83 | } 84 | } 85 | } 86 | 87 | class Proxy implements LenovoIDInterface { 88 | 89 | private IBinder iBinder; 90 | 91 | public Proxy(IBinder ib) { 92 | iBinder = ib; 93 | } 94 | 95 | @Override 96 | public IBinder asBinder() { 97 | return null; 98 | } 99 | 100 | @Override 101 | public String a() { 102 | String readString = null; 103 | Parcel obtain = Parcel.obtain(); 104 | Parcel obtain2 = Parcel.obtain(); 105 | try { 106 | obtain.writeInterfaceToken("com.zui.deviceidservice.IDeviceidInterface"); 107 | iBinder.transact(1, obtain, obtain2, 0); 108 | obtain2.readException(); 109 | readString = obtain2.readString(); 110 | return readString; 111 | } catch (Exception e) { 112 | e.printStackTrace(); 113 | } finally { 114 | obtain2.recycle(); 115 | obtain.recycle(); 116 | } 117 | return readString; 118 | } 119 | 120 | @Override 121 | public String a(String arg1) { 122 | String readString = null; 123 | Parcel obtain = Parcel.obtain(); 124 | Parcel obtain2 = Parcel.obtain(); 125 | try { 126 | obtain.writeInterfaceToken("com.zui.deviceidservice.IDeviceidInterface"); 127 | iBinder.transact(4, obtain, obtain2, 0); 128 | obtain2.readException(); 129 | readString = obtain2.readString(); 130 | return readString; 131 | } catch (Exception e) { 132 | e.printStackTrace(); 133 | } finally { 134 | obtain2.recycle(); 135 | obtain.recycle(); 136 | } 137 | return readString; 138 | } 139 | 140 | @Override 141 | public String b() { 142 | String readString = null; 143 | Parcel obtain = Parcel.obtain(); 144 | Parcel obtain2 = Parcel.obtain(); 145 | try { 146 | obtain.writeInterfaceToken("com.zui.deviceidservice.IDeviceidInterface"); 147 | iBinder.transact(2, obtain, obtain2, 0); 148 | obtain2.readException(); 149 | readString = obtain2.readString(); 150 | return readString; 151 | } catch (Exception e) { 152 | e.printStackTrace(); 153 | } finally { 154 | obtain2.recycle(); 155 | obtain.recycle(); 156 | } 157 | return readString; 158 | } 159 | 160 | @Override 161 | public String b(String arg1) { 162 | String readString = null; 163 | Parcel obtain = Parcel.obtain(); 164 | Parcel obtain2 = Parcel.obtain(); 165 | try { 166 | obtain.writeInterfaceToken("com.zui.deviceidservice.IDeviceidInterface"); 167 | iBinder.transact(5, obtain, obtain2, 0); 168 | obtain2.readException(); 169 | readString = obtain2.readString(); 170 | return readString; 171 | } catch (Exception e) { 172 | e.printStackTrace(); 173 | } finally { 174 | obtain2.recycle(); 175 | obtain.recycle(); 176 | } 177 | return readString; 178 | } 179 | 180 | @Override 181 | public boolean c() { 182 | boolean z = false; 183 | Parcel obtain = Parcel.obtain(); 184 | Parcel obtain2 = Parcel.obtain(); 185 | try { 186 | obtain.writeInterfaceToken("com.zui.deviceidservice.IDeviceidInterface"); 187 | iBinder.transact(3, obtain, obtain2, 0); 188 | obtain2.readException(); 189 | if (obtain2.readInt() != 0) { 190 | z = true; 191 | } 192 | obtain2.recycle(); 193 | obtain.recycle(); 194 | } catch (Throwable th) { 195 | obtain2.recycle(); 196 | obtain.recycle(); 197 | } 198 | return z; 199 | } 200 | } 201 | } 202 | -------------------------------------------------------------------------------- /app/src/main/java/com/yr/unique/code/utils/interfaces/OnePlusIDInterface.java: -------------------------------------------------------------------------------- 1 | package com.yr.unique.code.utils.interfaces; 2 | 3 | import android.os.Binder; 4 | import android.os.IBinder; 5 | import android.os.IInterface; 6 | import android.os.Parcel; 7 | 8 | /** 9 | * 一加手机获取OAid 10 | * 11 | * @author AF 12 | * @time 2020/4/14 18:27 13 | */ 14 | public interface OnePlusIDInterface extends IInterface { 15 | 16 | abstract class Stub extends Binder implements OnePlusIDInterface { 17 | 18 | public static OnePlusIDInterface genInstance(IBinder iBinder) { 19 | if (iBinder == null) { 20 | return null; 21 | } 22 | IInterface iInterface = iBinder.queryLocalInterface("com.heytap.openid.IOpenID"); 23 | if (iInterface == null || !(iInterface instanceof OnePlusIDInterface)) { 24 | return new Stub.Proxy(iBinder); 25 | } else { 26 | return (OnePlusIDInterface) iInterface; 27 | } 28 | } 29 | } 30 | 31 | class Proxy implements OnePlusIDInterface { 32 | public IBinder iBinder; 33 | 34 | public Proxy(IBinder ib) { 35 | iBinder = ib; 36 | } 37 | 38 | public String getSerID(String str1, String str2, String str3) { 39 | String res = null; 40 | Parcel obtain = Parcel.obtain(); 41 | Parcel obtain2 = Parcel.obtain(); 42 | try { 43 | obtain.writeInterfaceToken("com.heytap.openid.IOpenID"); 44 | obtain.writeString(str1); 45 | obtain.writeString(str2); 46 | obtain.writeString(str3); 47 | iBinder.transact(1, obtain, obtain2, 0); 48 | obtain2.readException(); 49 | res = obtain2.readString(); 50 | } catch (Exception e) { 51 | e.printStackTrace(); 52 | } finally { 53 | obtain.recycle(); 54 | obtain2.recycle(); 55 | } 56 | return res; 57 | } 58 | 59 | @Override 60 | public IBinder asBinder() { 61 | return iBinder; 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /app/src/main/java/com/yr/unique/code/utils/interfaces/OppoIDInterface.java: -------------------------------------------------------------------------------- 1 | package com.yr.unique.code.utils.interfaces; 2 | 3 | import android.os.Binder; 4 | import android.os.IBinder; 5 | import android.os.IInterface; 6 | import android.os.Parcel; 7 | 8 | 9 | /**************************** 10 | * on 2019/10/29 11 | **************************** 12 | */ 13 | public interface OppoIDInterface extends IInterface { 14 | 15 | public abstract class Stub extends Binder implements OppoIDInterface { 16 | 17 | public static OppoIDInterface genInterface(IBinder iBinder) { 18 | if (iBinder == null) { 19 | return null; 20 | } 21 | IInterface iInterface = iBinder.queryLocalInterface("com.heytap.openid.IOpenID"); 22 | if (iInterface == null || !(iInterface instanceof OppoIDInterface)) { 23 | return new Stub.Proxy(iBinder); 24 | } else { 25 | return (OppoIDInterface) iInterface; 26 | } 27 | } 28 | } 29 | 30 | public class Proxy implements OppoIDInterface { 31 | public IBinder iBinder; 32 | 33 | public Proxy(IBinder ib) { 34 | iBinder = ib; 35 | } 36 | 37 | public String getSerID(String str1, String str2, String str3) { 38 | String res = null; 39 | Parcel obtain = Parcel.obtain(); 40 | Parcel obtain2 = Parcel.obtain(); 41 | try { 42 | obtain.writeInterfaceToken("com.heytap.openid.IOpenID"); 43 | obtain.writeString(str1); 44 | obtain.writeString(str2); 45 | obtain.writeString(str3); 46 | iBinder.transact(1, obtain, obtain2, 0); 47 | obtain2.readException(); 48 | res = obtain2.readString(); 49 | } catch (Exception e) { 50 | e.printStackTrace(); 51 | } finally { 52 | obtain.recycle(); 53 | obtain2.recycle(); 54 | } 55 | return res; 56 | } 57 | 58 | @Override 59 | public IBinder asBinder() { 60 | return iBinder; 61 | } 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /app/src/main/java/com/yr/unique/code/utils/interfaces/SamsungIDInterface.java: -------------------------------------------------------------------------------- 1 | package com.yr.unique.code.utils.interfaces; 2 | 3 | import android.os.Binder; 4 | import android.os.IBinder; 5 | import android.os.IInterface; 6 | import android.os.Parcel; 7 | 8 | 9 | /**************************** 10 | * * on 2019/10/29 11 | **************************** 12 | */ 13 | public interface SamsungIDInterface extends IInterface { 14 | 15 | String getID(); 16 | 17 | class Proxy implements SamsungIDInterface { 18 | 19 | private IBinder mIBinder; 20 | 21 | public Proxy(IBinder iBinder) { 22 | super(); 23 | mIBinder = iBinder; 24 | } 25 | 26 | @Override 27 | public IBinder asBinder() { 28 | return mIBinder; 29 | } 30 | 31 | @Override 32 | public String getID() { 33 | String result = null; 34 | Parcel v1 = Parcel.obtain(); 35 | Parcel v2 = Parcel.obtain(); 36 | try { 37 | v1.writeInterfaceToken("com.samsung.android.deviceidservice.IDeviceIdService"); 38 | mIBinder.transact(1, v1, v2, 0); 39 | v2.readException(); 40 | result = v2.readString(); 41 | } catch (Throwable t) { 42 | v2.recycle(); 43 | v1.recycle(); 44 | t.printStackTrace(); 45 | } 46 | v2.recycle(); 47 | v1.recycle(); 48 | 49 | return result; 50 | } 51 | } 52 | 53 | abstract class Stub extends Binder implements SamsungIDInterface { 54 | 55 | public Stub() { 56 | super(); 57 | this.attachInterface(((IInterface) this), "com.samsung.android.deviceidservice.IDeviceIdService"); 58 | } 59 | 60 | public SamsungIDInterface a(IBinder iBinder) { 61 | if (iBinder == null) { 62 | return null; 63 | } 64 | IInterface iInterface = iBinder.queryLocalInterface("com.samsung.android.deviceidservice.IDeviceIdService"); 65 | if (iInterface == null) { 66 | return null; 67 | } 68 | Proxy proxy = new Proxy(iBinder); 69 | return (SamsungIDInterface) proxy; 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /app/src/main/java/com/yr/unique/code/utils/interfaces/ZTEIDInterface.java: -------------------------------------------------------------------------------- 1 | package com.yr.unique.code.utils.interfaces; 2 | 3 | import android.os.Binder; 4 | import android.os.IBinder; 5 | import android.os.IInterface; 6 | import android.os.Parcel; 7 | 8 | 9 | public interface ZTEIDInterface extends IInterface { 10 | boolean c(); 11 | 12 | String getOAID(); 13 | 14 | boolean isSupported(); 15 | 16 | void shutDown(); 17 | 18 | abstract class Stub extends Binder implements ZTEIDInterface { 19 | } 20 | 21 | public static class Proxy implements ZTEIDInterface { 22 | private IBinder binder; 23 | 24 | public Proxy(IBinder b) { 25 | binder = b; 26 | } 27 | 28 | @Override 29 | public IBinder asBinder() { 30 | return binder; 31 | } 32 | 33 | @Override 34 | public boolean c() { 35 | boolean v0 = false; 36 | Parcel v1 = Parcel.obtain(); 37 | Parcel v2 = Parcel.obtain(); 38 | try { 39 | v1.writeInterfaceToken("com.bun.lib.MsaIdInterface"); 40 | binder.transact(2, v1, v2, 0); 41 | v2.readException(); 42 | if (v2.readInt() == 0) { 43 | v2.recycle(); 44 | v1.recycle(); 45 | v0 = true; 46 | } 47 | } catch (Throwable v0_1) { 48 | v2.recycle(); 49 | v1.recycle(); 50 | v0_1.printStackTrace(); 51 | } 52 | return v0; 53 | } 54 | 55 | @Override 56 | public String getOAID() { 57 | String v0_1 = null; 58 | Parcel v1 = Parcel.obtain(); 59 | Parcel v2 = Parcel.obtain(); 60 | try { 61 | v1.writeInterfaceToken("com.bun.lib.MsaIdInterface"); 62 | binder.transact(3, v1, v2, 0); 63 | v2.readException(); 64 | v0_1 = v2.readString(); 65 | } catch (Throwable v0) { 66 | v2.recycle(); 67 | v1.recycle(); 68 | } 69 | 70 | v2.recycle(); 71 | v1.recycle(); 72 | return v0_1; 73 | } 74 | 75 | @Override 76 | public boolean isSupported() { 77 | return false; 78 | } 79 | 80 | @Override 81 | public void shutDown() { 82 | Parcel v1 = Parcel.obtain(); 83 | Parcel v2 = Parcel.obtain(); 84 | try { 85 | v1.writeInterfaceToken("com.bun.lib.MsaIdInterface"); 86 | binder.transact(6, v1, v2, 0); 87 | v2.readException(); 88 | } catch (Throwable v0) { 89 | v2.recycle(); 90 | v1.recycle(); 91 | } 92 | v2.recycle(); 93 | v1.recycle(); 94 | } 95 | } 96 | 97 | } 98 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 15 | 18 | 21 | 22 | 23 | 24 | 30 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 |