From 63bdde81a3360891864e902b5e2a6181ebdeebd2 Mon Sep 17 00:00:00 2001
From: Sundong Ahn <sundongahn@google.com>
Date: Thu, 24 May 2018 17:18:12 +0900
Subject: [PATCH] com.android.mediadrm.signer is built with java_sdk_library

The com.android.mediadrm.signer is built with java_sdk_library
and api files are added by running "make update-api".
The com.android.mediadrm.signer is removed in platform.xml
since it will be made auto generation by soong when the library is
built with java_sdk_library.

Bug:77577799
Test: make -j
Test: make checkapi

Merged-In: I0e773615abe6aa8d757e489de2b9d807cd356146
Change-Id: I0e773615abe6aa8d757e489de2b9d807cd356146
(cherry picked from commit 2e1089bae43fe327346c531fcbdd4cc5d1664b14)
---
 CleanSpec.mk                                  |  1 +
 media/lib/signer/Android.bp                   | 21 +++++++++
 media/lib/signer/Android.mk                   | 44 -------------------
 media/lib/signer/api/current.txt              | 21 +++++++++
 media/lib/signer/api/removed.txt              |  0
 media/lib/signer/api/system-current.txt       |  0
 media/lib/signer/api/system-removed.txt       |  0
 media/lib/signer/api/test-current.txt         |  0
 media/lib/signer/api/test-removed.txt         |  0
 .../signer/com.android.mediadrm.signer.xml    | 20 ---------
 10 files changed, 43 insertions(+), 64 deletions(-)
 create mode 100644 media/lib/signer/Android.bp
 delete mode 100644 media/lib/signer/Android.mk
 create mode 100644 media/lib/signer/api/current.txt
 create mode 100644 media/lib/signer/api/removed.txt
 create mode 100644 media/lib/signer/api/system-current.txt
 create mode 100644 media/lib/signer/api/system-removed.txt
 create mode 100644 media/lib/signer/api/test-current.txt
 create mode 100644 media/lib/signer/api/test-removed.txt
 delete mode 100644 media/lib/signer/com.android.mediadrm.signer.xml

diff --git a/CleanSpec.mk b/CleanSpec.mk
index e728897139454..cc0e76205abb0 100644
--- a/CleanSpec.mk
+++ b/CleanSpec.mk
@@ -243,6 +243,7 @@ $(call add-clean-step, rm -f $(OUT_DIR)/target/common/obj/APPS/FeatureSplit2_int
 $(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/core/java/android/hardware)
 $(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/framework_intermediates/core/java/android/os/storage/*)
 $(call add-clean-step, rm -rf $(OUT_DIR)/host/common/obj/JAVA_LIBRARIES/platformprotos_intermediates)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/framework/com.android.mediadrm.signer.jar)
 # ******************************************************************
 # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST ABOVE THIS BANNER
 # ******************************************************************
diff --git a/media/lib/signer/Android.bp b/media/lib/signer/Android.bp
new file mode 100644
index 0000000000000..3b25787540874
--- /dev/null
+++ b/media/lib/signer/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: "com.android.mediadrm.signer",
+    srcs: ["java/**/*.java"],
+    api_packages: ["com.android.mediadrm.signer"],
+}
diff --git a/media/lib/signer/Android.mk b/media/lib/signer/Android.mk
deleted file mode 100644
index 69ca4d2fc8c5c..0000000000000
--- a/media/lib/signer/Android.mk
+++ /dev/null
@@ -1,44 +0,0 @@
-#
-# Copyright (C) 2013 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.
-#
-LOCAL_PATH := $(call my-dir)
-
-# the mediadrm signer library
-# ============================================================
-include $(CLEAR_VARS)
-
-LOCAL_MODULE:= com.android.mediadrm.signer
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_SRC_FILES := $(call all-java-files-under, java)
-
-include $(BUILD_JAVA_LIBRARY)
-
-
-# ====  com.android.mediadrm.signer.xml lib def  ========================
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := com.android.mediadrm.signer.xml
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_MODULE_CLASS := ETC
-
-# This will install the file in /system/etc/permissions
-#
-LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/permissions
-
-LOCAL_SRC_FILES := $(LOCAL_MODULE)
-
-include $(BUILD_PREBUILT)
diff --git a/media/lib/signer/api/current.txt b/media/lib/signer/api/current.txt
new file mode 100644
index 0000000000000..4aa912d66cb40
--- /dev/null
+++ b/media/lib/signer/api/current.txt
@@ -0,0 +1,21 @@
+package com.android.mediadrm.signer {
+
+  public final class MediaDrmSigner {
+    method public static com.android.mediadrm.signer.MediaDrmSigner.CertificateRequest getCertificateRequest(android.media.MediaDrm, int, java.lang.String);
+    method public static com.android.mediadrm.signer.MediaDrmSigner.Certificate provideCertificateResponse(android.media.MediaDrm, byte[]) throws android.media.DeniedByServerException;
+    method public static byte[] signRSA(android.media.MediaDrm, byte[], java.lang.String, byte[], byte[]);
+    field public static final int CERTIFICATE_TYPE_X509 = 1; // 0x1
+  }
+
+  public static final class MediaDrmSigner.Certificate {
+    method public byte[] getContent();
+    method public byte[] getWrappedPrivateKey();
+  }
+
+  public static final class MediaDrmSigner.CertificateRequest {
+    method public byte[] getData();
+    method public java.lang.String getDefaultUrl();
+  }
+
+}
+
diff --git a/media/lib/signer/api/removed.txt b/media/lib/signer/api/removed.txt
new file mode 100644
index 0000000000000..e69de29bb2d1d
diff --git a/media/lib/signer/api/system-current.txt b/media/lib/signer/api/system-current.txt
new file mode 100644
index 0000000000000..e69de29bb2d1d
diff --git a/media/lib/signer/api/system-removed.txt b/media/lib/signer/api/system-removed.txt
new file mode 100644
index 0000000000000..e69de29bb2d1d
diff --git a/media/lib/signer/api/test-current.txt b/media/lib/signer/api/test-current.txt
new file mode 100644
index 0000000000000..e69de29bb2d1d
diff --git a/media/lib/signer/api/test-removed.txt b/media/lib/signer/api/test-removed.txt
new file mode 100644
index 0000000000000..e69de29bb2d1d
diff --git a/media/lib/signer/com.android.mediadrm.signer.xml b/media/lib/signer/com.android.mediadrm.signer.xml
deleted file mode 100644
index fd3a1158095da..0000000000000
--- a/media/lib/signer/com.android.mediadrm.signer.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2013 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.
--->
-
-<permissions>
-    <library name="com.android.mediadrm.signer"
-            file="/system/framework/com.android.mediadrm.signer.jar" />
-</permissions>
-- 
GitLab