修改文件:
frameworks\base\media\java\android\mtp\MtpDatabase.java
修改方法:
增加导包
///START. Fix the display error on PC. By XiaFei, 20170503.import android.os.SystemProperties;///import com.mediatek.xlog.SXlog;///import com.mediatek.xlog.Xlog;import java.lang.Integer;///END. Fix the display error on PC. By XiaFei, 20170503.
插入如下代码
private int getDeviceProperty(int property, long[] outIntValue, char[] outStringValue) {Log.d(TAG, "getDeviceProperty property = 0x" + Integer.toHexString(property));switch (property) {case MtpConstants.DEVICE_PROPERTY_SYNCHRONIZATION_PARTNER:case MtpConstants.DEVICE_PROPERTY_DEVICE_FRIENDLY_NAME:// writable string properties kept in shared preferencesString value = mDeviceProperties.getString(Integer.toString(property), "");int length = value.length();if (length > 255) {length = 255;}value.getChars(0, length, outStringValue, 0);outStringValue[length] = 0;///START. Fix the display error on PC. By XiaFei, 20170503.// Return the device name for the PC display if the FriendlyName is empty!!String deviceName = SystemProperties.get("ro.product.name");int lengthDeviceName = deviceName.length();if (lengthDeviceName > 255) {lengthDeviceName = 255;}if(lengthDeviceName >0) {deviceName.getChars(0, lengthDeviceName, outStringValue, 0);outStringValue[lengthDeviceName] = 0;///SXlog.d(TAG, "getDeviceProperty deviceName = " + deviceName + ", lengthDeviceName = " + lengthDeviceName);} else {///SXlog.d(TAG, "getDeviceProperty lengthDeviceName = " + lengthDeviceName);}///END. Fix the display error on PC. By XiaFei, 20170503.return MtpConstants.RESPONSE_OK;case MtpConstants.DEVICE_PROPERTY_IMAGE_SIZE:// use screen size as max image sizeDisplay display = ((WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();int width = display.getMaximumSizeDimension();int height = display.getMaximumSizeDimension();String imageSize = Integer.toString(width) + "x" + Integer.toString(height);imageSize.getChars(0, imageSize.length(), outStringValue, 0);outStringValue[imageSize.length()] = 0;return MtpConstants.RESPONSE_OK;// DEVICE_PROPERTY_BATTERY_LEVEL is implemented in the JNI codedefault:return MtpConstants.RESPONSE_DEVICE_PROP_NOT_SUPPORTED;}}
