Merge "Add hansson to OWNERS."
diff --git a/build/Android.bp b/build/Android.bp
new file mode 100644
index 0000000..649094c
--- /dev/null
+++ b/build/Android.bp
@@ -0,0 +1,24 @@
+//
+// Copyright (C) 2020 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.
+//
+
+// For use by modules.
+java_library {
+ name: "modules-utils-build",
+ srcs: [
+ "src/**/*.java",
+ ],
+ sdk_version: "module_current",
+}
diff --git a/build/src/com/android/modules/utils/build/SdkLevel.java b/build/src/com/android/modules/utils/build/SdkLevel.java
new file mode 100644
index 0000000..689d91e
--- /dev/null
+++ b/build/src/com/android/modules/utils/build/SdkLevel.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2020 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.
+ */
+
+package com.android.modules.utils.build;
+
+import android.os.Build;
+
+/**
+ * Utility class to check SDK level.
+ *
+ * @hide
+ */
+public class SdkLevel {
+
+ private SdkLevel() {}
+
+ /** Return true iff the running Android SDK is at least "R". */
+ public static boolean isAtLeastR() {
+ return Build.VERSION.SDK_INT >= Build.VERSION_CODES.R;
+ }
+
+ /**
+ * Returns true iff the running Android SDK is pre-release "S", built based on "R" SDK.
+ *
+ * If new SDK versions are added > R, then this method needs to be updated to recognise them
+ * (e.g. if we add SDK version for R-QPR, the current implementation will not recognise
+ * pre-release "S" versions built on that).
+ */
+ public static boolean isAtLeastS() {
+ // TODO(b/170831689) This should check SDK_INT >= S once S sdk finalised. Note that removing the
+ // current conditions may lead to issues in mainlinefood (and possibly public beta?).
+
+ // While in development, builds will have R SDK_INT and "S" codename.
+ // We don't accept SDK_INT > R for now, since R and S may have non-consecutive values.
+ if (Build.VERSION.SDK_INT == Build.VERSION_CODES.R
+ && "S".equals(Build.VERSION.CODENAME)) {
+ return true;
+ }
+
+ return false;
+ }
+}