Merge "Add support for MTP perceived device type property."
This commit is contained in:
@ -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:
|
||||
|
@ -76,6 +76,7 @@ static jmethodID method_sessionEnded;
|
||||
static jfieldID field_context;
|
||||
static jfieldID field_batteryLevel;
|
||||
static jfieldID field_batteryScale;
|
||||
static jfieldID field_deviceType;
|
||||
|
||||
// MtpPropertyList fields
|
||||
static jfieldID field_mCount;
|
||||
@ -1030,6 +1031,7 @@ static const PropertyTableEntry kDevicePropertyTable[] = {
|
||||
{ MTP_DEVICE_PROPERTY_DEVICE_FRIENDLY_NAME, MTP_TYPE_STR },
|
||||
{ MTP_DEVICE_PROPERTY_IMAGE_SIZE, MTP_TYPE_STR },
|
||||
{ MTP_DEVICE_PROPERTY_BATTERY_LEVEL, MTP_TYPE_UINT8 },
|
||||
{ MTP_DEVICE_PROPERTY_PERCEIVED_DEVICE_TYPE, MTP_TYPE_UINT32 },
|
||||
};
|
||||
|
||||
bool MyMtpDatabase::getObjectPropertyInfo(MtpObjectProperty property, int& type) {
|
||||
@ -1209,6 +1211,10 @@ MtpProperty* MyMtpDatabase::getDevicePropertyDesc(MtpDeviceProperty property) {
|
||||
result->setFormRange(0, env->GetIntField(mDatabase, field_batteryScale), 1);
|
||||
result->mCurrentValue.u.u8 = (uint8_t)env->GetIntField(mDatabase, field_batteryLevel);
|
||||
break;
|
||||
case MTP_DEVICE_PROPERTY_PERCEIVED_DEVICE_TYPE:
|
||||
result = new MtpProperty(property, MTP_TYPE_UINT32);
|
||||
result->mCurrentValue.u.u32 = (uint32_t)env->GetIntField(mDatabase, field_deviceType);
|
||||
break;
|
||||
}
|
||||
|
||||
checkAndClearExceptionFromCallback(env, __FUNCTION__);
|
||||
@ -1388,6 +1394,11 @@ int register_android_mtp_MtpDatabase(JNIEnv *env)
|
||||
ALOGE("Can't find MtpDatabase.mBatteryScale");
|
||||
return -1;
|
||||
}
|
||||
field_deviceType = env->GetFieldID(clazz, "mDeviceType", "I");
|
||||
if (field_deviceType == NULL) {
|
||||
ALOGE("Can't find MtpDatabase.mDeviceType");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// now set up fields for MtpPropertyList class
|
||||
clazz = env->FindClass("android/mtp/MtpPropertyList");
|
||||
|
Reference in New Issue
Block a user