zenfone7: Add a tile to trigger camera rotation control

Change-Id: I4cca7b45197ce7ec1743589bcae3e1d04e37c68b
diff --git a/CameraTile/Android.mk b/CameraTile/Android.mk
new file mode 100644
index 0000000..ecf7582
--- /dev/null
+++ b/CameraTile/Android.mk
@@ -0,0 +1,20 @@
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+    $(call all-java-files-under, src)
+
+LOCAL_RESOURCE_DIR := \
+    $(LOCAL_PATH)/res
+
+LOCAL_AAPT_FLAGS := \
+    --auto-add-overlay
+
+LOCAL_CERTIFICATE := platform
+LOCAL_MODULE_TAGS := optional
+LOCAL_SDK_VERSION := current
+
+LOCAL_PACKAGE_NAME := CameraTile
+
+include $(BUILD_PACKAGE)
diff --git a/CameraTile/AndroidManifest.xml b/CameraTile/AndroidManifest.xml
new file mode 100644
index 0000000..4e8dea3
--- /dev/null
+++ b/CameraTile/AndroidManifest.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+    Copyright 2019 The LineageOS 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.
+-->
+<manifest
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    package="org.omnirom.cameratile"
+    android:versionCode="1"
+    android:versionName="1.0">
+
+    <application
+        android:label="@string/app_name">
+
+        <!-- Camera -->
+        <service
+            android:name=".CameraTile"
+            android:icon="@drawable/ic_camera"
+            android:label="@string/camera_label"
+            android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
+            <intent-filter>
+                <action android:name="android.service.quicksettings.action.QS_TILE" />
+            </intent-filter>
+        </service>
+    </application>
+</manifest>
diff --git a/CameraTile/res/drawable/ic_camera.xml b/CameraTile/res/drawable/ic_camera.xml
new file mode 100644
index 0000000..3824a19
--- /dev/null
+++ b/CameraTile/res/drawable/ic_camera.xml
@@ -0,0 +1,7 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:height="24dp"
+    android:width="24dp"
+    android:viewportWidth="24"
+    android:viewportHeight="24">
+    <path android:fillColor="#000" android:pathData="M9,12C9,11.19 9.3,10.5 9.89,9.89C10.5,9.3 11.19,9 12,9C12.81,9 13.5,9.3 14.11,9.89C14.7,10.5 15,11.19 15,12C15,12.81 14.7,13.5 14.11,14.11C13.5,14.7 12.81,15 12,15C11.19,15 10.5,14.7 9.89,14.11C9.3,13.5 9,12.81 9,12M5.53,8.44L7.31,10.22L5.53,12L7.31,13.78L5.53,15.56L2,12L5.53,8.44M8.44,18.47L10.22,16.69L12,18.47L13.78,16.69L15.56,18.47L12,22L8.44,18.47M18.47,15.56L16.69,13.78L18.47,12L16.69,10.22L18.47,8.44L22,12L18.47,15.56M15.56,5.53L13.78,7.31L12,5.53L10.22,7.31L8.44,5.53L12,2L15.56,5.53Z" />
+</vector>
diff --git a/CameraTile/res/values/strings.xml b/CameraTile/res/values/strings.xml
new file mode 100644
index 0000000..e230cad
--- /dev/null
+++ b/CameraTile/res/values/strings.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+    Copyright (C) 2019 The LineageOS 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.
+-->
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <string name="app_name">Camera tile</string>
+
+    <!-- Labels -->
+    <string name="camera_label">Rotate camera</string>
+</resources>
diff --git a/CameraTile/src/org/omnirom/cameratile/CameraTile.java b/CameraTile/src/org/omnirom/cameratile/CameraTile.java
new file mode 100644
index 0000000..c5176b2
--- /dev/null
+++ b/CameraTile/src/org/omnirom/cameratile/CameraTile.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2019 The LineageOS 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 org.omnirom.cameratile;
+
+import android.content.Intent;
+import android.graphics.drawable.Icon;
+import android.service.quicksettings.Tile;
+import android.service.quicksettings.TileService;
+
+public class CameraTile extends TileService {
+
+    @Override
+    public void onStartListening() {
+        super.onStartListening();
+
+        getQsTile().setIcon(Icon.createWithResource(this, R.drawable.ic_camera));
+        getQsTile().setState(Tile.STATE_ACTIVE);
+        getQsTile().updateTile();
+    }
+
+    @Override
+    public void onClick() {
+        super.onClick();
+
+        Intent intent = new Intent("com.asus.motorservice.action.WIDGET_BTN_CLICKED");
+        intent.setPackage("com.asus.motorservice");
+        sendBroadcast(intent);
+    }
+}
diff --git a/device.mk b/device.mk
index d3535a1..42d6ebb 100755
--- a/device.mk
+++ b/device.mk
@@ -36,6 +36,10 @@
     $(LOCAL_PATH)/audio/audio_policy_configuration_ZS670KS.xml:$(TARGET_COPY_OUT_PRODUCT)/vendor_overlay/$(PRODUCT_TARGET_VNDK_VERSION)/etc/audio_policy_configuration.xml \
     $(LOCAL_PATH)/audio/audio_policy_volumes_ZS670KS.xml:$(TARGET_COPY_OUT_PRODUCT)/vendor_overlay/$(PRODUCT_TARGET_VNDK_VERSION)/etc/audio_policy_volumes_ZS670KS.xml
 
+# Camera
+PRODUCT_PACKAGES += \
+    CameraTile
+
 # Frameworks
 PRODUCT_PACKAGES += \
     FrameworksResOverlay