Debian Codegraph @

core/java/android/service/carrier/CarrierMessagingClientService.java

raw symbols SCIP
1 /*
2 * Copyright (C) 2018 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package android.service.carrier;
17
18 import android.annotation.NonNull;
19 import android.annotation.Nullable;
20 import android.app.Service;
21 import android.content.ComponentName;
22 import android.content.Intent;
23 import android.os.IBinder;
24
25 /**
26 * If the default SMS app has a service that extends this class, the system always tries to bind
27 * it so that the process is always running, which allows the app to have a persistent connection
28 * to the server.
29 *
30 * <p>The service must have an
31 * {@link android.telephony.TelephonyManager#ACTION_CARRIER_MESSAGING_CLIENT_SERVICE}
32 * action in the intent handler, and be protected with
33 * {@link android.Manifest.permission#BIND_CARRIER_MESSAGING_CLIENT_SERVICE}.
34 * However the service does not have to be exported.
35 *
36 * <p>The service must be associated with a non-main process, meaning it must have an
37 * {@code android:process} tag in its manifest entry.
38 *
39 * <p>An app can use
40 * {@link android.content.pm.PackageManager#setComponentEnabledSetting(ComponentName, int, int)}
41 * to disable or enable the service. An app should use it to disable the service when it no longer
42 * needs to be running.
43 *
44 * <p>When the owner process crashes, the service will be re-bound automatically after a
45 * back-off.
46 *
47 * <p>Note the process may still be killed if the system is under heavy memory pressure, in which
48 * case the process will be re-started later.
49 *
50 * <p>Example: First, define a subclass in the application:
51 * <pre>
52 * public class MyCarrierMessagingClientService extends CarrierMessagingClientService {
53 * }
54 * </pre>
55 * Then, declare it in its {@code AndroidManifest.xml}:
56 * <pre>
57 * &lt;service
58 * android:name=".MyCarrierMessagingClientService"
59 * android:exported="false"
60 * android:process=":persistent"
61 * android:permission="android.permission.BIND_CARRIER_MESSAGING_CLIENT_SERVICE"&gt;
62 * &lt;intent-filter&gt;
63 * &lt;action android:name="android.telephony.action.CARRIER_MESSAGING_CLIENT_SERVICE" /&gt;
64 * &lt;/intent-filter&gt;
65 * &lt;/service&gt;
66 * </pre>
67 */
68 public class CarrierMessagingClientService extends Service {
69 private final ICarrierMessagingClientServiceImpl mImpl;
70
71 public CarrierMessagingClientService() {
72 mImpl = new ICarrierMessagingClientServiceImpl();
73 }
74
75 @Override
76 @NonNull
77 public final IBinder onBind(@Nullable Intent intent) {
78 return mImpl.asBinder();
79 }
80
81 private class ICarrierMessagingClientServiceImpl extends ICarrierMessagingClientService.Stub {
82 }
83 }