Make users of MtpServer provide DeviceInfo fields

This is part of weaning apps off accessing system identifiers via
system properties API. Apps should use android.os.Build API instead.

Bug: 33700679
Test: Enable MTP mode then check that mtp-detect output same as before this commit
Change-Id: Ic21da7b8e976aaa1abc606a3cb4a1f2bd8698408
diff --git a/media/mtp/MtpServer.cpp b/media/mtp/MtpServer.cpp
index 2a96ac9..8d56c16 100644
--- a/media/mtp/MtpServer.cpp
+++ b/media/mtp/MtpServer.cpp
@@ -16,7 +16,6 @@
 
 #include <android-base/properties.h>
 #include <chrono>
-#include <cutils/properties.h>
 #include <dirent.h>
 #include <errno.h>
 #include <fcntl.h>
@@ -96,12 +95,20 @@
 };
 
 MtpServer::MtpServer(MtpDatabase* database, bool ptp,
-                    int fileGroup, int filePerm, int directoryPerm)
+                    int fileGroup, int filePerm, int directoryPerm,
+                    const MtpString& deviceInfoManufacturer,
+                    const MtpString& deviceInfoModel,
+                    const MtpString& deviceInfoDeviceVersion,
+                    const MtpString& deviceInfoSerialNumber)
     :   mDatabase(database),
         mPtp(ptp),
         mFileGroup(fileGroup),
         mFilePermission(filePerm),
         mDirectoryPermission(directoryPerm),
+        mDeviceInfoManufacturer(deviceInfoManufacturer),
+        mDeviceInfoModel(deviceInfoModel),
+        mDeviceInfoDeviceVersion(deviceInfoDeviceVersion),
+        mDeviceInfoSerialNumber(deviceInfoSerialNumber),
         mSessionID(0),
         mSessionOpen(false),
         mSendObjectHandle(kInvalidObjectHandle),
@@ -451,7 +458,6 @@
 
 MtpResponseCode MtpServer::doGetDeviceInfo() {
     MtpStringBuffer   string;
-    char prop_value[PROPERTY_VALUE_MAX];
 
     MtpObjectFormatList* playbackFormats = mDatabase->getSupportedPlaybackFormats();
     MtpObjectFormatList* captureFormats = mDatabase->getSupportedCaptureFormats();
@@ -483,19 +489,10 @@
     mData.putAUInt16(captureFormats); // Capture Formats
     mData.putAUInt16(playbackFormats);  // Playback Formats
 
-    property_get("ro.product.manufacturer", prop_value, "unknown manufacturer");
-    string.set(prop_value);
-    mData.putString(string);   // Manufacturer
-
-    property_get("ro.product.model", prop_value, "MTP Device");
-    string.set(prop_value);
-    mData.putString(string);   // Model
-    string.set("1.0");
-    mData.putString(string);   // Device Version
-
-    property_get("ro.serialno", prop_value, "????????");
-    string.set(prop_value);
-    mData.putString(string);   // Serial Number
+    mData.putString(mDeviceInfoManufacturer); // Manufacturer
+    mData.putString(mDeviceInfoModel); // Model
+    mData.putString(mDeviceInfoDeviceVersion); // Device Version
+    mData.putString(mDeviceInfoSerialNumber); // Serial Number
 
     delete playbackFormats;
     delete captureFormats;