Merge changes from topic "CherryPickMainline"

* changes:
  make sim_colors a system config
  convert hidden configs to public
  Add back off timer configs as carrier config
  Carrier config to switch data if primary is OOS
  Do not use hidden enabledSetting
  Do not use hidden putIntForUser
  Fix testNetworkScanRequestParcel_Parcel CTS
  Do not use hidden broadcast API of RemoteCallbackList
  Make requestModemActivityInfo a system api
  Remove usage of hidden Parcel APIs
  Do not use hidden withCleanCallingIdentity
  Do not use hidden isPrivilegedApp
This commit is contained in:
Sooraj Sasindran
2020-01-29 17:34:53 +00:00
committed by Gerrit Code Review
25 changed files with 366 additions and 115 deletions

View File

@@ -44701,6 +44701,7 @@ package android.telephony {
field public static final String KEY_5G_NR_SSRSRP_THRESHOLDS_INT_ARRAY = "5g_nr_ssrsrp_thresholds_int_array";
field public static final String KEY_5G_NR_SSRSRQ_THRESHOLDS_INT_ARRAY = "5g_nr_ssrsrq_thresholds_int_array";
field public static final String KEY_5G_NR_SSSINR_THRESHOLDS_INT_ARRAY = "5g_nr_sssinr_thresholds_int_array";
field public static final String KEY_5G_WATCHDOG_TIME_MS_LONG = "5g_watchdog_time_long";
field public static final String KEY_ADDITIONAL_CALL_SETTING_BOOL = "additional_call_setting_bool";
field public static final String KEY_ALLOW_ADDING_APNS_BOOL = "allow_adding_apns_bool";
field public static final String KEY_ALLOW_ADD_CALL_DURING_VIDEO_CALL_BOOL = "allow_add_call_during_video_call";
@@ -44784,6 +44785,7 @@ package android.telephony {
field public static final String KEY_DATA_LIMIT_NOTIFICATION_BOOL = "data_limit_notification_bool";
field public static final String KEY_DATA_LIMIT_THRESHOLD_BYTES_LONG = "data_limit_threshold_bytes_long";
field public static final String KEY_DATA_RAPID_NOTIFICATION_BOOL = "data_rapid_notification_bool";
field public static final String KEY_DATA_SWITCH_VALIDATION_TIMEOUT_LONG = "data_switch_validation_timeout_long";
field public static final String KEY_DATA_WARNING_NOTIFICATION_BOOL = "data_warning_notification_bool";
field public static final String KEY_DATA_WARNING_THRESHOLD_BYTES_LONG = "data_warning_threshold_bytes_long";
field public static final String KEY_DEFAULT_SIM_CALL_MANAGER_STRING = "default_sim_call_manager_string";
@@ -44866,6 +44868,8 @@ package android.telephony {
field public static final String KEY_ONLY_AUTO_SELECT_IN_HOME_NETWORK_BOOL = "only_auto_select_in_home_network";
field public static final String KEY_ONLY_SINGLE_DC_ALLOWED_INT_ARRAY = "only_single_dc_allowed_int_array";
field public static final String KEY_OPERATOR_SELECTION_EXPAND_BOOL = "operator_selection_expand_bool";
field public static final String KEY_OPPORTUNISTIC_NETWORK_BACKOFF_TIME_LONG = "opportunistic_network_backoff_time_long";
field public static final String KEY_OPPORTUNISTIC_NETWORK_DATA_SWITCH_EXIT_HYSTERESIS_TIME_LONG = "opportunistic_network_data_switch_exit_hysteresis_time_long";
field public static final String KEY_OPPORTUNISTIC_NETWORK_DATA_SWITCH_HYSTERESIS_TIME_LONG = "opportunistic_network_data_switch_hysteresis_time_long";
field public static final String KEY_OPPORTUNISTIC_NETWORK_ENTRY_OR_EXIT_HYSTERESIS_TIME_LONG = "opportunistic_network_entry_or_exit_hysteresis_time_long";
field public static final String KEY_OPPORTUNISTIC_NETWORK_ENTRY_THRESHOLD_BANDWIDTH_INT = "opportunistic_network_entry_threshold_bandwidth_int";
@@ -44873,6 +44877,9 @@ package android.telephony {
field public static final String KEY_OPPORTUNISTIC_NETWORK_ENTRY_THRESHOLD_RSSNR_INT = "opportunistic_network_entry_threshold_rssnr_int";
field public static final String KEY_OPPORTUNISTIC_NETWORK_EXIT_THRESHOLD_RSRP_INT = "opportunistic_network_exit_threshold_rsrp_int";
field public static final String KEY_OPPORTUNISTIC_NETWORK_EXIT_THRESHOLD_RSSNR_INT = "opportunistic_network_exit_threshold_rssnr_int";
field public static final String KEY_OPPORTUNISTIC_NETWORK_MAX_BACKOFF_TIME_LONG = "opportunistic_network_max_backoff_time_long";
field public static final String KEY_OPPORTUNISTIC_NETWORK_PING_PONG_TIME_LONG = "opportunistic_network_ping_pong_time_long";
field public static final String KEY_PING_TEST_BEFORE_DATA_SWITCH_BOOL = "ping_test_before_data_switch_bool";
field public static final String KEY_PREFER_2G_BOOL = "prefer_2g_bool";
field public static final String KEY_PREVENT_CLIR_ACTIVATION_AND_DEACTIVATION_CODE_BOOL = "prevent_clir_activation_and_deactivation_code_bool";
field public static final String KEY_RADIO_RESTART_FAILURE_CAUSES_INT_ARRAY = "radio_restart_failure_causes_int_array";
@@ -44909,6 +44916,7 @@ package android.telephony {
field public static final String KEY_SUPPORT_SWAP_AFTER_MERGE_BOOL = "support_swap_after_merge_bool";
field public static final String KEY_SUPPORT_TDSCDMA_BOOL = "support_tdscdma_bool";
field public static final String KEY_SUPPORT_TDSCDMA_ROAMING_NETWORKS_STRING_ARRAY = "support_tdscdma_roaming_networks_string_array";
field public static final String KEY_SWITCH_DATA_TO_PRIMARY_IF_PRIMARY_IS_OOS_BOOL = "switch_data_to_primary_if_primary_is_oos_bool";
field public static final String KEY_TREAT_DOWNGRADED_VIDEO_CALLS_AS_VIDEO_CALLS_BOOL = "treat_downgraded_video_calls_as_video_calls_bool";
field public static final String KEY_TTY_SUPPORTED_BOOL = "tty_supported_bool";
field public static final String KEY_UNLOGGABLE_NUMBERS_STRING_ARRAY = "unloggable_numbers_string_array";

View File

@@ -226,6 +226,7 @@ package android {
public static final class R.array {
field public static final int config_keySystemUuidMapping = 17235973; // 0x1070005
field public static final int simColors = 17235974; // 0x1070006
}
public static final class R.attr {
@@ -9556,6 +9557,7 @@ package android.telephony {
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean rebootRadio();
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void reportDefaultNetworkStatus(boolean);
method @RequiresPermission(allOf={android.Manifest.permission.ACCESS_FINE_LOCATION, android.Manifest.permission.MODIFY_PHONE_STATE}) public void requestCellInfoUpdate(@NonNull android.os.WorkSource, @NonNull java.util.concurrent.Executor, @NonNull android.telephony.TelephonyManager.CellInfoCallback);
method public void requestModemActivityInfo(@NonNull android.os.ResultReceiver);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void requestNumberVerification(@NonNull android.telephony.PhoneNumberRange, long, @NonNull java.util.concurrent.Executor, @NonNull android.telephony.NumberVerificationCallback);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void resetAllCarrierActions();
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void resetCarrierKeysForImsiEncryption();

View File

@@ -6237,7 +6237,8 @@ message DeviceIdentifierAccessDenied {
optional bool is_preinstalled = 3;
// True if the package is privileged.
optional bool is_priv_app = 4;
// Starting from Android 11, this boolean is not set and will always be false.
optional bool is_priv_app = 4 [deprecated = true];
}
/**

View File

@@ -165,7 +165,7 @@
<item>中文 (繁體)</item>
</string-array>
<array name="sim_colors">
<array name="simColors">
<item>@color/Teal_700</item>
<item>@color/Blue_700</item>
<item>@color/Indigo_700</item>

View File

@@ -3021,6 +3021,10 @@
<public-group type="color" first-id="0x0106001d">
</public-group>
<public-group type="array" first-id="0x01070006">
<!-- @hide @SystemApi -->
<public name="simColors" />
</public-group>
<!-- ===============================================================
DO NOT ADD UN-GROUPED ITEMS HERE

View File

@@ -1303,7 +1303,7 @@
<java-symbol type="array" name="preloaded_color_state_lists" />
<java-symbol type="array" name="preloaded_drawables" />
<java-symbol type="array" name="preloaded_freeform_multi_window_drawables" />
<java-symbol type="array" name="sim_colors" />
<java-symbol type="array" name="simColors" />
<java-symbol type="array" name="special_locale_codes" />
<java-symbol type="array" name="special_locale_names" />
<java-symbol type="array" name="supported_locales" />

View File

@@ -21009,7 +21009,7 @@ public class PackageManagerService extends IPackageManager.Stub
// Disable any carrier apps. We do this very early in boot to prevent the apps from being
// disabled after already being started.
CarrierAppUtils.disableCarrierAppsUntilPrivileged(mContext.getOpPackageName(), this,
mContext.getContentResolver(), UserHandle.USER_SYSTEM);
UserHandle.USER_SYSTEM, mContext);
disableSkuSpecificApps();

View File

@@ -18,16 +18,18 @@ package com.android.internal.telephony;
import android.annotation.Nullable;
import android.content.ContentResolver;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.IPackageManager;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.os.RemoteException;
import android.os.UserHandle;
import android.provider.Settings;
import android.util.Log;
import android.telephony.TelephonyManager;
import android.util.ArrayMap;
import android.util.ArraySet;
import android.util.Log;
import com.android.internal.R;
import com.android.internal.annotations.VisibleForTesting;
@@ -75,7 +77,7 @@ public final class CarrierAppUtils {
*/
public static synchronized void disableCarrierAppsUntilPrivileged(String callingPackage,
IPackageManager packageManager, TelephonyManager telephonyManager,
ContentResolver contentResolver, int userId) {
int userId, Context context) {
if (DEBUG) {
Log.d(TAG, "disableCarrierAppsUntilPrivileged");
}
@@ -84,6 +86,7 @@ public final class CarrierAppUtils {
config.getDisabledUntilUsedPreinstalledCarrierApps();
ArrayMap<String, List<String>> systemCarrierAssociatedAppsDisabledUntilUsed =
config.getDisabledUntilUsedPreinstalledCarrierAssociatedApps();
ContentResolver contentResolver = getContentResolverForUser(context, userId);
disableCarrierAppsUntilPrivileged(callingPackage, packageManager, telephonyManager,
contentResolver, userId, systemCarrierAppsDisabledUntilUsed,
systemCarrierAssociatedAppsDisabledUntilUsed);
@@ -101,7 +104,7 @@ public final class CarrierAppUtils {
* Manager can kill it, and this can lead to crashes as the app is in an unexpected state.
*/
public static synchronized void disableCarrierAppsUntilPrivileged(String callingPackage,
IPackageManager packageManager, ContentResolver contentResolver, int userId) {
IPackageManager packageManager, int userId, Context context) {
if (DEBUG) {
Log.d(TAG, "disableCarrierAppsUntilPrivileged");
}
@@ -112,23 +115,31 @@ public final class CarrierAppUtils {
ArrayMap<String, List<String>> systemCarrierAssociatedAppsDisabledUntilUsed =
config.getDisabledUntilUsedPreinstalledCarrierAssociatedApps();
ContentResolver contentResolver = getContentResolverForUser(context, userId);
disableCarrierAppsUntilPrivileged(callingPackage, packageManager,
null /* telephonyManager */, contentResolver, userId,
systemCarrierAppsDisabledUntilUsed, systemCarrierAssociatedAppsDisabledUntilUsed);
}
private static ContentResolver getContentResolverForUser(Context context, int userId) {
Context userContext = context.createContextAsUser(UserHandle.getUserHandleForUid(userId),
0);
return userContext.getContentResolver();
}
/**
* Disable carrier apps until they are privileged
* Must be public b/c framework unit tests can't access package-private methods.
*/
// Must be public b/c framework unit tests can't access package-private methods.
@VisibleForTesting
public static void disableCarrierAppsUntilPrivileged(String callingPackage,
IPackageManager packageManager, @Nullable TelephonyManager telephonyManager,
ContentResolver contentResolver, int userId,
ArraySet<String> systemCarrierAppsDisabledUntilUsed,
ArrayMap<String, List<String>> systemCarrierAssociatedAppsDisabledUntilUsed) {
List<ApplicationInfo> candidates = getDefaultCarrierAppCandidatesHelper(packageManager,
userId, systemCarrierAppsDisabledUntilUsed);
List<ApplicationInfo> candidates = getDefaultNotUpdatedCarrierAppCandidatesHelper(
packageManager, userId, systemCarrierAppsDisabledUntilUsed);
if (candidates == null || candidates.isEmpty()) {
return;
}
@@ -139,9 +150,8 @@ public final class CarrierAppUtils {
systemCarrierAssociatedAppsDisabledUntilUsed);
List<String> enabledCarrierPackages = new ArrayList<>();
boolean hasRunOnce = Settings.Secure.getIntForUser(
contentResolver, Settings.Secure.CARRIER_APPS_HANDLED, 0, userId) == 1;
boolean hasRunOnce = Settings.Secure.getInt(contentResolver,
Settings.Secure.CARRIER_APPS_HANDLED, 0) == 1;
try {
for (ApplicationInfo ai : candidates) {
@@ -165,15 +175,16 @@ public final class CarrierAppUtils {
}
}
int enabledSetting = packageManager.getApplicationEnabledSetting(packageName,
userId);
if (hasPrivileges) {
// Only update enabled state for the app on /system. Once it has been
// updated we shouldn't touch it.
if (!ai.isUpdatedSystemApp()
&& (ai.enabledSetting
if (enabledSetting
== PackageManager.COMPONENT_ENABLED_STATE_DEFAULT
|| ai.enabledSetting
|| enabledSetting
== PackageManager.COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED
|| (ai.flags & ApplicationInfo.FLAG_INSTALLED) == 0)) {
|| (ai.flags & ApplicationInfo.FLAG_INSTALLED) == 0) {
Log.i(TAG, "Update state(" + packageName + "): ENABLED for user "
+ userId);
packageManager.setSystemAppInstallState(
@@ -191,9 +202,12 @@ public final class CarrierAppUtils {
// Also enable any associated apps for this carrier app.
if (associatedAppList != null) {
for (ApplicationInfo associatedApp : associatedAppList) {
if (associatedApp.enabledSetting
int associatedAppEnabledSetting =
packageManager.getApplicationEnabledSetting(
associatedApp.packageName, userId);
if (associatedAppEnabledSetting
== PackageManager.COMPONENT_ENABLED_STATE_DEFAULT
|| associatedApp.enabledSetting
|| associatedAppEnabledSetting
== PackageManager.COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED
|| (associatedApp.flags
& ApplicationInfo.FLAG_INSTALLED) == 0) {
@@ -218,8 +232,7 @@ public final class CarrierAppUtils {
} else { // No carrier privileges
// Only update enabled state for the app on /system. Once it has been
// updated we shouldn't touch it.
if (!ai.isUpdatedSystemApp()
&& ai.enabledSetting
if (enabledSetting
== PackageManager.COMPONENT_ENABLED_STATE_DEFAULT
&& (ai.flags & ApplicationInfo.FLAG_INSTALLED) != 0) {
Log.i(TAG, "Update state(" + packageName
@@ -236,7 +249,10 @@ public final class CarrierAppUtils {
if (!hasRunOnce) {
if (associatedAppList != null) {
for (ApplicationInfo associatedApp : associatedAppList) {
if (associatedApp.enabledSetting
int associatedAppEnabledSetting =
packageManager.getApplicationEnabledSetting(
associatedApp.packageName, userId);
if (associatedAppEnabledSetting
== PackageManager.COMPONENT_ENABLED_STATE_DEFAULT
&& (associatedApp.flags
& ApplicationInfo.FLAG_INSTALLED) != 0) {
@@ -256,8 +272,7 @@ public final class CarrierAppUtils {
// Mark the execution so we do not disable apps again.
if (!hasRunOnce) {
Settings.Secure.putIntForUser(
contentResolver, Settings.Secure.CARRIER_APPS_HANDLED, 1, userId);
Settings.Secure.putInt(contentResolver, Settings.Secure.CARRIER_APPS_HANDLED, 1);
}
if (!enabledCarrierPackages.isEmpty()) {
@@ -348,6 +363,31 @@ public final class CarrierAppUtils {
return apps;
}
private static List<ApplicationInfo> getDefaultNotUpdatedCarrierAppCandidatesHelper(
IPackageManager packageManager,
int userId,
ArraySet<String> systemCarrierAppsDisabledUntilUsed) {
if (systemCarrierAppsDisabledUntilUsed == null) {
return null;
}
int size = systemCarrierAppsDisabledUntilUsed.size();
if (size == 0) {
return null;
}
List<ApplicationInfo> apps = new ArrayList<>(size);
for (int i = 0; i < size; i++) {
String packageName = systemCarrierAppsDisabledUntilUsed.valueAt(i);
ApplicationInfo ai =
getApplicationInfoIfNotUpdatedSystemApp(packageManager, userId, packageName);
if (ai != null) {
apps.add(ai);
}
}
return apps;
}
private static Map<String, List<ApplicationInfo>> getDefaultCarrierAssociatedAppsHelper(
IPackageManager packageManager,
int userId,
@@ -360,11 +400,11 @@ public final class CarrierAppUtils {
systemCarrierAssociatedAppsDisabledUntilUsed.valueAt(i);
for (int j = 0; j < associatedAppPackages.size(); j++) {
ApplicationInfo ai =
getApplicationInfoIfSystemApp(
getApplicationInfoIfNotUpdatedSystemApp(
packageManager, userId, associatedAppPackages.get(j));
// Only update enabled state for the app on /system. Once it has been updated we
// shouldn't touch it.
if (ai != null && !ai.isUpdatedSystemApp()) {
if (ai != null) {
List<ApplicationInfo> appList = associatedApps.get(carrierAppPackage);
if (appList == null) {
appList = new ArrayList<>();
@@ -377,6 +417,26 @@ public final class CarrierAppUtils {
return associatedApps;
}
@Nullable
private static ApplicationInfo getApplicationInfoIfNotUpdatedSystemApp(
IPackageManager packageManager,
int userId,
String packageName) {
try {
ApplicationInfo ai = packageManager.getApplicationInfo(packageName,
PackageManager.MATCH_DISABLED_UNTIL_USED_COMPONENTS
| PackageManager.MATCH_HIDDEN_UNTIL_INSTALLED_COMPONENTS
| PackageManager.MATCH_SYSTEM_ONLY
| PackageManager.MATCH_FACTORY_ONLY, userId);
if (ai != null) {
return ai;
}
} catch (RemoteException e) {
Log.w(TAG, "Could not reach PackageManager", e);
}
return null;
}
@Nullable
private static ApplicationInfo getApplicationInfoIfSystemApp(
IPackageManager packageManager,
@@ -385,8 +445,9 @@ public final class CarrierAppUtils {
try {
ApplicationInfo ai = packageManager.getApplicationInfo(packageName,
PackageManager.MATCH_DISABLED_UNTIL_USED_COMPONENTS
| PackageManager.MATCH_HIDDEN_UNTIL_INSTALLED_COMPONENTS, userId);
if (ai != null && ai.isSystemApp()) {
| PackageManager.MATCH_HIDDEN_UNTIL_INSTALLED_COMPONENTS
| PackageManager.MATCH_SYSTEM_ONLY, userId);
if (ai != null) {
return ai;
}
} catch (RemoteException e) {

View File

@@ -365,7 +365,6 @@ public final class TelephonyPermissions {
private static boolean reportAccessDeniedToReadIdentifiers(Context context, int subId, int pid,
int uid, String callingPackage, String message) {
boolean isPreinstalled = false;
boolean isPrivApp = false;
ApplicationInfo callingPackageInfo = null;
try {
callingPackageInfo = context.getPackageManager().getApplicationInfoAsUser(
@@ -373,9 +372,6 @@ public final class TelephonyPermissions {
if (callingPackageInfo != null) {
if (callingPackageInfo.isSystemApp()) {
isPreinstalled = true;
if (callingPackageInfo.isPrivilegedApp()) {
isPrivApp = true;
}
}
}
} catch (PackageManager.NameNotFoundException e) {
@@ -398,10 +394,10 @@ public final class TelephonyPermissions {
}
invokedMethods.add(message);
StatsLog.write(StatsLog.DEVICE_IDENTIFIER_ACCESS_DENIED, callingPackage, message,
isPreinstalled, isPrivApp);
isPreinstalled, false);
}
Log.w(LOG_TAG, "reportAccessDeniedToReadIdentifiers:" + callingPackage + ":" + message
+ ":isPreinstalled=" + isPreinstalled + ":isPrivApp=" + isPrivApp);
+ ":isPreinstalled=" + isPreinstalled);
// if the target SDK is pre-Q then check if the calling package would have previously
// had access to device identifiers.
if (callingPackageInfo != null && (

View File

@@ -28,6 +28,7 @@ import android.os.RemoteException;
import android.os.SystemProperties;
import java.io.PrintWriter;
import java.util.function.Supplier;
/**
* This class provides various util functions
@@ -74,6 +75,42 @@ public final class TelephonyUtils {
throw new IllegalStateException("Missing ComponentInfo!");
}
/**
* Convenience method for running the provided action enclosed in
* {@link Binder#clearCallingIdentity}/{@link Binder#restoreCallingIdentity}
*
* Any exception thrown by the given action will need to be handled by caller.
*
*/
public static void runWithCleanCallingIdentity(
@NonNull Runnable action) {
long callingIdentity = Binder.clearCallingIdentity();
try {
action.run();
} finally {
Binder.restoreCallingIdentity(callingIdentity);
}
}
/**
* Convenience method for running the provided action enclosed in
* {@link Binder#clearCallingIdentity}/{@link Binder#restoreCallingIdentity} and return
* the result.
*
* Any exception thrown by the given action will need to be handled by caller.
*
*/
public static <T> T runWithCleanCallingIdentity(
@NonNull Supplier<T> action) {
long callingIdentity = Binder.clearCallingIdentity();
try {
return action.get();
} finally {
Binder.restoreCallingIdentity(callingIdentity);
}
}
/**
* Filter values in bundle to only basic types.
*/

View File

@@ -2973,7 +2973,6 @@ public class CarrierConfigManager {
/**
* Controls hysteresis time in milli seconds for which OpportunisticNetworkService
* will wait before switching data from opportunistic network to primary network.
* @hide
*/
public static final String KEY_OPPORTUNISTIC_NETWORK_DATA_SWITCH_EXIT_HYSTERESIS_TIME_LONG =
"opportunistic_network_data_switch_exit_hysteresis_time_long";
@@ -2981,17 +2980,58 @@ public class CarrierConfigManager {
/**
* Controls whether to do ping test before switching data to opportunistic network.
* This carrier config is used to disable this feature.
* @hide
*/
public static final String KEY_PING_TEST_BEFORE_DATA_SWITCH_BOOL =
"ping_test_before_data_switch_bool";
/**
* Controls time in milliseconds until DcTracker reevaluates 5G connection state.
* @hide
*/
public static final String KEY_5G_WATCHDOG_TIME_MS_LONG =
"5g_watchdog_time_long";
/**
* Controls whether to switch data to primary from opportunistic subscription
* if primary is out of service. This control only affects system or 1st party app
* initiated data switch, but will not override data switch initiated by privileged carrier apps
* This carrier config is used to disable this feature.
*/
public static final String KEY_SWITCH_DATA_TO_PRIMARY_IF_PRIMARY_IS_OOS_BOOL =
"switch_data_to_primary_if_primary_is_oos_bool";
/**
* Controls the ping pong determination of opportunistic network.
* If opportunistic network is determined as out of service or below
* #KEY_OPPORTUNISTIC_NETWORK_EXIT_THRESHOLD_RSRP_INT or
* #KEY_OPPORTUNISTIC_NETWORK_EXIT_THRESHOLD_RSSNR_INT within
* #KEY_OPPORTUNISTIC_NETWORK_PING_PONG_TIME_LONG of switching to opportunistic network,
* it will be determined as ping pong situation by system app or 1st party app.
*/
public static final String KEY_OPPORTUNISTIC_NETWORK_PING_PONG_TIME_LONG =
"opportunistic_network_ping_pong_time_long";
/**
* Controls back off time in milli seconds for switching back to
* opportunistic subscription. This time will be added to
* {@link CarrierConfigManager#KEY_OPPORTUNISTIC_NETWORK_DATA_SWITCH_HYSTERESIS_TIME_LONG} to
* determine hysteresis time if there is ping pong situation
* (determined by system app or 1st party app) between primary and opportunistic
* subscription. Ping ping situation is defined in
* #KEY_OPPORTUNISTIC_NETWORK_PING_PONG_TIME_LONG.
* If ping pong situation continuous #KEY_OPPORTUNISTIC_NETWORK_BACKOFF_TIME_LONG
* will be added to previously determined hysteresis time.
*/
public static final String KEY_OPPORTUNISTIC_NETWORK_BACKOFF_TIME_LONG =
"opportunistic_network_backoff_time_long";
/**
* Controls the max back off time in milli seconds for switching back to
* opportunistic subscription.
* This time will be the max hysteresis that can be determined irrespective of there is
* continuous ping pong situation or not as described in
* #KEY_OPPORTUNISTIC_NETWORK_PING_PONG_TIME_LONG and
* #KEY_OPPORTUNISTIC_NETWORK_BACKOFF_TIME_LONG.
*/
public static final String KEY_OPPORTUNISTIC_NETWORK_MAX_BACKOFF_TIME_LONG =
"opportunistic_network_max_backoff_time_long";
/**
* Indicates zero or more emergency number prefix(es), because some carrier requires
@@ -3035,7 +3075,6 @@ public class CarrierConfigManager {
* validation result, this value defines customized value of how long we wait for validation
* success before we fail and revoke the switch.
* Time out is in milliseconds.
* @hide
*/
public static final String KEY_DATA_SWITCH_VALIDATION_TIMEOUT_LONG =
"data_switch_validation_timeout_long";
@@ -3816,6 +3855,13 @@ public class CarrierConfigManager {
sDefaults.putBoolean(KEY_PING_TEST_BEFORE_DATA_SWITCH_BOOL, true);
/* Default value is 1 hour. */
sDefaults.putLong(KEY_5G_WATCHDOG_TIME_MS_LONG, 3600000);
sDefaults.putBoolean(KEY_SWITCH_DATA_TO_PRIMARY_IF_PRIMARY_IS_OOS_BOOL, true);
/* Default value is 60 seconds. */
sDefaults.putLong(KEY_OPPORTUNISTIC_NETWORK_PING_PONG_TIME_LONG, 60000);
/* Default value is 10 seconds. */
sDefaults.putLong(KEY_OPPORTUNISTIC_NETWORK_BACKOFF_TIME_LONG, 10000);
/* Default value is 60 seconds. */
sDefaults.putLong(KEY_OPPORTUNISTIC_NETWORK_MAX_BACKOFF_TIME_LONG, 60000);
sDefaults.putAll(Gps.getDefaults());
sDefaults.putIntArray(KEY_CDMA_ENHANCED_ROAMING_INDICATOR_FOR_HOME_NETWORK_INT_ARRAY,
new int[] {

View File

@@ -20,10 +20,10 @@ import android.annotation.IntDef;
import android.os.Parcel;
import android.os.Parcelable;
import java.util.ArrayList;
import java.util.Arrays;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.Arrays;
/**
* Defines a request to peform a network scan.
@@ -221,9 +221,15 @@ public final class NetworkScanRequest implements Parcelable {
private NetworkScanRequest(Parcel in) {
mScanType = in.readInt();
mSpecifiers = (RadioAccessSpecifier[]) in.readParcelableArray(
Object.class.getClassLoader(),
RadioAccessSpecifier.class);
Parcelable[] tempSpecifiers = in.readParcelableArray(Object.class.getClassLoader());
if (tempSpecifiers != null) {
mSpecifiers = new RadioAccessSpecifier[tempSpecifiers.length];
for (int i = 0; i < tempSpecifiers.length; i++) {
mSpecifiers[i] = (RadioAccessSpecifier) tempSpecifiers[i];
}
} else {
mSpecifiers = null;
}
mSearchPeriodicity = in.readInt();
mMaxSearchTime = in.readInt();
mIncrementalResults = in.readBoolean();

View File

@@ -85,18 +85,18 @@ public final class PhoneNumberRange implements Parcelable {
}
private PhoneNumberRange(Parcel in) {
mCountryCode = in.readStringNoHelper();
mPrefix = in.readStringNoHelper();
mLowerBound = in.readStringNoHelper();
mUpperBound = in.readStringNoHelper();
mCountryCode = in.readString();
mPrefix = in.readString();
mLowerBound = in.readString();
mUpperBound = in.readString();
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeStringNoHelper(mCountryCode);
dest.writeStringNoHelper(mPrefix);
dest.writeStringNoHelper(mLowerBound);
dest.writeStringNoHelper(mUpperBound);
dest.writeString(mCountryCode);
dest.writeString(mPrefix);
dest.writeString(mLowerBound);
dest.writeString(mUpperBound);
}
@Override

View File

@@ -16,8 +16,6 @@
package android.telephony;
import com.android.telephony.Rlog;
import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.compat.annotation.UnsupportedAppUsage;
@@ -40,6 +38,7 @@ import android.util.DisplayMetrics;
import android.util.Log;
import com.android.internal.telephony.util.TelephonyUtils;
import com.android.telephony.Rlog;
import java.util.ArrayList;
import java.util.Arrays;
@@ -685,8 +684,8 @@ public class SubscriptionInfo implements Parcelable {
int id = source.readInt();
String iccId = source.readString();
int simSlotIndex = source.readInt();
CharSequence displayName = source.readCharSequence();
CharSequence carrierName = source.readCharSequence();
CharSequence displayName = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
CharSequence carrierName = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
int nameSource = source.readInt();
int iconTint = source.readInt();
String number = source.readString();
@@ -705,8 +704,8 @@ public class SubscriptionInfo implements Parcelable {
int carrierid = source.readInt();
int profileClass = source.readInt();
int subType = source.readInt();
String[] ehplmns = source.readStringArray();
String[] hplmns = source.readStringArray();
String[] ehplmns = source.createStringArray();
String[] hplmns = source.createStringArray();
String groupOwner = source.readString();
UiccAccessRule[] carrierConfigAccessRules = source.createTypedArray(
UiccAccessRule.CREATOR);
@@ -732,8 +731,8 @@ public class SubscriptionInfo implements Parcelable {
dest.writeInt(mId);
dest.writeString(mIccId);
dest.writeInt(mSimSlotIndex);
dest.writeCharSequence(mDisplayName);
dest.writeCharSequence(mCarrierName);
TextUtils.writeToParcel(mDisplayName, dest, 0);
TextUtils.writeToParcel(mCarrierName, dest, 0);
dest.writeInt(mNameSource);
dest.writeInt(mIconTint);
dest.writeString(mNumber);

View File

@@ -9835,7 +9835,8 @@ public class TelephonyManager {
* {@link android.telephony.ModemActivityInfo} object.
* @hide
*/
public void requestModemActivityInfo(ResultReceiver result) {
@SystemApi
public void requestModemActivityInfo(@NonNull ResultReceiver result) {
try {
ITelephony service = getITelephony();
if (service != null) {

View File

@@ -163,9 +163,13 @@ public class ImsMmTelManager implements RegistrationManager {
public void onCapabilitiesStatusChanged(int config) {
if (mLocalCallback == null) return;
Binder.withCleanCallingIdentity(() ->
mExecutor.execute(() -> mLocalCallback.onCapabilitiesStatusChanged(
new MmTelFeature.MmTelCapabilities(config))));
long callingIdentity = Binder.clearCallingIdentity();
try {
mExecutor.execute(() -> mLocalCallback.onCapabilitiesStatusChanged(
new MmTelFeature.MmTelCapabilities(config)));
} finally {
restoreCallingIdentity(callingIdentity);
}
}
@Override

View File

@@ -75,9 +75,13 @@ public class ImsRcsManager implements RegistrationManager {
public void onCapabilitiesStatusChanged(int config) {
if (mLocalCallback == null) return;
Binder.withCleanCallingIdentity(() ->
mExecutor.execute(() -> mLocalCallback.onAvailabilityChanged(
new RcsFeature.RcsImsCapabilities(config))));
long callingIdentity = Binder.clearCallingIdentity();
try {
mExecutor.execute(() -> mLocalCallback.onAvailabilityChanged(
new RcsFeature.RcsImsCapabilities(config)));
} finally {
restoreCallingIdentity(callingIdentity);
}
}
@Override

View File

@@ -791,17 +791,24 @@ public class ProvisioningManager {
@Override
public final void onIntConfigChanged(int item, int value) {
Binder.withCleanCallingIdentity(() ->
mExecutor.execute(() ->
mLocalConfigurationCallback.onProvisioningIntChanged(item, value)));
long callingIdentity = Binder.clearCallingIdentity();
try {
mExecutor.execute(() ->
mLocalConfigurationCallback.onProvisioningIntChanged(item, value));
} finally {
restoreCallingIdentity(callingIdentity);
}
}
@Override
public final void onStringConfigChanged(int item, String value) {
Binder.withCleanCallingIdentity(() ->
mExecutor.execute(() ->
mLocalConfigurationCallback.onProvisioningStringChanged(item,
value)));
long callingIdentity = Binder.clearCallingIdentity();
try {
mExecutor.execute(() ->
mLocalConfigurationCallback.onProvisioningStringChanged(item, value));
} finally {
restoreCallingIdentity(callingIdentity);
}
}
private void setExecutor(Executor executor) {

View File

@@ -251,15 +251,22 @@ public class RcsUceAdapter {
IRcsUceControllerCallback internalCallback = new IRcsUceControllerCallback.Stub() {
@Override
public void onCapabilitiesReceived(List<RcsContactUceCapability> contactCapabilities) {
Binder.withCleanCallingIdentity(() ->
executor.execute(() ->
c.onCapabilitiesReceived(contactCapabilities)));
long callingIdentity = Binder.clearCallingIdentity();
try {
executor.execute(() ->
c.onCapabilitiesReceived(contactCapabilities));
} finally {
restoreCallingIdentity(callingIdentity);
}
}
@Override
public void onError(int errorCode) {
Binder.withCleanCallingIdentity(() ->
executor.execute(() ->
c.onError(errorCode)));
long callingIdentity = Binder.clearCallingIdentity();
try {
executor.execute(() -> c.onError(errorCode));
} finally {
restoreCallingIdentity(callingIdentity);
}
}
};

View File

@@ -105,41 +105,62 @@ public interface RegistrationManager {
public void onRegistered(int imsRadioTech) {
if (mLocalCallback == null) return;
Binder.withCleanCallingIdentity(() -> mExecutor.execute(() ->
mLocalCallback.onRegistered(getAccessType(imsRadioTech))));
long callingIdentity = Binder.clearCallingIdentity();
try {
mExecutor.execute(() ->
mLocalCallback.onRegistered(getAccessType(imsRadioTech)));
} finally {
restoreCallingIdentity(callingIdentity);
}
}
@Override
public void onRegistering(int imsRadioTech) {
if (mLocalCallback == null) return;
Binder.withCleanCallingIdentity(() -> mExecutor.execute(() ->
mLocalCallback.onRegistering(getAccessType(imsRadioTech))));
long callingIdentity = Binder.clearCallingIdentity();
try {
mExecutor.execute(() ->
mLocalCallback.onRegistering(getAccessType(imsRadioTech)));
} finally {
restoreCallingIdentity(callingIdentity);
}
}
@Override
public void onDeregistered(ImsReasonInfo info) {
if (mLocalCallback == null) return;
Binder.withCleanCallingIdentity(() ->
mExecutor.execute(() -> mLocalCallback.onUnregistered(info)));
long callingIdentity = Binder.clearCallingIdentity();
try {
mExecutor.execute(() -> mLocalCallback.onUnregistered(info));
} finally {
restoreCallingIdentity(callingIdentity);
}
}
@Override
public void onTechnologyChangeFailed(int imsRadioTech, ImsReasonInfo info) {
if (mLocalCallback == null) return;
Binder.withCleanCallingIdentity(() ->
mExecutor.execute(() -> mLocalCallback.onTechnologyChangeFailed(
getAccessType(imsRadioTech), info)));
long callingIdentity = Binder.clearCallingIdentity();
try {
mExecutor.execute(() -> mLocalCallback.onTechnologyChangeFailed(
getAccessType(imsRadioTech), info));
} finally {
restoreCallingIdentity(callingIdentity);
}
}
public void onSubscriberAssociatedUriChanged(Uri[] uris) {
if (mLocalCallback == null) return;
Binder.withCleanCallingIdentity(() ->
mExecutor.execute(() ->
mLocalCallback.onSubscriberAssociatedUriChanged(uris)));
long callingIdentity = Binder.clearCallingIdentity();
try {
mExecutor.execute(() -> mLocalCallback.onSubscriberAssociatedUriChanged(uris));
} finally {
restoreCallingIdentity(callingIdentity);
}
}
private void setExecutor(Executor executor) {

View File

@@ -22,7 +22,6 @@ import android.annotation.SystemApi;
import android.annotation.TestApi;
import android.content.Context;
import android.os.IInterface;
import android.os.RemoteCallbackList;
import android.os.RemoteException;
import android.telephony.SubscriptionManager;
import android.telephony.ims.aidl.IImsCapabilityCallback;
@@ -31,6 +30,7 @@ import android.util.Log;
import com.android.ims.internal.IImsFeatureStatusCallback;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.telephony.util.RemoteCallbackListExt;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -326,12 +326,12 @@ public abstract class ImsFeature {
/** @hide */
protected final Object mLock = new Object();
private final RemoteCallbackList<IImsFeatureStatusCallback> mStatusCallbacks =
new RemoteCallbackList<>();
private final RemoteCallbackListExt<IImsFeatureStatusCallback> mStatusCallbacks =
new RemoteCallbackListExt<>();
private @ImsState int mState = STATE_UNAVAILABLE;
private int mSlotId = SubscriptionManager.INVALID_SIM_SLOT_INDEX;
private final RemoteCallbackList<IImsCapabilityCallback> mCapabilityCallbacks =
new RemoteCallbackList<>();
private final RemoteCallbackListExt<IImsCapabilityCallback> mCapabilityCallbacks =
new RemoteCallbackListExt<>();
private Capabilities mCapabilityStatus = new Capabilities();
/**
@@ -412,7 +412,7 @@ public abstract class ImsFeature {
* Internal method called by ImsFeature when setFeatureState has changed.
*/
private void notifyFeatureState(@ImsState int state) {
mStatusCallbacks.broadcast((c) -> {
mStatusCallbacks.broadcastAction((c) -> {
try {
c.notifyImsFeatureStatus(state);
} catch (RemoteException e) {
@@ -491,7 +491,7 @@ public abstract class ImsFeature {
synchronized (mLock) {
mCapabilityStatus = caps.copy();
}
mCapabilityCallbacks.broadcast((callback) -> {
mCapabilityCallbacks.broadcastAction((callback) -> {
try {
callback.onCapabilitiesStatusChanged(caps.mCapabilities);
} catch (RemoteException e) {

View File

@@ -22,7 +22,6 @@ import android.annotation.NonNull;
import android.annotation.SystemApi;
import android.annotation.TestApi;
import android.net.Uri;
import android.os.Binder;
import android.os.RemoteException;
import android.telephony.ims.RcsContactUceCapability;
import android.telephony.ims.aidl.IImsCapabilityCallback;
@@ -33,7 +32,7 @@ import android.telephony.ims.stub.RcsPresenceExchangeImplBase;
import android.telephony.ims.stub.RcsSipOptionsImplBase;
import android.util.Log;
import com.android.internal.util.FunctionalUtils;
import com.android.internal.telephony.util.TelephonyUtils;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -43,6 +42,7 @@ import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
import java.util.function.Supplier;
/**
* Base implementation of the RcsFeature APIs. Any ImsService wishing to support RCS should extend
@@ -150,13 +150,13 @@ public class RcsFeature extends ImsFeature {
// Call the methods with a clean calling identity on the executor and wait indefinitely for
// the future to return.
private void executeMethodAsync(FunctionalUtils.ThrowingRunnable r, String errorLogName)
private void executeMethodAsync(Runnable r, String errorLogName)
throws RemoteException {
// call with a clean calling identity on the executor and wait indefinitely for the
// future to return.
try {
CompletableFuture.runAsync(
() -> Binder.withCleanCallingIdentity(r), mExecutor).join();
() -> TelephonyUtils.runWithCleanCallingIdentity(r), mExecutor).join();
} catch (CancellationException | CompletionException e) {
Log.w(LOG_TAG, "RcsFeatureBinder - " + errorLogName + " exception: "
+ e.getMessage());
@@ -164,12 +164,12 @@ public class RcsFeature extends ImsFeature {
}
}
private <T> T executeMethodAsyncForResult(FunctionalUtils.ThrowingSupplier<T> r,
private <T> T executeMethodAsyncForResult(Supplier<T> r,
String errorLogName) throws RemoteException {
// call with a clean calling identity on the executor and wait indefinitely for the
// future to return.
CompletableFuture<T> future = CompletableFuture.supplyAsync(
() -> Binder.withCleanCallingIdentity(r), mExecutor);
() -> TelephonyUtils.runWithCleanCallingIdentity(r), mExecutor);
try {
return future.get();
} catch (ExecutionException | InterruptedException e) {

View File

@@ -22,7 +22,6 @@ import android.annotation.SystemApi;
import android.annotation.TestApi;
import android.content.Context;
import android.os.PersistableBundle;
import android.os.RemoteCallbackList;
import android.os.RemoteException;
import android.telephony.ims.ProvisioningManager;
import android.telephony.ims.aidl.IImsConfig;
@@ -31,6 +30,7 @@ import android.util.Log;
import com.android.ims.ImsConfig;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.telephony.util.RemoteCallbackListExt;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -257,7 +257,8 @@ public class ImsConfigImplBase {
})
public @interface SetConfigResult {}
private final RemoteCallbackList<IImsConfigCallback> mCallbacks = new RemoteCallbackList<>();
private final RemoteCallbackListExt<IImsConfigCallback> mCallbacks =
new RemoteCallbackListExt<>();
ImsConfigStub mImsConfigStub;
/**
@@ -298,7 +299,7 @@ public class ImsConfigImplBase {
if (mCallbacks == null) {
return;
}
mCallbacks.broadcast(c -> {
mCallbacks.broadcastAction(c -> {
try {
c.onIntConfigChanged(item, value);
} catch (RemoteException e) {
@@ -312,7 +313,7 @@ public class ImsConfigImplBase {
if (mCallbacks == null) {
return;
}
mCallbacks.broadcast(c -> {
mCallbacks.broadcastAction(c -> {
try {
c.onStringConfigChanged(item, value);
} catch (RemoteException e) {

View File

@@ -20,7 +20,6 @@ import android.annotation.IntDef;
import android.annotation.SystemApi;
import android.annotation.TestApi;
import android.net.Uri;
import android.os.RemoteCallbackList;
import android.os.RemoteException;
import android.telephony.ims.ImsReasonInfo;
import android.telephony.ims.RegistrationManager;
@@ -29,6 +28,7 @@ import android.telephony.ims.aidl.IImsRegistrationCallback;
import android.util.Log;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.telephony.util.RemoteCallbackListExt;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -94,8 +94,8 @@ public class ImsRegistrationImplBase {
}
};
private final RemoteCallbackList<IImsRegistrationCallback> mCallbacks
= new RemoteCallbackList<>();
private final RemoteCallbackListExt<IImsRegistrationCallback> mCallbacks =
new RemoteCallbackListExt<>();
private final Object mLock = new Object();
// Locked on mLock
private @ImsRegistrationTech
@@ -129,7 +129,7 @@ public class ImsRegistrationImplBase {
*/
public final void onRegistered(@ImsRegistrationTech int imsRadioTech) {
updateToState(imsRadioTech, RegistrationManager.REGISTRATION_STATE_REGISTERED);
mCallbacks.broadcast((c) -> {
mCallbacks.broadcastAction((c) -> {
try {
c.onRegistered(imsRadioTech);
} catch (RemoteException e) {
@@ -147,7 +147,7 @@ public class ImsRegistrationImplBase {
*/
public final void onRegistering(@ImsRegistrationTech int imsRadioTech) {
updateToState(imsRadioTech, RegistrationManager.REGISTRATION_STATE_REGISTERING);
mCallbacks.broadcast((c) -> {
mCallbacks.broadcastAction((c) -> {
try {
c.onRegistering(imsRadioTech);
} catch (RemoteException e) {
@@ -175,7 +175,7 @@ public class ImsRegistrationImplBase {
*/
public final void onDeregistered(ImsReasonInfo info) {
updateToDisconnectedState(info);
mCallbacks.broadcast((c) -> {
mCallbacks.broadcastAction((c) -> {
try {
c.onDeregistered(info);
} catch (RemoteException e) {
@@ -194,7 +194,7 @@ public class ImsRegistrationImplBase {
*/
public final void onTechnologyChangeFailed(@ImsRegistrationTech int imsRadioTech,
ImsReasonInfo info) {
mCallbacks.broadcast((c) -> {
mCallbacks.broadcastAction((c) -> {
try {
c.onTechnologyChangeFailed(imsRadioTech, info);
} catch (RemoteException e) {
@@ -210,7 +210,7 @@ public class ImsRegistrationImplBase {
* @param uris
*/
public final void onSubscriberAssociatedUriChanged(Uri[] uris) {
mCallbacks.broadcast((c) -> {
mCallbacks.broadcastAction((c) -> {
try {
c.onSubscriberAssociatedUriChanged(uris);
} catch (RemoteException e) {

View File

@@ -0,0 +1,46 @@
/*
* 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.os.IInterface;
import android.os.RemoteCallbackList;
import java.util.function.Consumer;
/**
* Extension of RemoteCallbackList
* @param <E> defines the type of registered callbacks
*/
public class RemoteCallbackListExt<E extends IInterface> extends RemoteCallbackList<E> {
/**
* Performs {@code action} on each callback, calling
* {@link RemoteCallbackListExt#beginBroadcast()}
* /{@link RemoteCallbackListExt#finishBroadcast()} before/after looping
* @param action to be performed on each callback
*
*/
public void broadcastAction(Consumer<E> action) {
int itemCount = beginBroadcast();
try {
for (int i = 0; i < itemCount; i++) {
action.accept(getBroadcastItem(i));
}
} finally {
finishBroadcast();
}
}
}