From 1c53cc161d5a8262fd959c8cd867b138b6344bba Mon Sep 17 00:00:00 2001
From: Sundong Ahn <sundongahn@google.com>
Date: Fri, 18 May 2018 09:58:11 +0900
Subject: [PATCH] Build java.obex with java_sdk_library

javax.obex is built with java_sdk_library and api files are added by
running "make update-api".
Remove java.obex is from platform.xml, since it will be generated
automatically by soong when the library is built with java_sdk_library.

Bug:77577799
Test: make -j
      make checkapi

Change-Id: Ib94955e62582ffbdfc7eb88cd0e494c61757c7aa
---
 data/etc/platform.xml       |  2 --
 obex/Android.bp             | 21 +++++++++++++++++++++
 obex/Android.mk             | 20 --------------------
 obex/CleanSpec.mk           | 18 ++++++++++++++++++
 obex/api/current.txt        | 12 ++++++++++++
 obex/api/removed.txt        |  0
 obex/api/system-current.txt |  0
 obex/api/system-removed.txt |  0
 obex/api/test-current.txt   |  0
 obex/api/test-removed.txt   |  0
 10 files changed, 51 insertions(+), 22 deletions(-)
 create mode 100644 obex/Android.bp
 delete mode 100644 obex/Android.mk
 create mode 100644 obex/CleanSpec.mk
 create mode 100644 obex/api/current.txt
 create mode 100644 obex/api/removed.txt
 create mode 100644 obex/api/system-current.txt
 create mode 100644 obex/api/system-removed.txt
 create mode 100644 obex/api/test-current.txt
 create mode 100644 obex/api/test-removed.txt

diff --git a/data/etc/platform.xml b/data/etc/platform.xml
index 434dfdf56e0ec..64085ea74edc4 100644
--- a/data/etc/platform.xml
+++ b/data/etc/platform.xml
@@ -167,8 +167,6 @@
             file="/system/framework/android.test.mock.jar" />
     <library name="android.test.runner"
             file="/system/framework/android.test.runner.jar" />
-    <library name="javax.obex"
-            file="/system/framework/javax.obex.jar" />
 
     <!-- These are the standard packages that are white-listed to always have internet
          access while in power save mode, even if they aren't in the foreground. -->
diff --git a/obex/Android.bp b/obex/Android.bp
new file mode 100644
index 0000000000000..6558eb36d0010
--- /dev/null
+++ b/obex/Android.bp
@@ -0,0 +1,21 @@
+//
+// Copyright (C) 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.
+//
+
+java_sdk_library {
+    name: "javax.obex",
+    srcs: ["javax/**/*.java"],
+    api_packages: ["javax.obex"],
+}
diff --git a/obex/Android.mk b/obex/Android.mk
deleted file mode 100644
index e7c1fd34dd749..0000000000000
--- a/obex/Android.mk
+++ /dev/null
@@ -1,20 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
-
-LOCAL_MODULE:= javax.obex
-
-include $(BUILD_JAVA_LIBRARY)
-
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
-
-LOCAL_MODULE:= javax.obexstatic
-
-include $(BUILD_STATIC_JAVA_LIBRARY)
\ No newline at end of file
diff --git a/obex/CleanSpec.mk b/obex/CleanSpec.mk
new file mode 100644
index 0000000000000..c104234e4fd9f
--- /dev/null
+++ b/obex/CleanSpec.mk
@@ -0,0 +1,18 @@
+#
+# Copyright (C) 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.
+#
+
+# runtime lib is renamed from javax.obex.jar to javax.obex.impl.jar
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/framework/javax.obex.jar)
diff --git a/obex/api/current.txt b/obex/api/current.txt
new file mode 100644
index 0000000000000..1cd562feff8dc
--- /dev/null
+++ b/obex/api/current.txt
@@ -0,0 +1,12 @@
+package javax.obex {
+
+  public class ObexPacket {
+    method public static javax.obex.ObexPacket read(java.io.InputStream) throws java.io.IOException;
+    method public static javax.obex.ObexPacket read(int, java.io.InputStream) throws java.io.IOException;
+    field public int mHeaderId;
+    field public int mLength;
+    field public byte[] mPayload;
+  }
+
+}
+
diff --git a/obex/api/removed.txt b/obex/api/removed.txt
new file mode 100644
index 0000000000000..e69de29bb2d1d
diff --git a/obex/api/system-current.txt b/obex/api/system-current.txt
new file mode 100644
index 0000000000000..e69de29bb2d1d
diff --git a/obex/api/system-removed.txt b/obex/api/system-removed.txt
new file mode 100644
index 0000000000000..e69de29bb2d1d
diff --git a/obex/api/test-current.txt b/obex/api/test-current.txt
new file mode 100644
index 0000000000000..e69de29bb2d1d
diff --git a/obex/api/test-removed.txt b/obex/api/test-removed.txt
new file mode 100644
index 0000000000000..e69de29bb2d1d
-- 
GitLab