Persistent connection to DO/PO service.

Test: Manual test with customize API tests; CTS coming.
Change-Id: I1d7eaa4b1fdd20726c1832c736d32f934c6a82f9
This commit is contained in:
Makoto Onuki
2017-03-22 14:22:35 -07:00
parent 6f3bc05868
commit fc73d799e9
10 changed files with 562 additions and 10 deletions

View File

@@ -0,0 +1,56 @@
/*
* Copyright (C) 2017 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.app.admin;
import android.app.Service;
import android.content.ComponentName;
import android.content.Intent;
import android.os.IBinder;
/**
* Base class for a service that device owner/profile owners can optionally have.
*
* <p>The system searches for it with an intent filter with the
* {@link DevicePolicyManager#ACTION_DEVICE_ADMIN_SERVICE} action, and tries to keep a bound
* connection as long as the hosting user is running, so that the device/profile owner is always
* considered to be in the foreground.
*
* <p>Device/profile owners can use
* {@link android.content.pm.PackageManager#setComponentEnabledSetting(ComponentName, int, int)}
* to disable/enable its own service. For example, when a device/profile owner no longer needs
* to be in the foreground, it can (and should) disable its service.
*
* <p>The service must not be exported.
*
* <p>TODO: Describe how the system handles crashes in DO/PO.
*/
public class DeviceAdminService extends Service {
private final IDeviceAdminServiceImpl mImpl;
public DeviceAdminService() {
mImpl = new IDeviceAdminServiceImpl();
}
@Override
public final IBinder onBind(Intent intent) {
return mImpl.asBinder();
}
private class IDeviceAdminServiceImpl extends IDeviceAdminService.Stub {
}
// So far, we have no methods in this class.
}

View File

@@ -1514,6 +1514,16 @@ public class DevicePolicyManager {
CODE_SPLIT_SYSTEM_USER_DEVICE_SYSTEM_USER, CODE_ADD_MANAGED_PROFILE_DISALLOWED})
public @interface ProvisioningPreCondition {}
/**
* Service action: Action for a service that device owner and profile owner can optionally
* own. If a device owner or a profile owner has such a service, the system tries to keep
* a bound connection to it, in order to keep their process always running.
* The service must not be exported.
*/
@SdkConstant(SdkConstantType.SERVICE_ACTION)
public static final String ACTION_DEVICE_ADMIN_SERVICE
= "android.app.action.DEVICE_ADMIN_SERVICE";
/**
* Return true if the given administrator component is currently active (enabled) in the system.
*

View File

@@ -0,0 +1,23 @@
/*
* Copyright (C) 2017 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.app.admin;
/**
* @hide
*/
interface IDeviceAdminService {
}