Merge changes from topic "barring-info"

* changes:
  Add a BARRING_TYPE_UNKNOWN for Unreported Barring
  Add Callback to notify changes of barring status
This commit is contained in:
Nathan Harold
2020-01-16 00:06:07 +00:00
committed by Android (Google) Code Review
11 changed files with 590 additions and 0 deletions

View File

@@ -384,6 +384,17 @@ public class PhoneStateListener {
@RequiresPermission(Manifest.permission.READ_PHONE_STATE)
public static final int LISTEN_REGISTRATION_FAILURE = 0x40000000;
/**
* Listen for Barring Information for the current registered / camped cell.
*
* <p>Requires permission {@link android.Manifest.permission#READ_PHONE_STATE} or the calling
* app has carrier privileges (see {@link TelephonyManager#hasCarrierPrivileges}).
*
* @see #onBarringInfoChanged()
*/
@RequiresPermission(Manifest.permission.READ_PHONE_STATE)
public static final int LISTEN_BARRING_INFO = 0x80000000;
/*
* Subscription used to listen to the phone state changes
* @hide
@@ -978,6 +989,20 @@ public class PhoneStateListener {
// default implementation empty
}
/**
* Report updated barring information for the current camped/registered cell.
*
* <p>Barring info is provided for all services applicable to the current camped/registered
* cell, for the registered PLMN and current access class/access category.
*
* @param barringInfo for all services on the current cell.
*
* @see android.telephony.BarringInfo
*/
public void onBarringInfoChanged(@NonNull BarringInfo barringInfo) {
// default implementation empty
}
/**
* The callback methods need to be called on the handler thread where
* this object was created. If the binder did that for us it'd be nice.
@@ -1262,6 +1287,14 @@ public class PhoneStateListener {
cellIdentity, chosenPlmn, domain, causeCode, additionalCauseCode)));
// default implementation empty
}
public void onBarringInfoChanged(BarringInfo barringInfo) {
PhoneStateListener psl = mPhoneStateListenerWeakRef.get();
if (psl == null) return;
Binder.withCleanCallingIdentity(
() -> mExecutor.execute(() -> psl.onBarringInfoChanged(barringInfo)));
}
}

View File

@@ -708,4 +708,21 @@ public class TelephonyRegistryManager {
} catch (RemoteException ex) {
}
}
/**
* Notify {@link BarringInfo} has changed for a specific subscription.
*
* @param slotIndex for the phone object that got updated barring info.
* @param subId for which the BarringInfo changed.
* @param barringInfo updated BarringInfo.
*/
public void notifyBarringInfoChanged(
int slotIndex, int subId, @NonNull BarringInfo barringInfo) {
try {
sRegistry.notifyBarringInfoChanged(slotIndex, subId, barringInfo);
} catch (RemoteException ex) {
// system server crash
}
}
}

View File

@@ -16,6 +16,7 @@
package com.android.internal.telephony;
import android.telephony.BarringInfo;
import android.telephony.CallAttributes;
import android.telephony.CellIdentity;
import android.telephony.CellInfo;
@@ -64,4 +65,5 @@ oneway interface IPhoneStateListener {
void onImsCallDisconnectCauseChanged(in ImsReasonInfo imsReasonInfo);
void onRegistrationFailed(in CellIdentity cellIdentity,
String chosenPlmn, int domain, int causeCode, int additionalCauseCode);
void onBarringInfoChanged(in BarringInfo barringInfo);
}

View File

@@ -19,6 +19,7 @@ package com.android.internal.telephony;
import android.content.Intent;
import android.net.LinkProperties;
import android.net.NetworkCapabilities;
import android.telephony.BarringInfo;
import android.telephony.CallQuality;
import android.telephony.CellIdentity;
import android.telephony.CellInfo;
@@ -99,4 +100,5 @@ interface ITelephonyRegistry {
void notifyImsDisconnectCause(int subId, in ImsReasonInfo imsReasonInfo);
void notifyRegistrationFailed(int slotIndex, int subId, in CellIdentity cellIdentity,
String chosenPlmn, int domain, int causeCode, int additionalCauseCode);
void notifyBarringInfoChanged(int slotIndex, int subId, in BarringInfo barringInfo);
}