summaryrefslogtreecommitdiffstats
path: root/core/java/android
diff options
context:
space:
mode:
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/app/SystemServiceRegistry.java8
-rw-r--r--core/java/android/content/Context.java13
-rw-r--r--core/java/android/service/carrier/CarrierConfigService.java104
-rw-r--r--core/java/android/service/carrier/CarrierIdentifier.aidl19
-rw-r--r--core/java/android/service/carrier/CarrierIdentifier.java117
-rw-r--r--core/java/android/service/carrier/ICarrierConfigService.aidl32
6 files changed, 293 insertions, 0 deletions
diff --git a/core/java/android/app/SystemServiceRegistry.java b/core/java/android/app/SystemServiceRegistry.java
index 4ede5b1..e446700 100644
--- a/core/java/android/app/SystemServiceRegistry.java
+++ b/core/java/android/app/SystemServiceRegistry.java
@@ -105,6 +105,7 @@ import android.hardware.fingerprint.IFingerprintService;
import android.service.persistentdata.IPersistentDataBlockService;
import android.service.persistentdata.PersistentDataBlockManager;
import android.telecom.TelecomManager;
+import android.telephony.CarrierConfigManager;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.util.Log;
@@ -420,6 +421,13 @@ final class SystemServiceRegistry {
return new SubscriptionManager(ctx.getOuterContext());
}});
+ registerService(Context.CARRIER_CONFIG_SERVICE, CarrierConfigManager.class,
+ new CachedServiceFetcher<CarrierConfigManager>() {
+ @Override
+ public CarrierConfigManager createService(ContextImpl ctx) {
+ return new CarrierConfigManager();
+ }});
+
registerService(Context.TELECOM_SERVICE, TelecomManager.class,
new CachedServiceFetcher<TelecomManager>() {
@Override
diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java
index 0cbf960..370f61c 100644
--- a/core/java/android/content/Context.java
+++ b/core/java/android/content/Context.java
@@ -2193,6 +2193,7 @@ public abstract class Context {
MEDIA_ROUTER_SERVICE,
TELEPHONY_SERVICE,
TELEPHONY_SUBSCRIPTION_SERVICE,
+ CARRIER_CONFIG_SERVICE,
TELECOM_SERVICE,
CLIPBOARD_SERVICE,
INPUT_METHOD_SERVICE,
@@ -2338,6 +2339,8 @@ public abstract class Context {
* @see android.telephony.TelephonyManager
* @see #TELEPHONY_SUBSCRIPTION_SERVICE
* @see android.telephony.SubscriptionManager
+ * @see #CARRIER_CONFIG_SERVICE
+ * @see android.telephony.CarrierConfigManager
* @see #INPUT_METHOD_SERVICE
* @see android.view.inputmethod.InputMethodManager
* @see #UI_MODE_SERVICE
@@ -2755,6 +2758,16 @@ public abstract class Context {
/**
* Use with {@link #getSystemService} to retrieve a
+ * {@link android.telephony.CarrierConfigManager} for reading carrier configuration values.
+ *
+ * @see #getSystemService
+ * @see android.telephony.CarrierConfigManager
+ */
+ public static final String CARRIER_CONFIG_SERVICE = "carrier_config";
+
+ /**
+ * Use with {@link #getSystemService} to retrieve a
+ * {@link android.text.ClipboardManager} for accessing and modifying
* {@link android.content.ClipboardManager} for accessing and modifying
* the contents of the global clipboard.
*
diff --git a/core/java/android/service/carrier/CarrierConfigService.java b/core/java/android/service/carrier/CarrierConfigService.java
new file mode 100644
index 0000000..1880d16
--- /dev/null
+++ b/core/java/android/service/carrier/CarrierConfigService.java
@@ -0,0 +1,104 @@
+/*
+ * Copyright (C) 2015 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 android.service.carrier;
+
+import android.app.Service;
+import android.content.Intent;
+import android.os.Bundle;
+import android.os.IBinder;
+
+/**
+ * A service that sets carrier configuration for telephony services.
+ * <p>
+ * To extend this class, you must declare the service in your manifest file to require the
+ * {@link android.Manifest.permission#BIND_CARRIER_CONFIG_SERVICE} permission and include an intent
+ * filter with the {@link #SERVICE_INTERFACE} action. For example:
+ * </p>
+ *
+ * <pre>{@code
+ * <service android:name=".MyCarrierConfigService"
+ * android:label="@string/service_name"
+ * android:permission="android.permission.BIND_CARRIER_CONFIG_SERVICE">
+ * <intent-filter>
+ * <action android:name="android.service.carrier.CarrierConfigService" />
+ * </intent-filter>
+ * </service>
+ * }</pre>
+ */
+public abstract class CarrierConfigService extends Service {
+
+ public static final String SERVICE_INTERFACE = "android.service.carrier.CarrierConfigService";
+
+ private final ICarrierConfigService.Stub mStubWrapper;
+
+ public CarrierConfigService() {
+ mStubWrapper = new ICarrierConfigServiceWrapper();
+ }
+
+ /**
+ * Override this method to set carrier configuration.
+ * <p>
+ * This method will be called by telephony services to get carrier-specific configuration
+ * values. The returned config will be saved by the system until,
+ * <ol>
+ * <li>The carrier app package is updated, or</li>
+ * <li>The carrier app requests a reload with
+ * {@link android.telephony.CarrierConfigManager#reloadCarrierConfigForSubId
+ * reloadCarrierConfigForSubId}.</li>
+ * </ol>
+ * This method can be called after a SIM card loads, which may be before or after boot.
+ * </p>
+ * <p>
+ * This method should not block for a long time. If expensive operations (e.g. network access)
+ * are required, this method can schedule the work and return null. Then, use
+ * {@link android.telephony.CarrierConfigManager#reloadCarrierConfigForSubId
+ * reloadCarrierConfigForSubId} to trigger a reload when the config is ready.
+ * </p>
+ * <p>
+ * Implementations should use the keys defined in {@link android.telephony.CarrierConfigManager
+ * CarrierConfigManager}. Any configuration values not set in the returned {@link Bundle} may be
+ * overridden by the system's default configuration service.
+ * </p>
+ *
+ * @param id contains details about the current carrier that can be used do decide what
+ * configuration values to return.
+ * @return a {@link Bundle} object containing the configuration or null if default values should
+ * be used.
+ */
+ public abstract Bundle onLoadConfig(CarrierIdentifier id);
+
+ /** @hide */
+ @Override
+ public final IBinder onBind(Intent intent) {
+ if (!SERVICE_INTERFACE.equals(intent.getAction())) {
+ return null;
+ }
+ return mStubWrapper;
+ }
+
+ /**
+ * A wrapper around ICarrierConfigService that forwards calls to implementations of
+ * {@link CarrierConfigService}.
+ *
+ * @hide
+ */
+ private class ICarrierConfigServiceWrapper extends ICarrierConfigService.Stub {
+
+ @Override
+ public Bundle getCarrierConfig(CarrierIdentifier id) {
+ return CarrierConfigService.this.onLoadConfig(id);
+ }
+ }
+}
diff --git a/core/java/android/service/carrier/CarrierIdentifier.aidl b/core/java/android/service/carrier/CarrierIdentifier.aidl
new file mode 100644
index 0000000..48b1398
--- /dev/null
+++ b/core/java/android/service/carrier/CarrierIdentifier.aidl
@@ -0,0 +1,19 @@
+/**
+ * Copyright (c) 2015, 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 android.service.carrier;
+
+parcelable CarrierIdentifier;
diff --git a/core/java/android/service/carrier/CarrierIdentifier.java b/core/java/android/service/carrier/CarrierIdentifier.java
new file mode 100644
index 0000000..495fea6
--- /dev/null
+++ b/core/java/android/service/carrier/CarrierIdentifier.java
@@ -0,0 +1,117 @@
+/**
+ * Copyright (c) 2015, 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 android.service.carrier;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+
+/**
+ * Used to pass info to CarrierConfigService implementations so they can decide what values to
+ * return.
+ */
+public class CarrierIdentifier implements Parcelable {
+
+ /** Used to create a {@link CarrierIdentifier} from a {@link Parcel}. */
+ public static final Creator<CarrierIdentifier> CREATOR = new Creator<CarrierIdentifier>() {
+ @Override
+ public CarrierIdentifier createFromParcel(Parcel parcel) {
+ return new CarrierIdentifier(parcel);
+ }
+
+ @Override
+ public CarrierIdentifier[] newArray(int i) {
+ return new CarrierIdentifier[i];
+ }
+ };
+
+ private String mMcc;
+ private String mMnc;
+ private String mSpn;
+ private String mImsi;
+ private String mGid1;
+ private String mGid2;
+
+ public CarrierIdentifier(String mcc, String mnc, String spn, String imsi, String gid1,
+ String gid2) {
+ mMcc = mcc;
+ mMnc = mnc;
+ mSpn = spn;
+ mImsi = imsi;
+ mGid1 = gid1;
+ mGid2 = gid2;
+ }
+
+ /** @hide */
+ public CarrierIdentifier(Parcel parcel) {
+ readFromParcel(parcel);
+ }
+
+ /** Get the mobile country code. */
+ public String getMcc() {
+ return mMcc;
+ }
+
+ /** Get the mobile network code. */
+ public String getMnc() {
+ return mMnc;
+ }
+
+ /** Get the service provider name. */
+ public String getSpn() {
+ return mSpn;
+ }
+
+ /** Get the international mobile subscriber identity. */
+ public String getImsi() {
+ return mImsi;
+ }
+
+ /** Get the group identifier level 1. */
+ public String getGid1() {
+ return mGid1;
+ }
+
+ /** Get the group identifier level 2. */
+ public String getGid2() {
+ return mGid2;
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel out, int flags) {
+ out.writeString(mMcc);
+ out.writeString(mMnc);
+ out.writeString(mSpn);
+ out.writeString(mImsi);
+ out.writeString(mGid1);
+ out.writeString(mGid2);
+ }
+
+ /** @hide */
+ public void readFromParcel(Parcel in) {
+ mMcc = in.readString();
+ mMnc = in.readString();
+ mSpn = in.readString();
+ mImsi = in.readString();
+ mGid1 = in.readString();
+ mGid2 = in.readString();
+ }
+}
diff --git a/core/java/android/service/carrier/ICarrierConfigService.aidl b/core/java/android/service/carrier/ICarrierConfigService.aidl
new file mode 100644
index 0000000..d8390b6
--- /dev/null
+++ b/core/java/android/service/carrier/ICarrierConfigService.aidl
@@ -0,0 +1,32 @@
+/**
+ * Copyright (c) 2015, 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 android.service.carrier;
+
+import android.os.Bundle;
+import android.service.carrier.CarrierIdentifier;
+
+/**
+ * Service used to get carrier config from carrier apps.
+ *
+ * @see android.service.carrier.CarrierConfigService
+ * @hide
+ */
+interface ICarrierConfigService {
+
+ /** @see android.service.carrier.CarrierConfigService#onLoadConfig */
+ Bundle getCarrierConfig(in CarrierIdentifier id);
+} \ No newline at end of file