diff options
25 files changed, 513 insertions, 579 deletions
diff --git a/Android.bp b/Android.bp index 570040f3ab93..dcb6ac77fe98 100644 --- a/Android.bp +++ b/Android.bp @@ -573,6 +573,7 @@ java_library { // If MimeMap ever becomes its own APEX, then this dependency would need to be removed // in favor of an API stubs dependency in java_library "framework" below. "mimemap", + "modules-utils-os", ], // For backwards compatibility. stem: "framework", @@ -1157,7 +1158,6 @@ aidl_mapping { filegroup { name: "framework-telephony-common-shared-srcs", srcs: [ - "core/java/android/os/BasicShellCommandHandler.java", "core/java/android/os/RegistrantList.java", "core/java/android/os/Registrant.java", "core/java/android/util/LocalLog.java", @@ -1238,7 +1238,6 @@ filegroup { name: "framework-wifi-service-shared-srcs", srcs: [ "core/java/android/net/InterfaceConfiguration.java", - "core/java/android/os/BasicShellCommandHandler.java", "core/java/android/util/BackupUtils.java", "core/java/android/util/Rational.java", "core/java/com/android/internal/util/FastXmlSerializer.java", diff --git a/apex/jobscheduler/service/java/com/android/server/job/JobSchedulerShellCommand.java b/apex/jobscheduler/service/java/com/android/server/job/JobSchedulerShellCommand.java index 1e7206287566..cc202130ab07 100644 --- a/apex/jobscheduler/service/java/com/android/server/job/JobSchedulerShellCommand.java +++ b/apex/jobscheduler/service/java/com/android/server/job/JobSchedulerShellCommand.java @@ -20,10 +20,11 @@ import android.app.ActivityManager; import android.app.AppGlobals; import android.content.pm.IPackageManager; import android.content.pm.PackageManager; -import android.os.BasicShellCommandHandler; import android.os.Binder; import android.os.UserHandle; +import com.android.modules.utils.BasicShellCommandHandler; + import java.io.PrintWriter; public final class JobSchedulerShellCommand extends BasicShellCommandHandler { diff --git a/config/preloaded-classes b/config/preloaded-classes index 481bcb5f8b85..d56fc7720c89 100644 --- a/config/preloaded-classes +++ b/config/preloaded-classes @@ -4539,7 +4539,6 @@ android.os.AsyncTask android.os.BadParcelableException android.os.BaseBundle$NoImagePreloadHolder android.os.BaseBundle -android.os.BasicShellCommandHandler android.os.BatteryManager android.os.BatteryManagerInternal android.os.BatteryProperty$1 @@ -9565,6 +9564,7 @@ com.android.internal.widget.VerifyCredentialResponse$1 com.android.internal.widget.VerifyCredentialResponse com.android.internal.widget.ViewClippingUtil$ClippingParameters com.android.internal.widget.ViewClippingUtil +com.android.modules.utils.BasicShellCommandHandler com.android.okhttp.Address com.android.okhttp.AndroidShimResponseCache com.android.okhttp.Authenticator diff --git a/core/api/current.txt b/core/api/current.txt index 2769c0a981e0..0bbe93928839 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -46095,6 +46095,7 @@ package android.telephony { } public class SignalStrength implements android.os.Parcelable { + ctor public SignalStrength(@NonNull android.telephony.SignalStrength); method public int describeContents(); method @Deprecated public int getCdmaDbm(); method @Deprecated public int getCdmaEcio(); @@ -46603,6 +46604,9 @@ package android.telephony { field public static final int DATA_ENABLED_REASON_USER = 0; // 0x0 field public static final int DATA_SUSPENDED = 3; // 0x3 field public static final int DATA_UNKNOWN = -1; // 0xffffffff + field public static final int ERI_FLASH = 2; // 0x2 + field public static final int ERI_OFF = 1; // 0x1 + field public static final int ERI_ON = 0; // 0x0 field public static final String EXTRA_ACTIVE_SIM_SUPPORTED_COUNT = "android.telephony.extra.ACTIVE_SIM_SUPPORTED_COUNT"; field public static final String EXTRA_CALL_VOICEMAIL_INTENT = "android.telephony.extra.CALL_VOICEMAIL_INTENT"; field public static final String EXTRA_CARRIER_ID = "android.telephony.extra.CARRIER_ID"; diff --git a/core/api/system-current.txt b/core/api/system-current.txt index 18d10641d0cd..e784756a76e8 100644 --- a/core/api/system-current.txt +++ b/core/api/system-current.txt @@ -10108,11 +10108,14 @@ package android.telephony { method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public int getCarrierPrivilegeStatus(int); method @NonNull @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public java.util.List<java.lang.String> getCarrierPrivilegedPackagesForAllActiveSubscriptions(); method @Nullable @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public android.telephony.CarrierRestrictionRules getCarrierRestrictionRules(); + method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public int getCdmaEnhancedRoamingIndicatorDisplayNumber(); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public String getCdmaMdn(); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public String getCdmaMdn(int); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public String getCdmaMin(); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public String getCdmaMin(int); method public String getCdmaPrlVersion(); + method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public int getCdmaRoamingMode(); + method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public int getCdmaSubscriptionMode(); method public int getCurrentPhoneType(); method public int getCurrentPhoneType(int); method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public int getDataActivationState(); @@ -10184,6 +10187,8 @@ package android.telephony { method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setCallWaitingEnabled(boolean, @Nullable java.util.concurrent.Executor, @Nullable java.util.function.Consumer<java.lang.Integer>); method @Deprecated @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setCarrierDataEnabled(boolean); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public int setCarrierRestrictionRules(@NonNull android.telephony.CarrierRestrictionRules); + method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setCdmaRoamingMode(int); + method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setCdmaSubscriptionMode(int); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setDataActivationState(int); method @Deprecated @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setDataEnabled(int, boolean); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setDataRoamingEnabled(boolean); @@ -10229,6 +10234,9 @@ package android.telephony { field public static final int CARRIER_PRIVILEGE_STATUS_HAS_ACCESS = 1; // 0x1 field public static final int CARRIER_PRIVILEGE_STATUS_NO_ACCESS = 0; // 0x0 field public static final int CARRIER_PRIVILEGE_STATUS_RULES_NOT_LOADED = -1; // 0xffffffff + field public static final int CDMA_SUBSCRIPTION_NV = 1; // 0x1 + field public static final int CDMA_SUBSCRIPTION_RUIM_SIM = 0; // 0x0 + field public static final int CDMA_SUBSCRIPTION_UNKNOWN = -1; // 0xffffffff field public static final int ENABLE_NR_DUAL_CONNECTIVITY_INVALID_STATE = 4; // 0x4 field public static final int ENABLE_NR_DUAL_CONNECTIVITY_NOT_SUPPORTED = 1; // 0x1 field public static final int ENABLE_NR_DUAL_CONNECTIVITY_RADIO_ERROR = 3; // 0x3 @@ -10372,7 +10380,8 @@ package android.telephony.data { method public int getMtuV6(); method @NonNull public java.util.List<java.net.InetAddress> getPcscfAddresses(); method public int getProtocolType(); - method public int getSuggestedRetryTime(); + method public long getRetryIntervalMillis(); + method @Deprecated public int getSuggestedRetryTime(); method public void writeToParcel(android.os.Parcel, int); field @NonNull public static final android.os.Parcelable.Creator<android.telephony.data.DataCallResponse> CREATOR; field public static final int HANDOVER_FAILURE_MODE_DO_FALLBACK = 1; // 0x1 @@ -10384,6 +10393,7 @@ package android.telephony.data { field public static final int LINK_STATUS_DORMANT = 1; // 0x1 field public static final int LINK_STATUS_INACTIVE = 0; // 0x0 field public static final int LINK_STATUS_UNKNOWN = -1; // 0xffffffff + field public static final int RETRY_INTERVAL_UNDEFINED = -1; // 0xffffffff } public static final class DataCallResponse.Builder { @@ -10402,7 +10412,8 @@ package android.telephony.data { method @NonNull public android.telephony.data.DataCallResponse.Builder setMtuV6(int); method @NonNull public android.telephony.data.DataCallResponse.Builder setPcscfAddresses(@NonNull java.util.List<java.net.InetAddress>); method @NonNull public android.telephony.data.DataCallResponse.Builder setProtocolType(int); - method @NonNull public android.telephony.data.DataCallResponse.Builder setSuggestedRetryTime(int); + method @NonNull public android.telephony.data.DataCallResponse.Builder setRetryIntervalMillis(long); + method @Deprecated @NonNull public android.telephony.data.DataCallResponse.Builder setSuggestedRetryTime(int); } public final class DataProfile implements android.os.Parcelable { diff --git a/core/api/test-current.txt b/core/api/test-current.txt index 6aaf973c0626..fc27d06d0b5a 100644 --- a/core/api/test-current.txt +++ b/core/api/test-current.txt @@ -1673,6 +1673,7 @@ package android.telephony { method @NonNull public java.util.List<android.telephony.data.ApnSetting> getDevicePolicyOverrideApns(@NonNull android.content.Context); method @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public String getLine1AlphaTag(); method public android.util.Pair<java.lang.Integer,java.lang.Integer> getRadioHalVersion(); + method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public long getSupportedRadioAccessFamily(); method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public boolean isMobileDataPolicyEnabled(int); method public boolean modifyDevicePolicyOverrideApn(@NonNull android.content.Context, int, @NonNull android.telephony.data.ApnSetting); method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void refreshUiccProfile(); diff --git a/core/java/android/net/LinkProperties.java b/core/java/android/net/LinkProperties.java index aa4b15454721..06046f7ded2e 100644 --- a/core/java/android/net/LinkProperties.java +++ b/core/java/android/net/LinkProperties.java @@ -80,8 +80,10 @@ public final class LinkProperties implements Parcelable { private final transient boolean mParcelSensitiveFields; private static final int MIN_MTU = 68; - /* package-visibility - Used in other files (such as Ikev2VpnProfile) as minimum iface MTU. */ - static final int MIN_MTU_V6 = 1280; + + /** @hide */ + public static final int MIN_MTU_V6 = 1280; + private static final int MAX_MTU = 10000; private static final int INET6_ADDR_LENGTH = 16; diff --git a/core/java/android/net/vcn/VcnGatewayConnectionConfig.java b/core/java/android/net/vcn/VcnGatewayConnectionConfig.java new file mode 100644 index 000000000000..8160edc87440 --- /dev/null +++ b/core/java/android/net/vcn/VcnGatewayConnectionConfig.java @@ -0,0 +1,86 @@ +/* + * Copyright (C) 2020 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 android.net.vcn; + +import android.annotation.NonNull; + +/** + * This class represents a configuration for a connection to a Virtual Carrier Network gateway. + * + * <p>Each VcnGatewayConnectionConfig represents a single logical connection to a carrier gateway, + * and may provide one or more telephony services (as represented by network capabilities). Each + * gateway is expected to provide mobility for a given session as the device roams across {@link + * Network}s. + * + * <p>A VCN connection based on this configuration will be brought up dynamically based on device + * settings, and filed NetworkRequests. Underlying networks will be selected based on the services + * required by this configuration (as represented by network capabilities), and must be part of the + * subscription group under which this configuration is registered (see {@link + * VcnManager#setVcnConfig}). + * + * <p>Services that can be provided by a VCN network, or required for underlying networks are + * limited to services provided by cellular networks: + * + * <ul> + * <li>{@link android.net.NetworkCapabilities.NET_CAPABILITY_MMS} + * <li>{@link android.net.NetworkCapabilities.NET_CAPABILITY_SUPL} + * <li>{@link android.net.NetworkCapabilities.NET_CAPABILITY_DUN} + * <li>{@link android.net.NetworkCapabilities.NET_CAPABILITY_FOTA} + * <li>{@link android.net.NetworkCapabilities.NET_CAPABILITY_IMS} + * <li>{@link android.net.NetworkCapabilities.NET_CAPABILITY_CBS} + * <li>{@link android.net.NetworkCapabilities.NET_CAPABILITY_IA} + * <li>{@link android.net.NetworkCapabilities.NET_CAPABILITY_RCS} + * <li>{@link android.net.NetworkCapabilities.NET_CAPABILITY_XCAP} + * <li>{@link android.net.NetworkCapabilities.NET_CAPABILITY_EIMS} + * <li>{@link android.net.NetworkCapabilities.NET_CAPABILITY_INTERNET} + * <li>{@link android.net.NetworkCapabilities.NET_CAPABILITY_MCX} + * </ul> + * + * @hide + */ +public final class VcnGatewayConnectionConfig { + private VcnGatewayConnectionConfig() { + validate(); + } + + // TODO: Implement getters, validators, etc + + /** + * Validates this configuration + * + * @hide + */ + private void validate() { + // TODO: implement validation logic + } + + // Parcelable methods + + /** This class is used to incrementally build {@link VcnGatewayConnectionConfig} objects */ + public static class Builder { + // TODO: Implement this builder + + /** + * Builds and validates the VcnGatewayConnectionConfig + * + * @return an immutable VcnGatewayConnectionConfig instance + */ + @NonNull + public VcnGatewayConnectionConfig build() { + return new VcnGatewayConnectionConfig(); + } + } +} diff --git a/core/java/android/os/BasicShellCommandHandler.java b/core/java/android/os/BasicShellCommandHandler.java deleted file mode 100644 index 1ea2229cff1f..000000000000 --- a/core/java/android/os/BasicShellCommandHandler.java +++ /dev/null @@ -1,330 +0,0 @@ -/* - * Copyright (C) 2019 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 android.os; - -import android.util.Log; - -import java.io.BufferedInputStream; -import java.io.FileDescriptor; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.PrintWriter; - -/** - * Helper for implementing {@link Binder#onShellCommand Binder.onShellCommand}. This is meant to - * be copied into mainline modules, so this class must not use any hidden APIs. - * - * @hide - */ -public abstract class BasicShellCommandHandler { - static final String TAG = "ShellCommand"; - static final boolean DEBUG = false; - - private Binder mTarget; - private FileDescriptor mIn; - private FileDescriptor mOut; - private FileDescriptor mErr; - private String[] mArgs; - - private String mCmd; - private int mArgPos; - private String mCurArgData; - - private FileInputStream mFileIn; - private FileOutputStream mFileOut; - private FileOutputStream mFileErr; - - private PrintWriter mOutPrintWriter; - private PrintWriter mErrPrintWriter; - private InputStream mInputStream; - - public void init(Binder target, FileDescriptor in, FileDescriptor out, FileDescriptor err, - String[] args, int firstArgPos) { - mTarget = target; - mIn = in; - mOut = out; - mErr = err; - mArgs = args; - mCmd = null; - mArgPos = firstArgPos; - mCurArgData = null; - mFileIn = null; - mFileOut = null; - mFileErr = null; - mOutPrintWriter = null; - mErrPrintWriter = null; - mInputStream = null; - } - - public int exec(Binder target, FileDescriptor in, FileDescriptor out, FileDescriptor err, - String[] args) { - String cmd; - int start; - if (args != null && args.length > 0) { - cmd = args[0]; - start = 1; - } else { - cmd = null; - start = 0; - } - init(target, in, out, err, args, start); - mCmd = cmd; - - if (DEBUG) { - RuntimeException here = new RuntimeException("here"); - here.fillInStackTrace(); - Log.d(TAG, "Starting command " + mCmd + " on " + mTarget, here); - Log.d(TAG, "Calling uid=" + Binder.getCallingUid() - + " pid=" + Binder.getCallingPid()); - } - int res = -1; - try { - res = onCommand(mCmd); - if (DEBUG) Log.d(TAG, "Executed command " + mCmd + " on " + mTarget); - } catch (Throwable e) { - // Unlike usual calls, in this case if an exception gets thrown - // back to us we want to print it back in to the dump data, since - // that is where the caller expects all interesting information to - // go. - PrintWriter eout = getErrPrintWriter(); - eout.println(); - eout.println("Exception occurred while executing '" + mCmd + "':"); - e.printStackTrace(eout); - } finally { - if (DEBUG) Log.d(TAG, "Flushing output streams on " + mTarget); - if (mOutPrintWriter != null) { - mOutPrintWriter.flush(); - } - if (mErrPrintWriter != null) { - mErrPrintWriter.flush(); - } - if (DEBUG) Log.d(TAG, "Sending command result on " + mTarget); - } - if (DEBUG) Log.d(TAG, "Finished command " + mCmd + " on " + mTarget); - return res; - } - - /** - * Return the raw FileDescriptor for the output stream. - */ - public FileDescriptor getOutFileDescriptor() { - return mOut; - } - - /** - * Return direct raw access (not buffered) to the command's output data stream. - */ - public OutputStream getRawOutputStream() { - if (mFileOut == null) { - mFileOut = new FileOutputStream(mOut); - } - return mFileOut; - } - - /** - * Return a PrintWriter for formatting output to {@link #getRawOutputStream()}. - */ - public PrintWriter getOutPrintWriter() { - if (mOutPrintWriter == null) { - mOutPrintWriter = new PrintWriter(getRawOutputStream()); - } - return mOutPrintWriter; - } - - /** - * Return the raw FileDescriptor for the error stream. - */ - public FileDescriptor getErrFileDescriptor() { - return mErr; - } - - /** - * Return direct raw access (not buffered) to the command's error output data stream. - */ - public OutputStream getRawErrorStream() { - if (mFileErr == null) { - mFileErr = new FileOutputStream(mErr); - } - return mFileErr; - } - - /** - * Return a PrintWriter for formatting output to {@link #getRawErrorStream()}. - */ - public PrintWriter getErrPrintWriter() { - if (mErr == null) { - return getOutPrintWriter(); - } - if (mErrPrintWriter == null) { - mErrPrintWriter = new PrintWriter(getRawErrorStream()); - } - return mErrPrintWriter; - } - - /** - * Return the raw FileDescriptor for the input stream. - */ - public FileDescriptor getInFileDescriptor() { - return mIn; - } - - /** - * Return direct raw access (not buffered) to the command's input data stream. - */ - public InputStream getRawInputStream() { - if (mFileIn == null) { - mFileIn = new FileInputStream(mIn); - } - return mFileIn; - } - - /** - * Return buffered access to the command's {@link #getRawInputStream()}. - */ - public InputStream getBufferedInputStream() { - if (mInputStream == null) { - mInputStream = new BufferedInputStream(getRawInputStream()); - } - return mInputStream; - } - - /** - * Return the next option on the command line -- that is an argument that - * starts with '-'. If the next argument is not an option, null is returned. - */ - public String getNextOption() { - if (mCurArgData != null) { - String prev = mArgs[mArgPos - 1]; - throw new IllegalArgumentException("No argument expected after \"" + prev + "\""); - } - if (mArgPos >= mArgs.length) { - return null; - } - String arg = mArgs[mArgPos]; - if (!arg.startsWith("-")) { - return null; - } - mArgPos++; - if (arg.equals("--")) { - return null; - } - if (arg.length() > 1 && arg.charAt(1) != '-') { - if (arg.length() > 2) { - mCurArgData = arg.substring(2); - return arg.substring(0, 2); - } else { - mCurArgData = null; - return arg; - } - } - mCurArgData = null; - return arg; - } - - /** - * Return the next argument on the command line, whatever it is; if there are - * no arguments left, return null. - */ - public String getNextArg() { - if (mCurArgData != null) { - String arg = mCurArgData; - mCurArgData = null; - return arg; - } else if (mArgPos < mArgs.length) { - return mArgs[mArgPos++]; - } else { - return null; - } - } - - public String peekNextArg() { - if (mCurArgData != null) { - return mCurArgData; - } else if (mArgPos < mArgs.length) { - return mArgs[mArgPos]; - } else { - return null; - } - } - - /** - * Returns number of arguments that haven't been processed yet. - */ - public int getRemainingArgsCount() { - if (mArgPos >= mArgs.length) { - return 0; - } - return mArgs.length - mArgPos; - } - - /** - * Return the next argument on the command line, whatever it is; if there are - * no arguments left, throws an IllegalArgumentException to report this to the user. - */ - public String getNextArgRequired() { - String arg = getNextArg(); - if (arg == null) { - String prev = mArgs[mArgPos - 1]; - throw new IllegalArgumentException("Argument expected after \"" + prev + "\""); - } - return arg; - } - - public int handleDefaultCommands(String cmd) { - if (cmd == null || "help".equals(cmd) || "-h".equals(cmd)) { - onHelp(); - } else { - getOutPrintWriter().println("Unknown command: " + cmd); - } - return -1; - } - - public Binder getTarget() { - return mTarget; - } - - public String[] getAllArgs() { - return mArgs; - } - - /** - * Implement parsing and execution of a command. If it isn't a command you understand, - * call {@link #handleDefaultCommands(String)} and return its result as a last resort. - * Use {@link #getNextOption()}, {@link #getNextArg()}, and {@link #getNextArgRequired()} - * to process additional command line arguments. Command output can be written to - * {@link #getOutPrintWriter()} and errors to {@link #getErrPrintWriter()}. - * - * <p class="caution">Note that no permission checking has been done before entering this - * function, so you need to be sure to do your own security verification for any commands you - * are executing. The easiest way to do this is to have the ShellCommand contain - * only a reference to your service's aidl interface, and do all of your command - * implementations on top of that -- that way you can rely entirely on your executing security - * code behind that interface.</p> - * - * @param cmd The first command line argument representing the name of the command to execute. - * @return Return the command result; generally 0 or positive indicates success and - * negative values indicate error. - */ - public abstract int onCommand(String cmd); - - /** - * Implement this to print help text about your command to {@link #getOutPrintWriter()}. - */ - public abstract void onHelp(); -} diff --git a/core/java/android/os/ShellCommand.java b/core/java/android/os/ShellCommand.java index 3358ce13ed52..a2173a6d2360 100644 --- a/core/java/android/os/ShellCommand.java +++ b/core/java/android/os/ShellCommand.java @@ -19,15 +19,9 @@ package android.os; import android.compat.annotation.UnsupportedAppUsage; import android.util.Slog; -import com.android.internal.util.FastPrintWriter; +import com.android.modules.utils.BasicShellCommandHandler; -import java.io.BufferedInputStream; import java.io.FileDescriptor; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.PrintWriter; /** * Helper for implementing {@link Binder#onShellCommand Binder.onShellCommand}. diff --git a/core/java/com/android/internal/os/BaseCommand.java b/core/java/com/android/internal/os/BaseCommand.java index c110b263e781..c85b5d7aa7a6 100644 --- a/core/java/com/android/internal/os/BaseCommand.java +++ b/core/java/com/android/internal/os/BaseCommand.java @@ -18,9 +18,10 @@ package com.android.internal.os; import android.compat.annotation.UnsupportedAppUsage; -import android.os.BasicShellCommandHandler; import android.os.Build; +import com.android.modules.utils.BasicShellCommandHandler; + import java.io.PrintStream; public abstract class BaseCommand { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/MobileSignalController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/MobileSignalController.java index cf83603997c0..2563f19245e0 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/MobileSignalController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/MobileSignalController.java @@ -23,7 +23,6 @@ import android.os.Handler; import android.os.Looper; import android.provider.Settings.Global; import android.telephony.Annotation; -import android.telephony.CdmaEriInformation; import android.telephony.CellSignalStrength; import android.telephony.CellSignalStrengthCdma; import android.telephony.PhoneStateListener; @@ -423,11 +422,9 @@ public class MobileSignalController extends SignalController< if (isCarrierNetworkChangeActive()) { return false; } - if (isCdma() && mServiceState != null) { - final int iconMode = mPhone.getCdmaEriInformation().getEriIconMode(); - return mPhone.getCdmaEriInformation().getEriIconIndex() != CdmaEriInformation.ERI_OFF - && (iconMode == CdmaEriInformation.ERI_ICON_MODE_NORMAL - || iconMode == CdmaEriInformation.ERI_ICON_MODE_FLASH); + if (isCdma()) { + return mPhone.getCdmaEnhancedRoamingIndicatorDisplayNumber() + != TelephonyManager.ERI_OFF; } else { return mServiceState != null && mServiceState.getRoaming(); } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerBaseTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerBaseTest.java index aef454fc1374..9a7400edca5c 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerBaseTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerBaseTest.java @@ -45,7 +45,6 @@ import android.net.wifi.WifiManager; import android.os.Handler; import android.provider.Settings; import android.provider.Settings.Global; -import android.telephony.CdmaEriInformation; import android.telephony.CellSignalStrength; import android.telephony.NetworkRegistrationInfo; import android.telephony.PhoneStateListener; @@ -119,8 +118,6 @@ public class NetworkControllerBaseTest extends SysuiTestCase { private NetworkCapabilities mNetCapabilities; private ConnectivityManager.NetworkCallback mNetworkCallback; - private CdmaEriInformation mEriInformation; - @Rule public TestWatcher failWatcher = new TestWatcher() { @Override @@ -181,11 +178,6 @@ public class NetworkControllerBaseTest extends SysuiTestCase { doReturn(TelephonyManager.NETWORK_TYPE_LTE).when(mTelephonyDisplayInfo).getNetworkType(); doReturn(TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NONE).when(mTelephonyDisplayInfo) .getOverrideNetworkType(); - - mEriInformation = new CdmaEriInformation(CdmaEriInformation.ERI_OFF, - CdmaEriInformation.ERI_ICON_MODE_NORMAL); - when(mMockTm.getCdmaEriInformation()).thenReturn(mEriInformation); - mConfig = new Config(); mConfig.hspaDataDistinguishable = true; mCallbackHandler = mock(CallbackHandler.class); @@ -308,9 +300,8 @@ public class NetworkControllerBaseTest extends SysuiTestCase { } public void setCdmaRoaming(boolean isRoaming) { - mEriInformation.setEriIconIndex(isRoaming ? - CdmaEriInformation.ERI_ON : CdmaEriInformation.ERI_OFF); - when(mMockTm.getCdmaEriInformation()).thenReturn(mEriInformation); + when(mMockTm.getCdmaEnhancedRoamingIndicatorDisplayNumber()).thenReturn( + isRoaming ? TelephonyManager.ERI_ON : TelephonyManager.ERI_OFF); } public void setVoiceRegState(int voiceRegState) { diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java index fba1e79ad79a..655275e2e1da 100644 --- a/services/core/java/com/android/server/ConnectivityService.java +++ b/services/core/java/com/android/server/ConnectivityService.java @@ -139,7 +139,6 @@ import android.net.util.LinkPropertiesUtils.CompareOrUpdateResult; import android.net.util.LinkPropertiesUtils.CompareResult; import android.net.util.MultinetworkPolicyTracker; import android.net.util.NetdService; -import android.os.BasicShellCommandHandler; import android.os.Binder; import android.os.Build; import android.os.Bundle; @@ -192,6 +191,7 @@ import com.android.internal.util.IndentingPrintWriter; import com.android.internal.util.LocationPermissionChecker; import com.android.internal.util.MessageUtils; import com.android.internal.util.XmlUtils; +import com.android.modules.utils.BasicShellCommandHandler; import com.android.server.am.BatteryStatsService; import com.android.server.connectivity.AutodestructReference; import com.android.server.connectivity.DataConnectionStats; @@ -5854,7 +5854,6 @@ public class ConnectivityService extends IConnectivityManager.Stub @GuardedBy("mBlockedAppUids") private final HashSet<Integer> mBlockedAppUids = new HashSet<>(); - // Note: if mDefaultRequest is changed, NetworkMonitor needs to be updated. @NonNull private final NetworkRequest mDefaultRequest; // The NetworkAgentInfo currently satisfying the default request, if any. diff --git a/services/core/java/com/android/server/adb/AdbShellCommand.java b/services/core/java/com/android/server/adb/AdbShellCommand.java index 76918529d071..d7e95df332fa 100644 --- a/services/core/java/com/android/server/adb/AdbShellCommand.java +++ b/services/core/java/com/android/server/adb/AdbShellCommand.java @@ -16,7 +16,7 @@ package com.android.server.adb; -import android.os.BasicShellCommandHandler; +import com.android.modules.utils.BasicShellCommandHandler; import java.io.PrintWriter; import java.util.Objects; diff --git a/services/core/java/com/android/server/location/LocationShellCommand.java b/services/core/java/com/android/server/location/LocationShellCommand.java index 909873f07993..3464704b9734 100644 --- a/services/core/java/com/android/server/location/LocationShellCommand.java +++ b/services/core/java/com/android/server/location/LocationShellCommand.java @@ -16,9 +16,10 @@ package com.android.server.location; -import android.os.BasicShellCommandHandler; import android.os.UserHandle; +import com.android.modules.utils.BasicShellCommandHandler; + import java.io.PrintWriter; import java.util.Objects; diff --git a/services/core/java/com/android/server/vcn/UnderlyingNetworkTracker.java b/services/core/java/com/android/server/vcn/UnderlyingNetworkTracker.java new file mode 100644 index 000000000000..e1feb5aab869 --- /dev/null +++ b/services/core/java/com/android/server/vcn/UnderlyingNetworkTracker.java @@ -0,0 +1,100 @@ +/* + * Copyright (C) 2020 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.server.vcn; + +import android.annotation.NonNull; +import android.annotation.Nullable; +import android.net.LinkProperties; +import android.net.Network; +import android.net.NetworkCapabilities; +import android.os.Handler; +import android.os.ParcelUuid; + +import java.util.Objects; + +/** + * Tracks a set of Networks underpinning a VcnGatewayConnection. + * + * <p>A single UnderlyingNetworkTracker is built to serve a SINGLE VCN Gateway Connection, and MUST + * be torn down with the VcnGatewayConnection in order to ensure underlying networks are allowed to + * be reaped. + * + * @hide + */ +public class UnderlyingNetworkTracker extends Handler { + @NonNull private static final String TAG = UnderlyingNetworkTracker.class.getSimpleName(); + + @NonNull private final VcnContext mVcnContext; + @NonNull private final ParcelUuid mSubscriptionGroup; + @NonNull private final UnderlyingNetworkTrackerCallback mCb; + @NonNull private final Dependencies mDeps; + + public UnderlyingNetworkTracker( + @NonNull VcnContext vcnContext, + @NonNull ParcelUuid subscriptionGroup, + @NonNull UnderlyingNetworkTrackerCallback cb) { + this(vcnContext, subscriptionGroup, cb, new Dependencies()); + } + + private UnderlyingNetworkTracker( + @NonNull VcnContext vcnContext, + @NonNull ParcelUuid subscriptionGroup, + @NonNull UnderlyingNetworkTrackerCallback cb, + @NonNull Dependencies deps) { + super(Objects.requireNonNull(vcnContext, "Missing vcnContext").getLooper()); + mVcnContext = vcnContext; + mSubscriptionGroup = Objects.requireNonNull(subscriptionGroup, "Missing subscriptionGroup"); + mCb = Objects.requireNonNull(cb, "Missing cb"); + mDeps = Objects.requireNonNull(deps, "Missing deps"); + } + + /** Tears down this Tracker, and releases all underlying network requests. */ + public void teardown() {} + + /** An record of a single underlying network, caching relevant fields. */ + public static class UnderlyingNetworkRecord { + @NonNull public final Network network; + @NonNull public final NetworkCapabilities networkCapabilities; + @NonNull public final LinkProperties linkProperties; + public final boolean blocked; + + private UnderlyingNetworkRecord( + @NonNull Network network, + @NonNull NetworkCapabilities networkCapabilities, + @NonNull LinkProperties linkProperties, + boolean blocked) { + this.network = network; + this.networkCapabilities = networkCapabilities; + this.linkProperties = linkProperties; + this.blocked = blocked; + } + } + + /** Callbacks for being notified of the changes in, or to the selected underlying network. */ + public interface UnderlyingNetworkTrackerCallback { + /** + * Fired when a new underlying network is selected, or properties have changed. + * + * <p>This callback does NOT signal a mobility event. + * + * @param underlying The details of the new underlying network + */ + void onSelectedUnderlyingNetworkChanged(@Nullable UnderlyingNetworkRecord underlying); + } + + private static class Dependencies {} +} diff --git a/services/core/java/com/android/server/vcn/Vcn.java b/services/core/java/com/android/server/vcn/Vcn.java index 2af41726caab..d51d16b1b4df 100644 --- a/services/core/java/com/android/server/vcn/Vcn.java +++ b/services/core/java/com/android/server/vcn/Vcn.java @@ -87,7 +87,8 @@ public class Vcn extends Handler { /** Retrieves the network score for a VCN Network */ private int getNetworkScore() { - // TODO: STOPSHIP: Make this use new NetworkSelection, or some magic "max in subGrp" value + // TODO: STOPSHIP (b/173549607): Make this use new NetworkSelection, or some magic "max in + // subGrp" value return 52; } diff --git a/services/core/java/com/android/server/vcn/VcnGatewayConnection.java b/services/core/java/com/android/server/vcn/VcnGatewayConnection.java new file mode 100644 index 000000000000..49c9b3297c77 --- /dev/null +++ b/services/core/java/com/android/server/vcn/VcnGatewayConnection.java @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2020 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.server.vcn; + +import android.annotation.NonNull; +import android.annotation.Nullable; +import android.net.vcn.VcnGatewayConnectionConfig; +import android.os.Handler; +import android.os.ParcelUuid; + +import com.android.server.vcn.UnderlyingNetworkTracker.UnderlyingNetworkRecord; +import com.android.server.vcn.UnderlyingNetworkTracker.UnderlyingNetworkTrackerCallback; + +import java.util.Objects; + +/** + * A single VCN Gateway Connection, providing a single public-facing VCN network. + * + * <p>This class handles mobility events, performs retries, and tracks safe-mode conditions. + * + * @hide + */ +public class VcnGatewayConnection extends Handler implements UnderlyingNetworkTrackerCallback { + private static final String TAG = VcnGatewayConnection.class.getSimpleName(); + + @NonNull private final VcnContext mVcnContext; + @NonNull private final ParcelUuid mSubscriptionGroup; + @NonNull private final UnderlyingNetworkTracker mUnderlyingNetworkTracker; + @NonNull private final VcnGatewayConnectionConfig mConnectionConfig; + @NonNull private final Dependencies mDeps; + + public VcnGatewayConnection( + @NonNull VcnContext vcnContext, + @NonNull ParcelUuid subscriptionGroup, + @NonNull VcnGatewayConnectionConfig connectionConfig) { + this(vcnContext, subscriptionGroup, connectionConfig, new Dependencies()); + } + + private VcnGatewayConnection( + @NonNull VcnContext vcnContext, + @NonNull ParcelUuid subscriptionGroup, + @NonNull VcnGatewayConnectionConfig connectionConfig, + @NonNull Dependencies deps) { + super(Objects.requireNonNull(vcnContext, "Missing vcnContext").getLooper()); + mVcnContext = vcnContext; + mSubscriptionGroup = Objects.requireNonNull(subscriptionGroup, "Missing subscriptionGroup"); + mConnectionConfig = Objects.requireNonNull(connectionConfig, "Missing connectionConfig"); + mDeps = Objects.requireNonNull(deps, "Missing deps"); + + mUnderlyingNetworkTracker = + mDeps.newUnderlyingNetworkTracker(mVcnContext, subscriptionGroup, this); + } + + /** Tears down this GatewayConnection, and any resources used */ + public void teardown() { + mUnderlyingNetworkTracker.teardown(); + } + + private static class Dependencies { + public UnderlyingNetworkTracker newUnderlyingNetworkTracker( + VcnContext vcnContext, + ParcelUuid subscriptionGroup, + UnderlyingNetworkTrackerCallback callback) { + return new UnderlyingNetworkTracker(vcnContext, subscriptionGroup, callback); + } + } + + @Override + public void onSelectedUnderlyingNetworkChanged(@Nullable UnderlyingNetworkRecord underlying) {} +} diff --git a/telephony/java/android/telephony/CdmaEriInformation.java b/telephony/java/android/telephony/CdmaEriInformation.java deleted file mode 100644 index fd0b905e9c3e..000000000000 --- a/telephony/java/android/telephony/CdmaEriInformation.java +++ /dev/null @@ -1,169 +0,0 @@ -/** - * Copyright (C) 2020 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 android.telephony; - -import android.annotation.IntDef; -import android.annotation.NonNull; -import android.annotation.SystemApi; -import android.os.Parcel; -import android.os.Parcelable; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -/** - * CDMA ERI (Enhanced Roaming Indicator) information. - * - * This contains the following ERI information - * - * 1. ERI (Enhanced Roaming Indicator) icon index. The number is assigned by - * 3GPP2 C.R1001-H v1.0 Table 8.1-1. Additionally carriers define their own - * ERI icon index. - * 2. CDMA ERI icon mode. This represents how the icon should be displayed. - * Its one of the following CDMA ERI icon mode - * {@link android.telephony.CdmaEriInformation#ERI_ICON_MODE_NORMAL} - * {@link android.telephony.CdmaEriInformation#ERI_ICON_MODE_FLASH} - * - * @hide - */ -public final class CdmaEriInformation implements Parcelable { - /** @hide */ - @Retention(RetentionPolicy.SOURCE) - @IntDef(prefix = {"ERI_"}, value = { - ERI_ON, - ERI_OFF, - ERI_FLASH - }) - public @interface EriIconIndex {} - - /** - * ERI (Enhanced Roaming Indicator) is ON i.e value 0 defined by - * 3GPP2 C.R1001-H v1.0 Table 8.1-1. - */ - public static final int ERI_ON = 0; - - /** - * ERI (Enhanced Roaming Indicator) is OFF i.e value 1 defined by - * 3GPP2 C.R1001-H v1.0 Table 8.1-1. - */ - public static final int ERI_OFF = 1; - - /** - * ERI (Enhanced Roaming Indicator) is FLASH i.e value 2 defined by - * 3GPP2 C.R1001-H v1.0 Table 8.1-1. - */ - public static final int ERI_FLASH = 2; - - /** @hide */ - @Retention(RetentionPolicy.SOURCE) - @IntDef(prefix = {"ERI_ICON_MODE_"}, value = { - ERI_ICON_MODE_NORMAL, - ERI_ICON_MODE_FLASH - }) - public @interface EriIconMode {} - - /** - * ERI (Enhanced Roaming Indicator) icon mode is normal. This constant represents that - * the ERI icon should be displayed normally. - * - * Note: ERI is defined 3GPP2 C.R1001-H Table 8.1-1 - */ - public static final int ERI_ICON_MODE_NORMAL = 0; - - /** - * ERI (Enhanced Roaming Indicator) icon mode flash. This constant represents that - * the ERI icon should be flashing. - * - * Note: ERI is defined 3GPP2 C.R1001-H Table 8.1-1 - */ - public static final int ERI_ICON_MODE_FLASH = 1; - - private @EriIconIndex int mIconIndex; - private @EriIconMode int mIconMode; - - /** - * Creates CdmaEriInformation from iconIndex and iconMode - * - * @hide - */ - public CdmaEriInformation(@EriIconIndex int iconIndex, @EriIconMode int iconMode) { - mIconIndex = iconIndex; - mIconMode = iconMode; - } - - /** Gets the ERI icon index */ - public @EriIconIndex int getEriIconIndex() { - return mIconIndex; - } - - /** - * Sets the ERI icon index - * - * @hide - */ - public void setEriIconIndex(@EriIconIndex int iconIndex) { - mIconIndex = iconIndex; - } - - /** Gets the ERI icon mode */ - public @EriIconMode int getEriIconMode() { - return mIconMode; - } - - /** - * Sets the ERI icon mode - * - * @hide - */ - public void setEriIconMode(@EriIconMode int iconMode) { - mIconMode = iconMode; - } - /** Implement the Parcelable interface */ - @Override - public void writeToParcel(@NonNull Parcel dest, int flags) { - dest.writeInt(mIconIndex); - dest.writeInt(mIconMode); - } - - /** Implement the Parcelable interface */ - @Override - public int describeContents() { - return 0; - } - - /** - * Construct a CdmaEriInformation object from the given parcel - */ - private CdmaEriInformation(Parcel in) { - mIconIndex = in.readInt(); - mIconMode = in.readInt(); - } - - /** Implement the Parcelable interface */ - public static final @android.annotation.NonNull Parcelable.Creator<CdmaEriInformation> CREATOR = - new Parcelable.Creator<CdmaEriInformation>() { - @Override - public CdmaEriInformation createFromParcel(Parcel in) { - return new CdmaEriInformation(in); - } - - @Override - public CdmaEriInformation[] newArray(int size) { - return new CdmaEriInformation[size]; - } - }; -} diff --git a/telephony/java/android/telephony/SignalStrength.java b/telephony/java/android/telephony/SignalStrength.java index 1376cddbc41f..7bd0bc0b69ce 100644 --- a/telephony/java/android/telephony/SignalStrength.java +++ b/telephony/java/android/telephony/SignalStrength.java @@ -287,11 +287,9 @@ public class SignalStrength implements Parcelable { } /** - * Copy constructors + * This constructor is used to create a copy of an existing SignalStrength object. * * @param s Source SignalStrength - * - * @hide */ public SignalStrength(@NonNull SignalStrength s) { copyFrom(s); diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 6f88cbdbff05..92dc2fffe6e2 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -5603,27 +5603,78 @@ public class TelephonyManager { } } + /** @hide */ + @Retention(RetentionPolicy.SOURCE) + @IntDef(prefix = {"ERI_"}, value = { + ERI_ON, + ERI_OFF, + ERI_FLASH + }) + public @interface EriIconIndex {} + + /** + * ERI (Enhanced Roaming Indicator) is ON i.e value 0 defined by + * 3GPP2 C.R1001-H v1.0 Table 8.1-1. + */ + public static final int ERI_ON = 0; + + /** + * ERI (Enhanced Roaming Indicator) is OFF i.e value 1 defined by + * 3GPP2 C.R1001-H v1.0 Table 8.1-1. + */ + public static final int ERI_OFF = 1; + /** - * Get the CDMA ERI (Enhanced Roaming Indicator) information + * ERI (Enhanced Roaming Indicator) is FLASH i.e value 2 defined by + * 3GPP2 C.R1001-H v1.0 Table 8.1-1. + */ + public static final int ERI_FLASH = 2; + + /** @hide */ + @Retention(RetentionPolicy.SOURCE) + @IntDef(prefix = {"ERI_ICON_MODE_"}, value = { + ERI_ICON_MODE_NORMAL, + ERI_ICON_MODE_FLASH + }) + public @interface EriIconMode {} + + /** + * ERI (Enhanced Roaming Indicator) icon mode is normal. This constant represents that + * the ERI icon should be displayed normally. * - * Returns {@link android.telephony#CdmaEriInformation} + * Note: ERI is defined 3GPP2 C.R1001-H Table 8.1-1 + * @hide + */ + public static final int ERI_ICON_MODE_NORMAL = 0; + + /** + * ERI (Enhanced Roaming Indicator) icon mode flash. This constant represents that + * the ERI icon should be flashing. * + * Note: ERI is defined 3GPP2 C.R1001-H Table 8.1-1 + * @hide + */ + public static final int ERI_ICON_MODE_FLASH = 1; + + /** + * Returns the CDMA ERI icon display number. The number is assigned by + * 3GPP2 C.R1001-H v1.0 Table 8.1-1. Additionally carriers define their own ERI display numbers. + * Defined values are {@link #ERI_ON}, {@link #ERI_OFF}, and {@link #ERI_FLASH}. * @hide */ + @SystemApi @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) - @NonNull - public CdmaEriInformation getCdmaEriInformation() { - return new CdmaEriInformation( - getCdmaEriIconIndex(getSubId()), getCdmaEriIconMode(getSubId())); + public @EriIconIndex int getCdmaEnhancedRoamingIndicatorDisplayNumber() { + return getCdmaEriIconIndex(getSubId()); } /** - * Returns the CDMA ERI icon index to display for a subscription + * Returns the CDMA ERI icon index to display for a subscription. * @hide */ @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) @UnsupportedAppUsage - public int getCdmaEriIconIndex(int subId) { + public @EriIconIndex int getCdmaEriIconIndex(int subId) { try { ITelephony telephony = getITelephony(); if (telephony == null) @@ -5647,7 +5698,7 @@ public class TelephonyManager { */ @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) @UnsupportedAppUsage - public int getCdmaEriIconMode(int subId) { + public @EriIconMode int getCdmaEriIconMode(int subId) { try { ITelephony telephony = getITelephony(); if (telephony == null) @@ -9283,11 +9334,22 @@ public class TelephonyManager { * <p>If this object has been created with {@link #createForSubscriptionId}, applies to the * given subId. Otherwise, applies to {@link SubscriptionManager#getDefaultSubscriptionId()} * - * @return one of {@link #CDMA_ROAMING_MODE_RADIO_DEFAULT}, {@link #CDMA_ROAMING_MODE_HOME}, - * {@link #CDMA_ROAMING_MODE_AFFILIATED}, {@link #CDMA_ROAMING_MODE_ANY}. + * @return the CDMA roaming mode. + * @throws SecurityException if the caller does not have the permission. + * @throws IllegalStateException if the Telephony process is not currently available. + * + * @see #CDMA_ROAMING_MODE_RADIO_DEFAULT + * @see #CDMA_ROAMING_MODE_HOME + * @see #CDMA_ROAMING_MODE_AFFILIATED + * @see #CDMA_ROAMING_MODE_ANY + * + * <p>Requires permission: + * {@link android.Manifest.permission#READ_PRIVILEGED_PHONE_STATE READ_PRIVILEGED_PHONE_STATE} + * or that the calling app has carrier privileges (see {@link #hasCarrierPrivileges}). * * @hide */ + @SystemApi @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public @CdmaRoamingMode int getCdmaRoamingMode() { int mode = CDMA_ROAMING_MODE_RADIO_DEFAULT; @@ -9295,9 +9357,12 @@ public class TelephonyManager { ITelephony telephony = getITelephony(); if (telephony != null) { mode = telephony.getCdmaRoamingMode(getSubId()); + } else { + throw new IllegalStateException("telephony service is null."); } } catch (RemoteException ex) { Log.e(TAG, "Error calling ITelephony#getCdmaRoamingMode", ex); + ex.rethrowFromSystemServer(); } return mode; } @@ -9308,25 +9373,36 @@ public class TelephonyManager { * <p>If this object has been created with {@link #createForSubscriptionId}, applies to the * given subId. Otherwise, applies to {@link SubscriptionManager#getDefaultSubscriptionId()} * - * @param mode should be one of {@link #CDMA_ROAMING_MODE_RADIO_DEFAULT}, - * {@link #CDMA_ROAMING_MODE_HOME}, {@link #CDMA_ROAMING_MODE_AFFILIATED}, - * {@link #CDMA_ROAMING_MODE_ANY}. + * @param mode CDMA roaming mode. + * @throws SecurityException if the caller does not have the permission. + * @throws IllegalStateException if the Telephony process or radio is not currently available. + * + * @see #CDMA_ROAMING_MODE_RADIO_DEFAULT + * @see #CDMA_ROAMING_MODE_HOME + * @see #CDMA_ROAMING_MODE_AFFILIATED + * @see #CDMA_ROAMING_MODE_ANY * - * @return {@code true} if successed. + * <p>Requires Permission: + * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} or that the calling + * app has carrier privileges (see {@link #hasCarrierPrivileges}). * * @hide */ + @SystemApi @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) - public boolean setCdmaRoamingMode(@CdmaRoamingMode int mode) { + public void setCdmaRoamingMode(@CdmaRoamingMode int mode) { try { ITelephony telephony = getITelephony(); if (telephony != null) { - return telephony.setCdmaRoamingMode(getSubId(), mode); + boolean result = telephony.setCdmaRoamingMode(getSubId(), mode); + if (!result) throw new IllegalStateException("radio is unavailable."); + } else { + throw new IllegalStateException("telephony service is null."); } } catch (RemoteException ex) { Log.e(TAG, "Error calling ITelephony#setCdmaRoamingMode", ex); + ex.rethrowFromSystemServer(); } - return false; } /** @hide */ @@ -9338,48 +9414,94 @@ public class TelephonyManager { @Retention(RetentionPolicy.SOURCE) public @interface CdmaSubscription{} - /** Used for CDMA subscription mode, it'll be UNKNOWN if there is no Subscription source. + /** + * Used for CDMA subscription mode, it'll be UNKNOWN if there is no Subscription source. * @hide */ + @SystemApi public static final int CDMA_SUBSCRIPTION_UNKNOWN = -1; - /** Used for CDMA subscription mode: RUIM/SIM (default) + /** + * Used for CDMA subscription mode: RUIM/SIM (default) * @hide */ + @SystemApi public static final int CDMA_SUBSCRIPTION_RUIM_SIM = 0; - /** Used for CDMA subscription mode: NV -> non-volatile memory + /** + * Used for CDMA subscription mode: NV -> non-volatile memory * @hide */ + @SystemApi public static final int CDMA_SUBSCRIPTION_NV = 1; - /** @hide */ - public static final int PREFERRED_CDMA_SUBSCRIPTION = CDMA_SUBSCRIPTION_RUIM_SIM; + /** + * Gets the subscription mode for CDMA phone. + * + * @return the CDMA subscription mode. + * @throws SecurityException if the caller does not have the permission. + * @throws IllegalStateException if the Telephony process or radio is not currently available. + * + * @see #CDMA_SUBSCRIPTION_UNKNOWN + * @see #CDMA_SUBSCRIPTION_RUIM_SIM + * @see #CDMA_SUBSCRIPTION_NV + * + * <p>Requires Permission: + * {@link android.Manifest.permission#READ_PRIVILEGED_PHONE_STATE READ_PRIVILEGED_PHONE_STATE} + * or that the calling app has carrier privileges (see {@link #hasCarrierPrivileges}). + * + * @hide + */ + @SystemApi + @RequiresPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE) + public @CdmaSubscription int getCdmaSubscriptionMode() { + int mode = CDMA_SUBSCRIPTION_RUIM_SIM; + try { + ITelephony telephony = getITelephony(); + if (telephony != null) { + mode = telephony.getCdmaSubscriptionMode(getSubId()); + } else { + throw new IllegalStateException("telephony service is null."); + } + } catch (RemoteException ex) { + Log.e(TAG, "Error calling ITelephony#getCdmaSubscriptionMode", ex); + ex.rethrowFromSystemServer(); + } + return mode; + } /** * Sets the subscription mode for CDMA phone to the given mode {@code mode}. * - * @param mode CDMA subscription mode - * - * @return {@code true} if successed. + * @param mode CDMA subscription mode. + * @throws SecurityException if the caller does not have the permission. + * @throws IllegalStateException if the Telephony process is not currently available. * * @see #CDMA_SUBSCRIPTION_UNKNOWN * @see #CDMA_SUBSCRIPTION_RUIM_SIM * @see #CDMA_SUBSCRIPTION_NV * + * <p>Requires Permission: + * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} or that the calling + * app has carrier privileges (see {@link #hasCarrierPrivileges}). + * * @hide */ + @SystemApi @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) - public boolean setCdmaSubscriptionMode(@CdmaSubscription int mode) { + public void setCdmaSubscriptionMode(@CdmaSubscription int mode) { try { ITelephony telephony = getITelephony(); if (telephony != null) { - return telephony.setCdmaSubscriptionMode(getSubId(), mode); + boolean result = telephony.setCdmaSubscriptionMode(getSubId(), mode); + if (!result) throw new IllegalStateException("radio is unavailable."); + } else { + throw new IllegalStateException("telephony service is null."); } } catch (RemoteException ex) { Log.e(TAG, "Error calling ITelephony#setCdmaSubscriptionMode", ex); + ex.rethrowFromSystemServer(); } - return false; } /** @@ -11795,12 +11917,13 @@ public class TelephonyManager { * @hide */ @SystemApi + @TestApi @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public @NetworkTypeBitMask long getSupportedRadioAccessFamily() { try { ITelephony telephony = getITelephony(); if (telephony != null) { - return (long) telephony.getRadioAccessFamily(getSlotIndex(), getOpPackageName()); + return telephony.getRadioAccessFamily(getSlotIndex(), getOpPackageName()); } else { // This can happen when the ITelephony interface is not up yet. return NETWORK_TYPE_BITMASK_UNKNOWN; diff --git a/telephony/java/android/telephony/data/DataCallResponse.java b/telephony/java/android/telephony/data/DataCallResponse.java index a39031d6846e..badae4f7f411 100644 --- a/telephony/java/android/telephony/data/DataCallResponse.java +++ b/telephony/java/android/telephony/data/DataCallResponse.java @@ -108,8 +108,14 @@ public final class DataCallResponse implements Parcelable { */ public static final int HANDOVER_FAILURE_MODE_NO_FALLBACK_RETRY_SETUP_NORMAL = 3; + /** + * Indicates that data retry interval is not specified. Platform can determine when to + * perform data setup appropriately. + */ + public static final int RETRY_INTERVAL_UNDEFINED = -1; + private final @DataFailureCause int mCause; - private final int mSuggestedRetryTime; + private final long mSuggestedRetryTime; private final int mId; private final @LinkStatus int mLinkStatus; private final @ProtocolType int mProtocolType; @@ -171,7 +177,7 @@ public final class DataCallResponse implements Parcelable { mHandoverFailureMode = HANDOVER_FAILURE_MODE_LEGACY; } - private DataCallResponse(@DataFailureCause int cause, int suggestedRetryTime, int id, + private DataCallResponse(@DataFailureCause int cause, long suggestedRetryTime, int id, @LinkStatus int linkStatus, @ProtocolType int protocolType, @Nullable String interfaceName, @Nullable List<LinkAddress> addresses, @Nullable List<InetAddress> dnsAddresses, @Nullable List<InetAddress> gatewayAddresses, @@ -201,7 +207,7 @@ public final class DataCallResponse implements Parcelable { @VisibleForTesting public DataCallResponse(Parcel source) { mCause = source.readInt(); - mSuggestedRetryTime = source.readInt(); + mSuggestedRetryTime = source.readLong(); mId = source.readInt(); mLinkStatus = source.readInt(); mProtocolType = source.readInt(); @@ -228,8 +234,22 @@ public final class DataCallResponse implements Parcelable { /** * @return The suggested data retry time in milliseconds. + * + * @deprecated Use {@link #getRetryIntervalMillis()} instead. + */ + @Deprecated + public int getSuggestedRetryTime() { + return (int) mSuggestedRetryTime; + } + + /** + * @return The network suggested data retry interval in milliseconds. {@code Long.MAX_VALUE} + * indicates data retry should not occur. {@link #RETRY_INTERVAL_UNDEFINED} indicates network + * did not suggest any retry interval. */ - public int getSuggestedRetryTime() { return mSuggestedRetryTime; } + public long getRetryIntervalMillis() { + return mSuggestedRetryTime; + } /** * @return The unique id of the data connection. @@ -381,7 +401,7 @@ public final class DataCallResponse implements Parcelable { @Override public void writeToParcel(Parcel dest, int flags) { dest.writeInt(mCause); - dest.writeInt(mSuggestedRetryTime); + dest.writeLong(mSuggestedRetryTime); dest.writeInt(mId); dest.writeInt(mLinkStatus); dest.writeInt(mProtocolType); @@ -445,7 +465,7 @@ public final class DataCallResponse implements Parcelable { public static final class Builder { private @DataFailureCause int mCause; - private int mSuggestedRetryTime; + private long mSuggestedRetryTime = RETRY_INTERVAL_UNDEFINED; private int mId; @@ -493,9 +513,23 @@ public final class DataCallResponse implements Parcelable { * * @param suggestedRetryTime The suggested data retry time in milliseconds. * @return The same instance of the builder. + * + * @deprecated Use {@link #setRetryIntervalMillis(long)} instead. */ + @Deprecated public @NonNull Builder setSuggestedRetryTime(int suggestedRetryTime) { - mSuggestedRetryTime = suggestedRetryTime; + mSuggestedRetryTime = (long) suggestedRetryTime; + return this; + } + + /** + * Set the network suggested data retry interval. + * + * @param retryIntervalMillis The suggested data retry interval in milliseconds. + * @return The same instance of the builder. + */ + public @NonNull Builder setRetryIntervalMillis(long retryIntervalMillis) { + mSuggestedRetryTime = retryIntervalMillis; return this; } diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl index d16cb16a290c..4895fffa5849 100644 --- a/telephony/java/com/android/internal/telephony/ITelephony.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl @@ -1799,6 +1799,14 @@ interface ITelephony { boolean setCdmaRoamingMode(int subId, int mode); /** + * Gets the subscription mode for the CDMA phone with the subscription id {@code subId}. + * + * @param the subscription id. + * @return the subscription mode for CDMA phone. + */ + int getCdmaSubscriptionMode(int subId); + + /** * Sets the subscription mode for CDMA phone with the subscription {@code subId} to the given * subscription mode {@code mode}. * diff --git a/wifi/jarjar-rules.txt b/wifi/jarjar-rules.txt index ff06a180b8c1..75b5e728eb0d 100644 --- a/wifi/jarjar-rules.txt +++ b/wifi/jarjar-rules.txt @@ -89,8 +89,6 @@ rule android.util.BackupUtils* com.android.wifi.x.@0 rule android.util.LocalLog* com.android.wifi.x.@0 rule android.util.Rational* com.android.wifi.x.@0 -rule android.os.BasicShellCommandHandler* com.android.wifi.x.@0 - # Use our statically linked bouncy castle library rule org.bouncycastle.** com.android.wifi.x.@0 # Use our statically linked protobuf library |