需求:
客户apk无法通过Build.getSerial方法正常获取到机器序列号
解决方法:
代码路径:frameworks/base/core/java/android/os/Build.java
--- a/core/java/android/os/Build.java
+++ b/core/java/android/os/Build.java
@@ -157,7 +157,7 @@ public class Build {
// IMPORTANT: This field should be initialized via a function call to
// prevent its value being inlined in the app during compilation because
// we will later set it to the value based on the app's target SDK.
- public static final String SERIAL = getString("no.such.thing");
+ public static final String SERIAL = getString("ro.serialno");
/**
* Gets the hardware serial number, if available.
@@ -199,7 +199,8 @@ public class Build {
@SuppressAutoDoc // No support for device / profile owner.
@RequiresPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
public static String getSerial() {
- IDeviceIdentifiersPolicyService service = IDeviceIdentifiersPolicyService.Stub
+ return getString("ro.serialno");
+ /*IDeviceIdentifiersPolicyService service = IDeviceIdentifiersPolicyService.Stub
.asInterface(ServiceManager.getService(Context.DEVICE_IDENTIFIERS_SERVICE));
try {
Application application = ActivityThread.currentApplication();
@@ -208,7 +209,7 @@ public class Build {
} catch (RemoteException e) {
e.rethrowFromSystemServer();
}
- return UNKNOWN;
+ return UNKNOWN;*/
}