/* * Copyright (C) 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. */ #define _GNU_SOURCE #include <unistd.h> #include <stdio.h> #include <dirent.h> #include <string.h> #include <sys/stat.h> #include <sys/ioctl.h> #include <sys/types.h> #include <sys/wait.h> #include <string.h> #include <dlfcn.h> #include <sys/time.h> #include <sys/mman.h> #include <sys/syscall.h> #include <sys/resource.h> #include <fcntl.h> #include <pthread.h> #include <unistd.h> #include <sched.h> #include <stdlib.h> #include <errno.h> #define MSG_REQUEST 0x2 struct voice_svc_write_msg { __u32 msg_type; __u8 payload[0]; }; int main() { int g_fd = 0; char* dev_path = "/dev/voice_svc"; g_fd = open(dev_path, O_RDWR); if (g_fd < 0) { return -1; } int size = sizeof(struct voice_svc_write_msg) + 4; char* msg = (char*)malloc(size); (msg + 4)[0] = 'A'; (msg + 4)[1] = 'A'; (msg + 4)[2] = 'A'; (msg + 4)[3] = 'A'; ((struct voice_svc_write_msg*)msg)->msg_type = MSG_REQUEST; int i; for (i = 0; i < 20; ++i) { write(g_fd, msg, size); sleep(1); } return 0; }