battery: fix battery_history avc denials

At first we met AVC denied log as:
I auditd  : type=1400 audit(0.0:8): avc: denied { read } for comm="pixelstats-vend" name="battery_history" dev="tmpfs" ino=14440 scontext=u:r:pixelstats_vendor:s0 tcontext=u:object_r:device:s0 tclass=chr_file permissive=0

It will conflict sepolicy rule and build break if only add above case in pixelstats_vendor.te
Hence we also add conditions in device.te and file_contexts

Bug: 160202146
Test: pixelstats read battery_history sucess
Signed-off-by: Jenny Ho <hsiufangho@google.com>

Merged-In: I59e195f60de1c54d956dbfbbdd3c0f82ad870d01
Change-Id: I59e195f60de1c54d956dbfbbdd3c0f82ad870d01
(cherry picked from commit 8f179fd6457dd7be5403e3f13dda019967efcb88)
diff --git a/vendor/google/device.te b/vendor/google/device.te
index 39eef55..bb3f611 100644
--- a/vendor/google/device.te
+++ b/vendor/google/device.te
@@ -6,3 +6,4 @@
 type pwrstats_device, dev_type;
 type dp_block_device, dev_type;
 type qg_device, dev_type;
+type battery_history_device, dev_type;
diff --git a/vendor/google/file_contexts b/vendor/google/file_contexts
index 1e80b98..58a7e25 100644
--- a/vendor/google/file_contexts
+++ b/vendor/google/file_contexts
@@ -14,6 +14,7 @@
 /system/bin/hw/hardware\.google\.pixelstats@1\.0-service                              u:object_r:pixelstats_system_exec:s0
 /vendor/bin/easelmanagerd                                                             u:object_r:easel_exec:s0
 /vendor/bin/pixelstats-vendor                                                         u:object_r:pixelstats_vendor_exec:s0
+/dev/battery_history                                                                  u:object_r:battery_history_device:s0
 
 # vendor binaries
 /vendor/bin/hw/android\.hardware\.atrace@1\.0-service.pixel                           u:object_r:hal_atrace_default_exec:s0
diff --git a/vendor/google/pixelstats_vendor.te b/vendor/google/pixelstats_vendor.te
index b490abb..887e68f 100644
--- a/vendor/google/pixelstats_vendor.te
+++ b/vendor/google/pixelstats_vendor.te
@@ -17,6 +17,7 @@
 allow pixelstats_vendor sysfs_scsi_devices_0000:file rw_file_perms;
 r_dir_file(pixelstats_vendor, sysfs_batteryinfo)
 allow pixelstats_vendor sysfs_batteryinfo:file rw_file_perms;
+allow pixelstats_vendor battery_history_device:chr_file r_file_perms;
 
 # UeventListener
 allow pixelstats_vendor self:netlink_kobject_uevent_socket create_socket_perms_no_ioctl;