diff options
-rw-r--r-- | core/java/android/provider/Telephony.java | 41 | ||||
-rw-r--r-- | core/java/android/service/carrier/ApnService.java | 2 | ||||
-rw-r--r-- | core/java/android/service/carrier/IApnSourceService.aidl (renamed from telephony/java/com/android/internal/telephony/IApnSourceService.aidl) | 3 | ||||
-rw-r--r-- | telephony/common/com/android/internal/telephony/EncodeException.java (renamed from telephony/java/com/android/internal/telephony/EncodeException.java) | 0 | ||||
-rw-r--r-- | telephony/common/com/android/internal/telephony/SmsApplication.java | 2 | ||||
-rw-r--r-- | telephony/java/android/telephony/CbGeoUtils.java | 20 | ||||
-rw-r--r-- | telephony/java/android/telephony/SmsCbMessage.java | 3 | ||||
-rw-r--r-- | telephony/java/android/telephony/SmsManager.java | 5 | ||||
-rw-r--r-- | telephony/java/android/telephony/SubscriptionManager.java | 51 | ||||
-rw-r--r-- | telephony/java/android/telephony/TelephonyManager.java | 6 | ||||
-rw-r--r-- | telephony/java/com/android/internal/telephony/util/TelephonyUtils.java | 74 |
11 files changed, 147 insertions, 60 deletions
diff --git a/core/java/android/provider/Telephony.java b/core/java/android/provider/Telephony.java index 8a3d79c2eb31..066ba6e8678e 100644 --- a/core/java/android/provider/Telephony.java +++ b/core/java/android/provider/Telephony.java @@ -25,7 +25,6 @@ import android.annotation.SdkConstant.SdkConstantType; import android.annotation.SystemApi; import android.annotation.TestApi; import android.annotation.UnsupportedAppUsage; -import android.app.job.JobService; import android.content.ComponentName; import android.content.ContentResolver; import android.content.ContentValues; @@ -4119,20 +4118,6 @@ public final class Telephony { public static final String CID = "cid"; /** - * Message code. <em>OBSOLETE: merged into SERIAL_NUMBER.</em> - * <P>Type: INTEGER</P> - * @hide - */ - public static final String V1_MESSAGE_CODE = "message_code"; - - /** - * Message identifier. <em>OBSOLETE: renamed to SERVICE_CATEGORY.</em> - * <P>Type: INTEGER</P> - * @hide - */ - public static final String V1_MESSAGE_IDENTIFIER = "message_id"; - - /** * Service category which represents the general topic of the message. * <p> * For GSM/UMTS: message identifier (see 3GPP TS 23.041 section 9.4.1.2.2) @@ -4380,9 +4365,11 @@ public final class Telephony { * ServiceState provider. * <p> * Use this {@link Uri} with a {@link ContentObserver} to be notified of changes to the - * {@link ServiceState} while your app is running. You can also use a {@link JobService} to + * {@link ServiceState} while your app is running. + * You can also use a {@link android.app.job.JobService} to * ensure your app is notified of changes to the {@link Uri} even when it is not running. - * Note, however, that using a {@link JobService} does not guarantee timely delivery of + * Note, however, that using a {@link android.app.job.JobService} + * does not guarantee timely delivery of * updates to the {@link Uri}. * * @param subscriptionId the subscriptionId to receive updates on @@ -4399,9 +4386,11 @@ public final class Telephony { * ServiceState provider. * <p> * Use this {@link Uri} with a {@link ContentObserver} to be notified of changes to the - * {@link ServiceState} while your app is running. You can also use a {@link JobService} to + * {@link ServiceState} while your app is running. You can also use a + * {@link android.app.job.JobService} to * ensure your app is notified of changes to the {@link Uri} even when it is not running. - * Note, however, that using a {@link JobService} does not guarantee timely delivery of + * Note, however, that using a {@link android.app.job.JobService} + * does not guarantee timely delivery of * updates to the {@link Uri}. * * @param subscriptionId the subscriptionId to receive updates on @@ -4655,10 +4644,11 @@ public final class Telephony { * <p> * Use this {@link Uri} with a {@link ContentObserver} to be notified of changes to the * carrier identity {@link TelephonyManager#getSimCarrierId()} - * while your app is running. You can also use a {@link JobService} to ensure your app + * while your app is running. You can also use a {@link android.app.job.JobService} + * to ensure your app * is notified of changes to the {@link Uri} even when it is not running. - * Note, however, that using a {@link JobService} does not guarantee timely delivery of - * updates to the {@link Uri}. + * Note, however, that using a {@link android.app.job.JobService} does not guarantee + * timely delivery of updates to the {@link Uri}. * * @param subscriptionId the subscriptionId to receive updates on * @return the Uri used to observe carrier identity changes @@ -4676,10 +4666,11 @@ public final class Telephony { * <p> * Use this {@link Uri} with a {@link ContentObserver} to be notified of changes to the * specific carrier identity {@link TelephonyManager#getSimSpecificCarrierId()} - * while your app is running. You can also use a {@link JobService} to ensure your app + * while your app is running. You can also use a {@link android.app.job.JobService} + * to ensure your app * is notified of changes to the {@link Uri} even when it is not running. - * Note, however, that using a {@link JobService} does not guarantee timely delivery of - * updates to the {@link Uri}. + * Note, however, that using a {@link android.app.job.JobService} does not guarantee timely + * delivery of updates to the {@link Uri}. * * @param subscriptionId the subscriptionId to receive updates on * @return the Uri used to observe specific carrier identity changes diff --git a/core/java/android/service/carrier/ApnService.java b/core/java/android/service/carrier/ApnService.java index 57e4b1b40748..0c12fd409078 100644 --- a/core/java/android/service/carrier/ApnService.java +++ b/core/java/android/service/carrier/ApnService.java @@ -26,7 +26,7 @@ import android.content.Intent; import android.os.IBinder; import android.util.Log; -import com.android.internal.telephony.IApnSourceService; +import android.service.carrier.IApnSourceService; import java.util.List; diff --git a/telephony/java/com/android/internal/telephony/IApnSourceService.aidl b/core/java/android/service/carrier/IApnSourceService.aidl index 34c9067c3f2f..fadd2ff1a772 100644 --- a/telephony/java/com/android/internal/telephony/IApnSourceService.aidl +++ b/core/java/android/service/carrier/IApnSourceService.aidl @@ -14,10 +14,11 @@ * limitations under the License. */ -package com.android.internal.telephony; +package android.service.carrier; import android.content.ContentValues; +/** @hide */ interface IApnSourceService { /** Retreive APNs. */ ContentValues[] getApns(int subId); diff --git a/telephony/java/com/android/internal/telephony/EncodeException.java b/telephony/common/com/android/internal/telephony/EncodeException.java index cdc853e09895..cdc853e09895 100644 --- a/telephony/java/com/android/internal/telephony/EncodeException.java +++ b/telephony/common/com/android/internal/telephony/EncodeException.java diff --git a/telephony/common/com/android/internal/telephony/SmsApplication.java b/telephony/common/com/android/internal/telephony/SmsApplication.java index 7cf4eebabec9..df668ea2313d 100644 --- a/telephony/common/com/android/internal/telephony/SmsApplication.java +++ b/telephony/common/com/android/internal/telephony/SmsApplication.java @@ -305,7 +305,7 @@ public final class SmsApplication { Uri.fromParts(SCHEME_SMSTO, "", null)); List<ResolveInfo> respondServices = packageManager.queryIntentServicesAsUser(intent, PackageManager.MATCH_DIRECT_BOOT_AWARE | PackageManager.MATCH_DIRECT_BOOT_UNAWARE, - UserHandle.getUserHandleForUid(userId)); + UserHandle.of(userId)); for (ResolveInfo resolveInfo : respondServices) { final ServiceInfo serviceInfo = resolveInfo.serviceInfo; if (serviceInfo == null) { diff --git a/telephony/java/android/telephony/CbGeoUtils.java b/telephony/java/android/telephony/CbGeoUtils.java index f4ce6e75769c..ce5e3f38e78b 100644 --- a/telephony/java/android/telephony/CbGeoUtils.java +++ b/telephony/java/android/telephony/CbGeoUtils.java @@ -18,6 +18,7 @@ package android.telephony; import android.annotation.NonNull; import android.annotation.SystemApi; +import android.os.Build; import android.text.TextUtils; import java.util.ArrayList; @@ -257,6 +258,15 @@ public class CbGeoUtils { return new Point(x - p.x, y - p.y); } } + + @Override + public String toString() { + String str = "Polygon: "; + if (Build.IS_DEBUGGABLE) { + str += mVertices; + } + return str; + } } /** @@ -284,6 +294,16 @@ public class CbGeoUtils { public boolean contains(LatLng p) { return mCenter.distance(p) <= mRadiusMeter; } + + @Override + public String toString() { + String str = "Circle: "; + if (Build.IS_DEBUGGABLE) { + str += mCenter + ", radius = " + mRadiusMeter; + } + + return str; + } } /** diff --git a/telephony/java/android/telephony/SmsCbMessage.java b/telephony/java/android/telephony/SmsCbMessage.java index c7f952954d5f..045d1ebb5640 100644 --- a/telephony/java/android/telephony/SmsCbMessage.java +++ b/telephony/java/android/telephony/SmsCbMessage.java @@ -533,7 +533,8 @@ public final class SmsCbMessage implements Parcelable { + ", priority=" + mPriority + (mEtwsWarningInfo != null ? (", " + mEtwsWarningInfo.toString()) : "") + (mCmasWarningInfo != null ? (", " + mCmasWarningInfo.toString()) : "") - + ", maximumWaitingTime = " + mMaximumWaitTimeSec + + ", maximumWaitingTime=" + mMaximumWaitTimeSec + + ", received time=" + mReceivedTimeMillis + ", slotIndex = " + mSlotIndex + ", geo=" + (mGeometries != null ? CbGeoUtils.encodeGeometriesToString(mGeometries) : "null") diff --git a/telephony/java/android/telephony/SmsManager.java b/telephony/java/android/telephony/SmsManager.java index 1faa65a4e6c7..5b49117be532 100644 --- a/telephony/java/android/telephony/SmsManager.java +++ b/telephony/java/android/telephony/SmsManager.java @@ -80,11 +80,6 @@ public final class SmsManager { SubscriptionManager.DEFAULT_SUBSCRIPTION_ID); private static final Object sLockObject = new Object(); - /** @hide */ - public static final int CELL_BROADCAST_RAN_TYPE_GSM = 0; - /** @hide */ - public static final int CELL_BROADCAST_RAN_TYPE_CDMA = 1; - /** SMS record length from TS 51.011 10.5.3 * @hide */ diff --git a/telephony/java/android/telephony/SubscriptionManager.java b/telephony/java/android/telephony/SubscriptionManager.java index 16415ead8b13..4f908408506b 100644 --- a/telephony/java/android/telephony/SubscriptionManager.java +++ b/telephony/java/android/telephony/SubscriptionManager.java @@ -35,7 +35,6 @@ import android.annotation.TestApi; import android.annotation.UnsupportedAppUsage; import android.app.BroadcastOptions; import android.app.PendingIntent; -import android.app.job.JobService; import android.content.Context; import android.content.Intent; import android.content.pm.PackageInfo; @@ -148,10 +147,11 @@ public class SubscriptionManager { * <p> * Use this {@link Uri} with a {@link ContentObserver} to be notified of changes to the * subscription wfc enabled {@link ImsMmTelManager#isVoWiFiSettingEnabled()} - * while your app is running. You can also use a {@link JobService} to ensure your app + * while your app is running. You can also use a {@link android.app.job.JobService} + * to ensure your app * is notified of changes to the {@link Uri} even when it is not running. - * Note, however, that using a {@link JobService} does not guarantee timely delivery of - * updates to the {@link Uri}. + * Note, however, that using a {@link android.app.job.JobService} does not guarantee timely + * delivery of updates to the {@link Uri}. * To be notified of changes to a specific subId, append subId to the URI * {@link Uri#withAppendedPath(Uri, String)}. * @hide @@ -168,10 +168,10 @@ public class SubscriptionManager { * Use this {@link Uri} with a {@link ContentObserver} to be notified of changes to the * subscription advanced calling enabled * {@link ImsMmTelManager#isAdvancedCallingSettingEnabled()} while your app is running. - * You can also use a {@link JobService} to ensure your app is notified of changes to the - * {@link Uri} even when it is not running. - * Note, however, that using a {@link JobService} does not guarantee timely delivery of - * updates to the {@link Uri}. + * You can also use a {@link android.app.job.JobService} to ensure your app is notified of + * changes to the {@link Uri} even when it is not running. + * Note, however, that using a {@link android.app.job.JobService} does not guarantee timely + * delivery of updates to the {@link Uri}. * To be notified of changes to a specific subId, append subId to the URI * {@link Uri#withAppendedPath(Uri, String)}. * @hide @@ -187,10 +187,10 @@ public class SubscriptionManager { * <p> * Use this {@link Uri} with a {@link ContentObserver} to be notified of changes to the * subscription wfc mode {@link ImsMmTelManager#getVoWiFiModeSetting()} - * while your app is running. You can also use a {@link JobService} to ensure your app - * is notified of changes to the {@link Uri} even when it is not running. - * Note, however, that using a {@link JobService} does not guarantee timely delivery of - * updates to the {@link Uri}. + * while your app is running. You can also use a {@link android.app.job.JobService} to ensure + * your app is notified of changes to the {@link Uri} even when it is not running. + * Note, however, that using a {@link android.app.job.JobService} does not guarantee timely + * delivery of updates to the {@link Uri}. * To be notified of changes to a specific subId, append subId to the URI * {@link Uri#withAppendedPath(Uri, String)}. * @hide @@ -205,10 +205,10 @@ public class SubscriptionManager { * <p> * Use this {@link Uri} with a {@link ContentObserver} to be notified of changes to the * subscription wfc roaming mode {@link ImsMmTelManager#getVoWiFiRoamingModeSetting()} - * while your app is running. You can also use a {@link JobService} to ensure your app - * is notified of changes to the {@link Uri} even when it is not running. - * Note, however, that using a {@link JobService} does not guarantee timely delivery of - * updates to the {@link Uri}. + * while your app is running. You can also use a {@link android.app.job.JobService} + * to ensure your app is notified of changes to the {@link Uri} even when it is not running. + * Note, however, that using a {@link android.app.job.JobService} does not guarantee timely + * delivery of updates to the {@link Uri}. * To be notified of changes to a specific subId, append subId to the URI * {@link Uri#withAppendedPath(Uri, String)}. * @hide @@ -225,10 +225,10 @@ public class SubscriptionManager { * <p> * Use this {@link Uri} with a {@link ContentObserver} to be notified of changes to the * subscription vt enabled {@link ImsMmTelManager#isVtSettingEnabled()} - * while your app is running. You can also use a {@link JobService} to ensure your app - * is notified of changes to the {@link Uri} even when it is not running. - * Note, however, that using a {@link JobService} does not guarantee timely delivery of - * updates to the {@link Uri}. + * while your app is running. You can also use a {@link android.app.job.JobService} to ensure + * your app is notified of changes to the {@link Uri} even when it is not running. + * Note, however, that using a {@link android.app.job.JobService} does not guarantee timely + * delivery of updates to the {@link Uri}. * To be notified of changes to a specific subId, append subId to the URI * {@link Uri#withAppendedPath(Uri, String)}. * @hide @@ -244,10 +244,10 @@ public class SubscriptionManager { * <p> * Use this {@link Uri} with a {@link ContentObserver} to be notified of changes to the * subscription wfc roaming enabled {@link ImsMmTelManager#isVoWiFiRoamingSettingEnabled()} - * while your app is running. You can also use a {@link JobService} to ensure your app - * is notified of changes to the {@link Uri} even when it is not running. - * Note, however, that using a {@link JobService} does not guarantee timely delivery of - * updates to the {@link Uri}. + * while your app is running. You can also use a {@link android.app.job.JobService} to ensure + * your app is notified of changes to the {@link Uri} even when it is not running. + * Note, however, that using a {@link android.app.job.JobService} does not guarantee timely + * delivery of updates to the {@link Uri}. * To be notified of changes to a specific subId, append subId to the URI * {@link Uri#withAppendedPath(Uri, String)}. * @hide @@ -2914,8 +2914,7 @@ public class SubscriptionManager { * * @throws SecurityException if the caller doesn't meet the requirements * outlined above. - * @throws IllegalArgumentException if the some subscriptions in the list doesn't exist, - * or the groupUuid doesn't exist. + * @throws IllegalArgumentException if the some subscriptions in the list doesn't exist. * @throws IllegalStateException if Telephony service is in bad state. * * @param subIdList list of subId that need adding into the group diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 58f1e8407d13..7232ea714180 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -2367,6 +2367,8 @@ public class TelephonyManager { * * @return the lowercase 2 character ISO-3166 country code, or empty string if not available. * + * @throws IllegalArgumentException when the slotIndex is invalid. + * * {@hide} */ @SystemApi @@ -2374,6 +2376,10 @@ public class TelephonyManager { @NonNull public String getNetworkCountryIso(int slotIndex) { try { + if (!SubscriptionManager.isValidSlotIndex(slotIndex)) { + throw new IllegalArgumentException("invalid slot index " + slotIndex); + } + ITelephony telephony = getITelephony(); if (telephony == null) return ""; return telephony.getNetworkCountryIsoForPhone(slotIndex); diff --git a/telephony/java/com/android/internal/telephony/util/TelephonyUtils.java b/telephony/java/com/android/internal/telephony/util/TelephonyUtils.java new file mode 100644 index 000000000000..a28d65c9abb6 --- /dev/null +++ b/telephony/java/com/android/internal/telephony/util/TelephonyUtils.java @@ -0,0 +1,74 @@ +/* + * 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 com.android.internal.telephony.util; + +import android.annotation.NonNull; +import android.annotation.Nullable; +import android.content.Context; +import android.content.pm.ComponentInfo; +import android.content.pm.PackageManager; +import android.content.pm.ResolveInfo; +import android.os.Binder; +import android.os.RemoteException; +import android.os.SystemProperties; + +import java.io.PrintWriter; + +/** + * This class provides various util functions + */ +public final class TelephonyUtils { + public static boolean IS_USER = "user".equals(android.os.Build.TYPE); + public static boolean IS_DEBUGGABLE = SystemProperties.getInt("ro.debuggable", 0) == 1; + + /** + * Verify that caller holds {@link android.Manifest.permission#DUMP}. + * + * @return true if access should be granted. + */ + public static boolean checkDumpPermission(Context context, String tag, PrintWriter pw) { + if (context.checkCallingOrSelfPermission(android.Manifest.permission.DUMP) + != PackageManager.PERMISSION_GRANTED) { + pw.println("Permission Denial: can't dump " + tag + " from from pid=" + + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid() + + " due to missing android.permission.DUMP permission"); + return false; + } else { + return true; + } + } + + /** Returns an empty string if the input is {@code null}. */ + public static String emptyIfNull(@Nullable String str) { + return str == null ? "" : str; + } + + /** Throws a {@link RuntimeException} that wrapps the {@link RemoteException}. */ + public static RuntimeException rethrowAsRuntimeException(RemoteException remoteException) { + throw new RuntimeException(remoteException); + } + + /** + * Returns a {@link ComponentInfo} from the {@link ResolveInfo}, + * or throws an {@link IllegalStateException} if not available. + */ + public static ComponentInfo getComponentInfo(@NonNull ResolveInfo resolveInfo) { + if (resolveInfo.activityInfo != null) return resolveInfo.activityInfo; + if (resolveInfo.serviceInfo != null) return resolveInfo.serviceInfo; + if (resolveInfo.providerInfo != null) return resolveInfo.providerInfo; + throw new IllegalStateException("Missing ComponentInfo!"); + } +} |