diff options
author | Andrew Flynn <flynn@google.com> | 2015-06-08 17:24:46 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-06-08 17:25:12 +0000 |
commit | 2429e6a8d96a4eba83e22c35595fa05e0f5e51f2 (patch) | |
tree | e9514ec66a89836bf16777626187ba0f7c5f6876 /core/java | |
parent | 7fa228f4eaa774df9e925e0c037f0fa78caafafc (diff) | |
parent | 7f8be9d89b7f294bf5e5d377908a5c74d2f4968f (diff) | |
download | frameworks_base-2429e6a8d96a4eba83e22c35595fa05e0f5e51f2.zip frameworks_base-2429e6a8d96a4eba83e22c35595fa05e0f5e51f2.tar.gz frameworks_base-2429e6a8d96a4eba83e22c35595fa05e0f5e51f2.tar.bz2 |
Merge "notifyCarrierNetworkChange:TelephonyManager->CarrierService" into mnc-dev
Diffstat (limited to 'core/java')
-rw-r--r-- | core/java/android/service/carrier/CarrierService.java | 48 |
1 files changed, 43 insertions, 5 deletions
diff --git a/core/java/android/service/carrier/CarrierService.java b/core/java/android/service/carrier/CarrierService.java index 4a4a375..4d21939 100644 --- a/core/java/android/service/carrier/CarrierService.java +++ b/core/java/android/service/carrier/CarrierService.java @@ -14,10 +14,15 @@ package android.service.carrier; +import android.annotation.CallSuper; import android.app.Service; import android.content.Intent; import android.os.IBinder; import android.os.PersistableBundle; +import android.os.RemoteException; +import android.os.ServiceManager; + +import com.android.internal.telephony.ITelephonyRegistry; /** * A service that exposes carrier-specific functionality to the system. @@ -45,10 +50,16 @@ public abstract class CarrierService extends Service { public static final String CONFIG_SERVICE_INTERFACE = "android.service.carrier.ConfigService"; public static final String BIND_SERVICE_INTERFACE = "android.service.carrier.BindService"; + private static ITelephonyRegistry sRegistry; + private final ICarrierService.Stub mStubWrapper; public CarrierService() { mStubWrapper = new ICarrierServiceWrapper(); + if (sRegistry == null) { + sRegistry = ITelephonyRegistry.Stub.asInterface( + ServiceManager.getService("telephony.registry")); + } } /** @@ -83,9 +94,39 @@ public abstract class CarrierService extends Service { */ public abstract PersistableBundle onLoadConfig(CarrierIdentifier id); - /** @hide */ + /** + * Informs the system of an intentional upcoming carrier network change by + * a carrier app. This call is optional and is only used to allow the + * system to provide alternative UI while telephony is performing an action + * that may result in intentional, temporary network lack of connectivity. + * <p> + * Based on the active parameter passed in, this method will either show or + * hide the alternative UI. There is no timeout associated with showing + * this UX, so a carrier app must be sure to call with active set to false + * sometime after calling with it set to true. + * <p> + * Requires Permission: + * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} + * Or the calling app has carrier privileges. + * @see {@link android.telephony.TelephonyManager#hasCarrierPrivileges} + * + * @param active Whether the carrier network change is or shortly will be + * active. Set this value to true to begin showing + * alternative UI and false to stop. + */ + public final void notifyCarrierNetworkChange(boolean active) { + try { + if (sRegistry != null) sRegistry.notifyCarrierNetworkChange(active); + } catch (RemoteException | NullPointerException ex) {} + } + + /** + * If overriding this method, call through to the super method for any unknown actions. + * {@inheritDoc} + */ @Override - public final IBinder onBind(Intent intent) { + @CallSuper + public IBinder onBind(Intent intent) { switch (intent.getAction()) { case CONFIG_SERVICE_INTERFACE: case BIND_SERVICE_INTERFACE: @@ -98,11 +139,8 @@ public abstract class CarrierService extends Service { /** * A wrapper around ICarrierService that forwards calls to implementations of * {@link CarrierService}. - * - * @hide */ private class ICarrierServiceWrapper extends ICarrierService.Stub { - @Override public PersistableBundle getCarrierConfig(CarrierIdentifier id) { return CarrierService.this.onLoadConfig(id); |