修改文件:

frameworks\base\media\java\android\mtp\MtpDatabase.java

修改方法:
  1. 增加导包

    1. ///START. Fix the display error on PC. By XiaFei, 20170503.
    2. import android.os.SystemProperties;
    3. ///import com.mediatek.xlog.SXlog;
    4. ///import com.mediatek.xlog.Xlog;
    5. import java.lang.Integer;
    6. ///END. Fix the display error on PC. By XiaFei, 20170503.
  2. 插入如下代码

    1. private int getDeviceProperty(int property, long[] outIntValue, char[] outStringValue) {
    2. Log.d(TAG, "getDeviceProperty property = 0x" + Integer.toHexString(property));
    3. switch (property) {
    4. case MtpConstants.DEVICE_PROPERTY_SYNCHRONIZATION_PARTNER:
    5. case MtpConstants.DEVICE_PROPERTY_DEVICE_FRIENDLY_NAME:
    6. // writable string properties kept in shared preferences
    7. String value = mDeviceProperties.getString(Integer.toString(property), "");
    8. int length = value.length();
    9. if (length > 255) {
    10. length = 255;
    11. }
    12. value.getChars(0, length, outStringValue, 0);
    13. outStringValue[length] = 0;
    14. ///START. Fix the display error on PC. By XiaFei, 20170503.
    15. // Return the device name for the PC display if the FriendlyName is empty!!
    16. String deviceName = SystemProperties.get("ro.product.name");
    17. int lengthDeviceName = deviceName.length();
    18. if (lengthDeviceName > 255) {
    19. lengthDeviceName = 255;
    20. }
    21. if(lengthDeviceName >0) {
    22. deviceName.getChars(0, lengthDeviceName, outStringValue, 0);
    23. outStringValue[lengthDeviceName] = 0;
    24. ///SXlog.d(TAG, "getDeviceProperty deviceName = " + deviceName + ", lengthDeviceName = " + lengthDeviceName);
    25. } else {
    26. ///SXlog.d(TAG, "getDeviceProperty lengthDeviceName = " + lengthDeviceName);
    27. }
    28. ///END. Fix the display error on PC. By XiaFei, 20170503.
    29. return MtpConstants.RESPONSE_OK;
    30. case MtpConstants.DEVICE_PROPERTY_IMAGE_SIZE:
    31. // use screen size as max image size
    32. Display display = ((WindowManager)mContext.getSystemService(
    33. Context.WINDOW_SERVICE)).getDefaultDisplay();
    34. int width = display.getMaximumSizeDimension();
    35. int height = display.getMaximumSizeDimension();
    36. String imageSize = Integer.toString(width) + "x" + Integer.toString(height);
    37. imageSize.getChars(0, imageSize.length(), outStringValue, 0);
    38. outStringValue[imageSize.length()] = 0;
    39. return MtpConstants.RESPONSE_OK;
    40. // DEVICE_PROPERTY_BATTERY_LEVEL is implemented in the JNI code
    41. default:
    42. return MtpConstants.RESPONSE_DEVICE_PROP_NOT_SUPPORTED;
    43. }
    44. }