2011-01-13 203 views
5

有沒有辦法改變模擬器的TelephonyManager將返回的IMEI?另外,有沒有辦法改變Settings.Secure.ANDROID_ID返回的ID?更改Android模擬器上的設備ID?

我在服務器端存儲他們的數據時使用這些ID區分我的用戶。如果我的QA團隊可以更改這些ID,以便它們不都使用相同的一組用戶數據,那將會很好。

回答

2

我還沒有嘗試過,但this page概述了一種涉及手動修改emaultor.exe文件的方法。這看起來很簡單,但你必須爲每個QA團隊成員創建一個單獨的模擬器。

+0

它不是最好的方式,但它是唯一的出路!在他的後續[post](http://blog.codepainters.com/2010/11/20/android-emulator-patch-for-configurable-imei-imsi-and-sim-card-serial-number/)他提供了一個補丁來使其可配置(當然,需要重新編譯仿真器)。 – 2011-01-18 23:25:47

+0

Upvoting由於鏈接到我的博客:)請注意,我將博客移動到http://blog.codepainters.com,盡情享受吧! – 2012-11-13 10:16:19

2

至於Settings.Secure.ANDROID_ID去,這應該做的伎倆:

adb shell sqlite3 /data/data/com.android.providers.settings/databases/settings.db "UPDATE secure SET value='newid' WHERE name='android_id'

哪裏newid通常是16進制數字代碼(即不追加 」Android_「 的話)。我只是想這對我模擬器想象一個真正的手機將需要先紮根

1

查詢android_id在亞行外殼使用這個命令:。

settings get secure android_id

變化android_id在亞行外殼使用這個命令:

settings put secure android_id xxxxxxxxxxxxxxxx

0

答案ZYC ZYC是最好的一個,直到安卓7.1.1(25)。在Android android_id的8條規則作爲官方開發者文檔中描述了變化: https://android-developers.googleblog.com/2017/04/changes-to-device-identifiers-in.html

In O, Android ID (Settings.Secure.ANDROID_ID or SSAID) has a different value for each app and each user on the device. Developers requiring a device-scoped identifier, should instead use a resettable identifier, such as Advertising ID, giving users more control. Advertising ID also provides a user-facing setting to limit ad tracking. Additionally in Android O: The ANDROID_ID value won't change on package uninstall/reinstall, as long as the package name and signing key are the same. Apps can rely on this value to maintain state across reinstalls. If an app was installed on a device running an earlier version of Android, the Android ID remains the same when the device is updated to Android O, unless the app is uninstalled and reinstalled. The Android ID value only changes if the device is factory reset or if the signing key rotates between uninstall and reinstall events. This change is only required for device manufacturers shipping with Google Play services and Advertising ID. Other device manufacturers may provide an alternative resettable ID or continue to provide ANDROID ID.

相關問題