Extract the otapreopt parameters in their own class and add tests

This is in preparation to get rid of the annoying
ReadArgumentV1..5 pattern and to be able to write
unit tests.

(cherry picked from commit c9e76799ef0dc4358fb5e2a815c42311aac6b81b)

Test: installd_dexopt_test
Bug: 72666394
Merged-In: I0ad438ee69aa82d9ff2ad2f94d465dcc78ea8c28
Change-Id: I0ad438ee69aa82d9ff2ad2f94d465dcc78ea8c28
diff --git a/cmds/installd/otapreopt_parameters.h b/cmds/installd/otapreopt_parameters.h
new file mode 100644
index 0000000..20faeb5
--- /dev/null
+++ b/cmds/installd/otapreopt_parameters.h
@@ -0,0 +1,61 @@
+/*
+ ** Copyright 2018, The Android Open Source Project
+ **
+ ** Licensed under the Apache License, Version 2.0 (the "License");
+ ** you may not use this file except in compliance with the License.
+ ** You may obtain a copy of the License at
+ **
+ **     http://www.apache.org/licenses/LICENSE-2.0
+ **
+ ** Unless required by applicable law or agreed to in writing, software
+ ** distributed under the License is distributed on an "AS IS" BASIS,
+ ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ** See the License for the specific language governing permissions and
+ ** limitations under the License.
+ */
+
+#ifndef OTAPREOPT_PARAMETERS_H_
+#define OTAPREOPT_PARAMETERS_H_
+
+#include <string>
+#include <sys/types.h>
+
+namespace android {
+namespace installd {
+
+class OTAPreoptParameters {
+  public:
+    bool ReadArguments(int argc, const char** argv);
+
+  private:
+    bool ReadArgumentsV1(int argc, const char** argv);
+    bool ReadArgumentsV2(int argc, const char** argv, bool versioned);
+    bool ReadArgumentsV3(int argc, const char** argv);
+    bool ReadArgumentsV4(int argc, const char** argv);
+    bool ReadArgumentsV5(int argc, const char** argv);
+
+    const char* apk_path;
+    uid_t uid;
+    const char* pkgName;
+    const char* instruction_set;
+    int dexopt_needed;
+    const char* oat_dir;
+    int dexopt_flags;
+    const char* compiler_filter;
+    const char* volume_uuid;
+    const char* shared_libraries;
+    const char* se_info;
+    bool downgrade;
+    int target_sdk_version;
+    const char* profile_name;
+
+    std::string target_slot;
+
+    friend class OTAPreoptService;
+    friend class OTAPreoptTest;
+};
+
+}  // namespace installd
+}  // namespace android
+
+#endif  //  OTAPREOPT_PARAMETERS_H_
\ No newline at end of file