Add support for MTP perceived device type property.

Property value is based on the particular device.
This allows some hosts (windows) to apply a device
specific icon in file explorer.

Test: Connect device to windows, verify new icon
Bug: 25360563
Change-Id: I9d3468ca8c01a6f0d42ad543aef11ed265b6c825
This commit is contained in:
Jerry Zhang
2016-12-14 15:39:29 -08:00
parent a83222e4fb
commit 13bb2f4dda
2 changed files with 20 additions and 0 deletions

View File

@@ -29,6 +29,7 @@ import android.media.MediaScanner;
import android.net.Uri;
import android.os.BatteryManager;
import android.os.RemoteException;
import android.os.SystemProperties;
import android.provider.MediaStore;
import android.provider.MediaStore.Audio;
import android.provider.MediaStore.Files;
@@ -133,6 +134,8 @@ public class MtpDatabase implements AutoCloseable {
private int mBatteryLevel;
private int mBatteryScale;
private int mDeviceType;
static {
System.loadLibrary("media_jni");
}
@@ -195,6 +198,7 @@ public class MtpDatabase implements AutoCloseable {
}
initDeviceProperties(context);
mDeviceType = SystemProperties.getInt("sys.usb.mtp.device_type", 0);
mCloseGuard.open("close");
}
@@ -710,6 +714,7 @@ public class MtpDatabase implements AutoCloseable {
MtpConstants.DEVICE_PROPERTY_DEVICE_FRIENDLY_NAME,
MtpConstants.DEVICE_PROPERTY_IMAGE_SIZE,
MtpConstants.DEVICE_PROPERTY_BATTERY_LEVEL,
MtpConstants.DEVICE_PROPERTY_PERCEIVED_DEVICE_TYPE,
};
}
@@ -869,6 +874,10 @@ public class MtpDatabase implements AutoCloseable {
outStringValue[imageSize.length()] = 0;
return MtpConstants.RESPONSE_OK;
case MtpConstants.DEVICE_PROPERTY_PERCEIVED_DEVICE_TYPE:
outIntValue[0] = mDeviceType;
return MtpConstants.RESPONSE_OK;
// DEVICE_PROPERTY_BATTERY_LEVEL is implemented in the JNI code
default: