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

Commit 01132da7 authored by Brad Ebinger's avatar Brad Ebinger
Browse files

Redirect requests from "telecom" to "cmd telecom" to remove deps

Test: CtsTelecomTestCases
Bug: 400503648
Flag: build.ENABLE_TELECOM_MAINLINE_MODULE
Change-Id: If00c4feca5a72c3ef5d1be596135dd7490d7b34c
parent 85b59459
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ java_binary {
    name: "telecom",
    wrapper: "telecom.sh",
    srcs: [
        ":telecom-shell-commands-src",
        "**/*.java",
    ],
}
+20 −20
Original line number Diff line number Diff line
@@ -16,20 +16,16 @@

package com.android.commands.telecom;

import android.app.ActivityThread;
import android.content.Context;
import android.os.Looper;
import android.os.ServiceManager;

import com.android.internal.telecom.ITelecomService;
import com.android.server.telecom.TelecomShellCommand;

import java.io.BufferedReader;
import java.io.FileDescriptor;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;

/**
 * @deprecated Use {@code com.android.server.telecom.TelecomShellCommand} instead and execute the
 * shell command using {@code adb shell cmd telecom...}. This is only here for backwards
 * compatibility reasons.
 * shell command using {@code adb shell cmd telecom...}. Commands sent here are proxied to telecom
 * for backwards compatibility reasons.
 */
@Deprecated
public final class Telecom {
@@ -40,15 +36,19 @@ public final class Telecom {
     * @param args The command-line arguments
     */
    public static void main(String[] args) {
        // Initialize the telephony module.
        // TODO: Do it in zygote and RuntimeInit. b/148897549
        ActivityThread.initializeMainlineModules();

        Looper.prepareMainLooper();
        ITelecomService service = ITelecomService.Stub.asInterface(
                ServiceManager.getService(Context.TELECOM_SERVICE));
        Context context = ActivityThread.systemMain().getSystemContext();
        new TelecomShellCommand(service, context).exec(null, FileDescriptor.in,
                FileDescriptor.out, FileDescriptor.err, args);
        PrintWriter outputWriter = new PrintWriter(new FileOutputStream(FileDescriptor.out));
        try {
            // proxy args to "cmd telecom" and send response to output.
            Process proc = Runtime.getRuntime().exec("cmd telecom " + String.join(" ", args));
            BufferedReader stdInput = new BufferedReader(
                    new InputStreamReader(proc.getInputStream()));
            proc.waitFor();
            while (stdInput.ready()) {
                outputWriter.print((char) stdInput.read());
            }
        } catch (Exception e) {
            outputWriter.print("error executing command: " + e);
        }
        outputWriter.flush();
    }
}