Home | History | Annotate | Download | only in admin
      1 /*
      2  * Copyright (C) 2017 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.app.admin;
     17 
     18 import android.app.Service;
     19 import android.content.ComponentName;
     20 import android.content.Intent;
     21 import android.os.IBinder;
     22 
     23 /**
     24  * Base class for a service that device owner/profile owners can optionally have.
     25  *
     26  * <p>The system searches for it with an intent filter with the
     27  * {@link DevicePolicyManager#ACTION_DEVICE_ADMIN_SERVICE} action, and tries to keep a bound
     28  * connection as long as the hosting user is running, so that the device/profile owner is always
     29  * considered to be in the foreground.  This is useful to receive implicit broadcasts that
     30  * can no longer be received by manifest receivers by apps targeting Android version
     31  * {@link android.os.Build.VERSION_CODES#O}.  Device/profile owners can use a runtime-registered
     32  * broadcast receiver instead, and have a {@link DeviceAdminService} so that the process is always
     33  * running.
     34  *
     35  * <p>Device/profile owners can use
     36  * {@link android.content.pm.PackageManager#setComponentEnabledSetting(ComponentName, int, int)}
     37  * to disable/enable its own service.  For example, when a device/profile owner no longer needs
     38  * to be in the foreground, it can (and should) disable its service.
     39  *
     40  * <p>The service must be protected with the permission
     41  * {@link android.Manifest.permission#BIND_DEVICE_ADMIN}.  Otherwise the system would ignore it.
     42  *
     43  * <p>When the owner process crashes, the service will be re-bound automatically after a
     44  * back-off.
     45  *
     46  * <p>Note the process may still be killed if the system is under heavy memory pressure, in which
     47  * case the process will be re-started later.
     48  */
     49 public class DeviceAdminService extends Service {
     50     private final IDeviceAdminServiceImpl mImpl;
     51 
     52     public DeviceAdminService() {
     53         mImpl = new IDeviceAdminServiceImpl();
     54     }
     55 
     56     @Override
     57     public final IBinder onBind(Intent intent) {
     58         return mImpl.asBinder();
     59     }
     60 
     61     private class IDeviceAdminServiceImpl extends IDeviceAdminService.Stub {
     62     }
     63 
     64     // So far, we have no methods in this class.
     65 }
     66