Merge QP1A.190613.002

Change-Id: I5e208f5c76399fecde4799dcadff7aea4ce34ede
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..c5ed9bf
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,7 @@
+Copyright 2016 Stanley Shyiko
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/ktlint-android-all.jar b/ktlint-android-all.jar
new file mode 100644
index 0000000..fce8357
--- /dev/null
+++ b/ktlint-android-all.jar
Binary files differ
diff --git a/ktlint.py b/ktlint.py
new file mode 100755
index 0000000..de256cd
--- /dev/null
+++ b/ktlint.py
@@ -0,0 +1,72 @@
+#!/usr/bin/python
+
+#
+# Copyright 2017, 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.
+#
+
+"""Script that is used by developers to run style checks on Kotlin files."""
+
+import argparse
+import errno
+import os
+import subprocess
+import sys
+
+MAIN_DIRECTORY = os.path.normpath(os.path.dirname(__file__))
+KTLINT_JAR = os.path.join(MAIN_DIRECTORY, 'ktlint-android-all.jar')
+FORMAT_MESSAGE = '''
+**********************************************************************
+To format run:
+{}/ktlint.py --format --file {}
+**********************************************************************
+'''
+
+
+def main(args=None):
+  parser = argparse.ArgumentParser()
+  parser.add_argument('--file', '-f', nargs='*')
+  parser.add_argument('--format', '-F', dest='format', action='store_true')
+  parser.add_argument('--noformat', dest='format', action='store_false')
+  parser.set_defaults(format=False)
+  args = parser.parse_args()
+  kt_files = [f for f in args.file if f.endswith('.kt') or f.endswith('.kts')]
+  ktlint_args = kt_files[:]
+  if args.format:
+    ktlint_args += ['-F']
+  if not ktlint_args:
+    sys.exit(0)
+
+  ktlint_args += ['--android']
+
+  ktlint_env = os.environ.copy()
+  ktlint_env['JAVA_CMD'] = 'java'
+  try:
+    check = subprocess.Popen(['java', '-jar', KTLINT_JAR] + ktlint_args,
+                             stdout=subprocess.PIPE, env=ktlint_env)
+    stdout, _ = check.communicate()
+    if stdout:
+      print 'prebuilts/ktlint found errors in files you changed:'
+      print stdout
+      print FORMAT_MESSAGE.format(MAIN_DIRECTORY, ' '.join(kt_files))
+      sys.exit(1)
+    else:
+      sys.exit(0)
+  except OSError as e:
+    if e.errno == errno.ENOENT:
+      print 'Error running ktlint!'
+      sys.exit(1)
+
+if __name__ == '__main__':
+  main()