Files
frameworks_base/telephony/java/com/android/internal/telephony/PhoneConstantConversions.java
Nathan Harold d9b5dda461 Expose PreciseDataConnectionState to Public API
1) Remove Unused Parameters for onDataConnectionState:
The data connection state broadcast includes a number of
parameters that are never used anywhere. To prepare for
updated code that relies on PreciseDataConnectionState,
remove the unused parameters that were internal-only and
included in the broadcast.

-LinkProperties
-NetworkCapabilities
-DataRoaming
-DataAllowed
-Interface name

2) Add Disconnecting State for Data Connections

Add a disconnecting state to correct a mismatch
between the internal and externally visible enums.

This will allow apps to know when connections are
in the process of being torn down, which in the case
of radio link issues could be as much as 15 seconds.

3) Expose PreciseDataConnection for Carrier Apps

Exposes the PSL for PreciseDataConnectionState along
with existing fields in the PreciseDataConnectionState
class.

-Make PreciseDataConnectionState public along with some
 of its fields.
-Expose onPreciseDataConnectionStateChanged.
-Add onPreciseDataConnectionStatesChanged to provide PDCS
 for all APNs in one cohesive batch.

4) Cache PreciseDataConnectionState by APN Type

In telephony registry, multiple different APN types
are all piped through the same cache entry, so every
time any APN changes relative to the previous type,
it triggers an update. This also means that when
a registrant requests the data connection state, only
the most recent type's state is updated.

This change caches entries in TelephonyRegistry based
on the APN's type (specifically the type among types
which triggered the change).

Bug: 143083105
Test: make update-api && make offline-sdk-docs
      (no functional change in this CL).
Test: atest FrameworksTelephonyTests

Merged-In: Ib6a769f5a0cae923ca47a842733bd28755a90ed5
Change-Id: Ib6a769f5a0cae923ca47a842733bd28755a90ed5
(cherry picked from commit 4d340f12c9)
(cherry picked from commit c95b4e5421)
2019-12-20 10:06:54 -08:00

92 lines
3.2 KiB
Java

/*
* Copyright (C) 2006 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;
import android.telephony.TelephonyManager;
import com.android.internal.telephony.PhoneConstants;
public class PhoneConstantConversions {
/**
* Convert the {@link PhoneConstants.State} enum into the TelephonyManager.CALL_STATE_*
* constants for the public API.
*/
public static int convertCallState(PhoneConstants.State state) {
switch (state) {
case RINGING:
return TelephonyManager.CALL_STATE_RINGING;
case OFFHOOK:
return TelephonyManager.CALL_STATE_OFFHOOK;
default:
return TelephonyManager.CALL_STATE_IDLE;
}
}
/**
* Convert the TelephonyManager.CALL_STATE_* constants into the
* {@link PhoneConstants.State} enum for the public API.
*/
public static PhoneConstants.State convertCallState(int state) {
switch (state) {
case TelephonyManager.CALL_STATE_RINGING:
return PhoneConstants.State.RINGING;
case TelephonyManager.CALL_STATE_OFFHOOK:
return PhoneConstants.State.OFFHOOK;
default:
return PhoneConstants.State.IDLE;
}
}
/**
* Convert the {@link PhoneConstants.DataState} enum into the TelephonyManager.DATA_* constants
* for the public API.
*/
public static int convertDataState(PhoneConstants.DataState state) {
switch (state) {
case CONNECTING:
return TelephonyManager.DATA_CONNECTING;
case CONNECTED:
return TelephonyManager.DATA_CONNECTED;
case SUSPENDED:
return TelephonyManager.DATA_SUSPENDED;
case DISCONNECTING:
return TelephonyManager.DATA_DISCONNECTING;
default:
return TelephonyManager.DATA_DISCONNECTED;
}
}
/**
* Convert the TelephonyManager.DATA_* constants into {@link PhoneConstants.DataState} enum
* for the public API.
*/
public static PhoneConstants.DataState convertDataState(int state) {
switch (state) {
case TelephonyManager.DATA_CONNECTING:
return PhoneConstants.DataState.CONNECTING;
case TelephonyManager.DATA_CONNECTED:
return PhoneConstants.DataState.CONNECTED;
case TelephonyManager.DATA_SUSPENDED:
return PhoneConstants.DataState.SUSPENDED;
case TelephonyManager.DATA_DISCONNECTING:
return PhoneConstants.DataState.DISCONNECTING;
default:
return PhoneConstants.DataState.DISCONNECTED;
}
}
}