/* * Copyright (C) 2014 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. */ package com.android.commands.telecom; import android.app.ActivityThread; import android.content.ComponentName; import android.content.Context; import android.net.Uri; import android.os.IUserManager; import android.os.Looper; import android.os.Process; import android.os.RemoteException; import android.os.ServiceManager; import android.os.UserHandle; import android.sysprop.TelephonyProperties; import android.telecom.Log; import android.telecom.PhoneAccount; import android.telecom.PhoneAccountHandle; import android.telephony.TelephonyManager; import android.text.TextUtils; import com.android.internal.os.BaseCommand; import com.android.internal.telecom.ITelecomService; import java.io.PrintStream; import java.util.Arrays; import java.util.stream.Collectors; public final class Telecom extends BaseCommand { /** * Command-line entry point. * * @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(); (new Telecom()).run(args); } private static final String CALLING_PACKAGE = Telecom.class.getPackageName(); private static final String COMMAND_SET_PHONE_ACCOUNT_ENABLED = "set-phone-account-enabled"; private static final String COMMAND_SET_PHONE_ACCOUNT_DISABLED = "set-phone-account-disabled"; private static final String COMMAND_REGISTER_PHONE_ACCOUNT = "register-phone-account"; private static final String COMMAND_SET_USER_SELECTED_OUTGOING_PHONE_ACCOUNT = "set-user-selected-outgoing-phone-account"; private static final String COMMAND_REGISTER_SIM_PHONE_ACCOUNT = "register-sim-phone-account"; private static final String COMMAND_SET_TEST_CALL_REDIRECTION_APP = "set-test-call-redirection-app"; private static final String COMMAND_SET_TEST_CALL_SCREENING_APP = "set-test-call-screening-app"; private static final String COMMAND_ADD_OR_REMOVE_CALL_COMPANION_APP = "add-or-remove-call-companion-app"; private static final String COMMAND_SET_PHONE_ACCOUNT_SUGGESTION_COMPONENT = "set-phone-acct-suggestion-component"; private static final String COMMAND_UNREGISTER_PHONE_ACCOUNT = "unregister-phone-account"; private static final String COMMAND_SET_CALL_DIAGNOSTIC_SERVICE = "set-call-diagnostic-service"; private static final String COMMAND_SET_DEFAULT_DIALER = "set-default-dialer"; private static final String COMMAND_GET_DEFAULT_DIALER = "get-default-dialer"; private static final String COMMAND_STOP_BLOCK_SUPPRESSION = "stop-block-suppression"; private static final String COMMAND_CLEANUP_STUCK_CALLS = "cleanup-stuck-calls"; private static final String COMMAND_CLEANUP_ORPHAN_PHONE_ACCOUNTS = "cleanup-orphan-phone-accounts"; private static final String COMMAND_RESET_CAR_MODE = "reset-car-mode"; /** * Change the system dialer package name if a package name was specified, * Example: adb shell telecom set-system-dialer * * Restore it to the default if if argument is "default" or no argument is passed. * Example: adb shell telecom set-system-dialer default */ private static final String COMMAND_SET_SYSTEM_DIALER = "set-system-dialer"; private static final String COMMAND_GET_SYSTEM_DIALER = "get-system-dialer"; private static final String COMMAND_WAIT_ON_HANDLERS = "wait-on-handlers"; private static final String COMMAND_SET_SIM_COUNT = "set-sim-count"; private static final String COMMAND_GET_SIM_CONFIG = "get-sim-config"; private static final String COMMAND_GET_MAX_PHONES = "get-max-phones"; private static final String COMMAND_SET_TEST_EMERGENCY_PHONE_ACCOUNT_PACKAGE_FILTER = "set-test-emergency-phone-account-package-filter"; /** * Command used to emit a distinct "mark" in the logs. */ private static final String COMMAND_LOG_MARK = "log-mark"; private ComponentName mComponent; private String mAccountId; private ITelecomService mTelecomService; private TelephonyManager mTelephonyManager; private IUserManager mUserManager; @Override public void onShowUsage(PrintStream out) { out.println("usage: telecom [subcommand] [options]\n" + "usage: telecom set-phone-account-enabled \n" + "usage: telecom set-phone-account-disabled \n" + "usage: telecom register-phone-account