blob: a97f659548e87b7bc89e0e25c840feead659cbe6 [file] [log] [blame]
Marc Blank9ba506c2011-02-08 18:54:56 -08001/*
2 * Copyright (C) 2011 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
17package com.android.email.service;
18
19import com.android.email.SecurityPolicy;
Marc Blankaeee10e2011-04-27 17:12:06 -070020import com.android.emailcommon.provider.Policy;
Marc Blank9ba506c2011-02-08 18:54:56 -080021import com.android.emailcommon.service.IPolicyService;
Marc Blank9ba506c2011-02-08 18:54:56 -080022
23import android.app.Service;
24import android.content.Context;
25import android.content.Intent;
26import android.os.IBinder;
27
28public class PolicyService extends Service {
29
30 private SecurityPolicy mSecurityPolicy;
31 private Context mContext;
32
33 private final IPolicyService.Stub mBinder = new IPolicyService.Stub() {
Marc Blankaeee10e2011-04-27 17:12:06 -070034 public boolean isActive(Policy policy) {
35 return mSecurityPolicy.isActive(policy);
Marc Blank9ba506c2011-02-08 18:54:56 -080036 }
37
38 public void policiesRequired(long accountId) {
39 mSecurityPolicy.policiesRequired(accountId);
40 }
41
Marc Blankaeee10e2011-04-27 17:12:06 -070042 public void policiesUpdated(long accountId) {
43 mSecurityPolicy.policiesUpdated(accountId);
Marc Blank9ba506c2011-02-08 18:54:56 -080044 }
45
46 public void setAccountHoldFlag(long accountId, boolean newState) {
47 SecurityPolicy.setAccountHoldFlag(mContext, accountId, newState);
48 }
49
50 public boolean isActiveAdmin() {
51 return mSecurityPolicy.isActiveAdmin();
52 }
53
54 public void remoteWipe() {
55 mSecurityPolicy.remoteWipe();
56 }
57
Marc Blankaeee10e2011-04-27 17:12:06 -070058 public boolean isSupported(Policy policy) {
59 return mSecurityPolicy.isSupported(policy);
Marc Blank9ba506c2011-02-08 18:54:56 -080060 }
61
Marc Blankaeee10e2011-04-27 17:12:06 -070062 public Policy clearUnsupportedPolicies(Policy policy) {
63 return mSecurityPolicy.clearUnsupportedPolicies(policy);
Marc Blank9ba506c2011-02-08 18:54:56 -080064 }
65 };
66
67 @Override
68 public IBinder onBind(Intent intent) {
69 // When we bind this service, save the context and SecurityPolicy singleton
70 mContext = this;
71 mSecurityPolicy = SecurityPolicy.getInstance(this);
72 return mBinder;
73 }
74}