Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cbb99674 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Program name adaptation for vndservice" am: e8ba9a1e am: 2d36063b...

Merge "Program name adaptation for vndservice" am: e8ba9a1e am: 2d36063b am: dfa2e5d3 am: 07ac6d10 am: 2dc73086

Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/1867786

Change-Id: I99ff70c75ef4f68cb0fc89fef93206a5a847da0e
parents f275116c 2dc73086
Loading
Loading
Loading
Loading
+35 −30
Original line number Diff line number Diff line
@@ -77,6 +77,9 @@ int main(int argc, char* const argv[])
    bool wantsUsage = false;
    int result = 0;

    /* Strip path off the program name. */
    char* prog_name = basename(argv[0]);

    while (1) {
        int ic = getopt(argc, argv, "h?");
        if (ic < 0)
@@ -88,7 +91,7 @@ int main(int argc, char* const argv[])
            wantsUsage = true;
            break;
        default:
            aerr << "service: Unknown option -" << ic << endl;
            aerr << prog_name << ": Unknown option -" << ic << endl;
            wantsUsage = true;
            result = 10;
            break;
@@ -103,7 +106,7 @@ int main(int argc, char* const argv[])
    sp<IServiceManager> sm = defaultServiceManager();
    fflush(stdout);
    if (sm == nullptr) {
        aerr << "service: Unable to get default service manager!" << endl;
        aerr << prog_name << ": Unable to get default service manager!" << endl;
        return 20;
    }

@@ -117,7 +120,7 @@ int main(int argc, char* const argv[])
                aout << "Service " << argv[optind] <<
                    (service == nullptr ? ": not found" : ": found") << endl;
            } else {
                aerr << "service: No service specified for check" << endl;
                aerr << prog_name << ": No service specified for check" << endl;
                wantsUsage = true;
                result = 10;
            }
@@ -152,7 +155,7 @@ int main(int argc, char* const argv[])
                        if (strcmp(argv[optind], "i32") == 0) {
                            optind++;
                            if (optind >= argc) {
                                aerr << "service: no integer supplied for 'i32'" << endl;
                                aerr << prog_name << ": no integer supplied for 'i32'" << endl;
                                wantsUsage = true;
                                result = 10;
                                break;
@@ -161,7 +164,7 @@ int main(int argc, char* const argv[])
                        } else if (strcmp(argv[optind], "i64") == 0) {
                            optind++;
                            if (optind >= argc) {
                                aerr << "service: no integer supplied for 'i64'" << endl;
                                aerr << prog_name << ": no integer supplied for 'i64'" << endl;
                                wantsUsage = true;
                                result = 10;
                                break;
@@ -170,7 +173,7 @@ int main(int argc, char* const argv[])
                        } else if (strcmp(argv[optind], "s16") == 0) {
                            optind++;
                            if (optind >= argc) {
                                aerr << "service: no string supplied for 's16'" << endl;
                                aerr << prog_name << ": no string supplied for 's16'" << endl;
                                wantsUsage = true;
                                result = 10;
                                break;
@@ -179,7 +182,7 @@ int main(int argc, char* const argv[])
                        } else if (strcmp(argv[optind], "f") == 0) {
                            optind++;
                            if (optind >= argc) {
                                aerr << "service: no number supplied for 'f'" << endl;
                                aerr << prog_name << ": no number supplied for 'f'" << endl;
                                wantsUsage = true;
                                result = 10;
                                break;
@@ -188,7 +191,7 @@ int main(int argc, char* const argv[])
                        } else if (strcmp(argv[optind], "d") == 0) {
                            optind++;
                            if (optind >= argc) {
                                aerr << "service: no number supplied for 'd'" << endl;
                                aerr << prog_name << ": no number supplied for 'd'" << endl;
                                wantsUsage = true;
                                result = 10;
                                break;
@@ -200,7 +203,7 @@ int main(int argc, char* const argv[])
                        } else if (strcmp(argv[optind], "fd") == 0) {
                            optind++;
                            if (optind >= argc) {
                                aerr << "service: no path supplied for 'fd'" << endl;
                                aerr << prog_name << ": no path supplied for 'fd'" << endl;
                                wantsUsage = true;
                                result = 10;
                                break;
@@ -208,7 +211,7 @@ int main(int argc, char* const argv[])
                            const char *path = argv[optind++];
                            int fd = open(path, O_RDONLY);
                            if (fd < 0) {
                                aerr << "service: could not open '" << path << "'" << endl;
                                aerr << prog_name << ": could not open '" << path << "'" << endl;
                                wantsUsage = true;
                                result = 10;
                                break;
@@ -217,7 +220,7 @@ int main(int argc, char* const argv[])
                        } else if (strcmp(argv[optind], "afd") == 0) {
                            optind++;
                            if (optind >= argc) {
                                aerr << "service: no path supplied for 'afd'" << endl;
                                aerr << prog_name << ": no path supplied for 'afd'" << endl;
                                wantsUsage = true;
                                result = 10;
                                break;
@@ -226,7 +229,8 @@ int main(int argc, char* const argv[])
                            int fd = open(path, O_RDONLY);
                            struct stat statbuf;
                            if (fd < 0 || fstat(fd, &statbuf) != 0) {
                                aerr << "service: could not open or stat '" << path << "'" << endl;
                                aerr << prog_name << ": could not open or stat"
                                    << " '" << path << "'" << endl;
                                wantsUsage = true;
                                result = 10;
                                break;
@@ -240,7 +244,8 @@ int main(int argc, char* const argv[])
                        } else if (strcmp(argv[optind], "nfd") == 0) {
                            optind++;
                            if (optind >= argc) {
                                aerr << "service: no file descriptor supplied for 'nfd'" << endl;
                                aerr << prog_name << ": no file descriptor supplied for"
                                    << " 'nfd'" << endl;
                                wantsUsage = true;
                                result = 10;
                                break;
@@ -327,7 +332,7 @@ int main(int argc, char* const argv[])
                            // for now just set the extra field to be null.
                            data.writeInt32(-1);
                        } else {
                            aerr << "service: unknown option " << argv[optind] << endl;
                            aerr << prog_name << ": unknown option " << argv[optind] << endl;
                            wantsUsage = true;
                            result = 10;
                            break;
@@ -337,32 +342,32 @@ int main(int argc, char* const argv[])
                    service->transact(code, data, &reply);
                    aout << "Result: " << reply << endl;
                } else {
                    aerr << "service: Service " << argv[serviceArg]
                    aerr << prog_name << ": Service " << argv[serviceArg]
                        << " does not exist" << endl;
                    result = 10;
                }
            } else {
                if (optind < argc) {
                    aerr << "service: No service specified for call" << endl;
                    aerr << prog_name << ": No service specified for call" << endl;
                } else {
                    aerr << "service: No code specified for call" << endl;
                    aerr << prog_name << ": No code specified for call" << endl;
                }
                wantsUsage = true;
                result = 10;
            }
        } else {
            aerr << "service: Unknown command " << argv[optind] << endl;
            aerr << prog_name << ": Unknown command " << argv[optind] << endl;
            wantsUsage = true;
            result = 10;
        }
    }

    if (wantsUsage) {
        aout << "Usage: service [-h|-?]\n"
                "       service list\n"
                "       service check SERVICE\n"
                "       service call SERVICE CODE [i32 N | i64 N | f N | d N | s16 STR | null"
                " | fd f | nfd n | afd f ] ...\n"
        aout << "Usage: " << prog_name << " [-h|-?]\n"
                "       " << prog_name << " list\n"
                "       " << prog_name << " check SERVICE\n"
                "       " << prog_name << " call SERVICE CODE [i32 N | i64 N | f N | d N | s16 STR"
                " | null | fd f | nfd n | afd f ] ...\n"
                "Options:\n"
                "   i32: Write the 32-bit integer N into the send parcel.\n"
                "   i64: Write the 64-bit integer N into the send parcel.\n"
@@ -370,11 +375,11 @@ int main(int argc, char* const argv[])
                "     d: Write the 64-bit double-precision number N into the send parcel.\n"
                "   s16: Write the UTF-16 string STR into the send parcel.\n"
                "  null: Write a null binder into the send parcel.\n"
                "    fd: Write a file descriptor for the file f to the send parcel.\n"
                "   nfd: Write file descriptor n to the send parcel.\n"
                "   afd: Write an ashmem file descriptor for a region containing the data from"
                " file f to the send parcel.\n";
//                "   intent: Write and Intent int the send parcel. ARGS can be\n"
                "    fd: Write a file descriptor for the file f into the send parcel.\n"
                "   nfd: Write the file descriptor n into the send parcel.\n"
                "   afd: Write an ashmem file descriptor for a region containing the data from\n"
                "          file f into the send parcel.\n";
//                "   intent: Write an Intent into the send parcel. ARGS can be\n"
//                "       action=STR data=STR type=STR launchFlags=INT component=STR categories=STR[,STR,...]\n";
        return result;
    }