blob: fc0ab6906d76e7d79bc382d83a0f3d38d29a4104 [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
2 * Copyright (C) 2008 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.server;
18
19import android.content.Context;
20import android.content.pm.PackageManager;
21import android.os.Binder;
22import android.os.ICheckinService;
23import android.os.IParentalControlCallback;
Doug Zongker1af33d02010-01-05 11:28:55 -080024import android.os.RecoverySystem;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080025import android.util.Log;
26
27import java.io.IOException;
28
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080029import com.google.android.net.ParentalControlState;
30
31/**
32 * @hide
33 */
34public final class FallbackCheckinService extends ICheckinService.Stub {
35 static final String TAG = "FallbackCheckinService";
36 final Context mContext;
Dan Egnorb7f03672009-12-09 16:22:32 -080037
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080038 public FallbackCheckinService(Context context) {
39 mContext = context;
40 }
41
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080042 public void masterClear() {
43 if (mContext.checkCallingOrSelfPermission("android.permission.MASTER_CLEAR") !=
44 PackageManager.PERMISSION_GRANTED) {
45 Log.e(TAG, "Permission Denial: can't invoke masterClear from "
46 + "pid=" + Binder.getCallingPid() + ", "
47 + "uid=" + Binder.getCallingUid());
48 return;
49 }
50
51 // Save the android ID so the new system can get it erased.
52 try {
Doug Zongker1af33d02010-01-05 11:28:55 -080053 RecoverySystem.rebootWipeUserData(mContext);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080054 } catch (IOException e) {
55 Log.e(TAG, "Reboot for masterClear() failed", e);
56 }
57 }
58
Oscar Montemayor3baf1bf2009-11-30 10:37:37 -080059 public void masterClearAndToggleEFS(boolean efsEnabled) {
60 if (mContext.checkCallingOrSelfPermission("android.permission.MASTER_CLEAR") !=
61 PackageManager.PERMISSION_GRANTED) {
62 Log.e(TAG, "Permission Denial: can't invoke masterClearAndToggleEFS from "
63 + "pid=" + Binder.getCallingPid() + ", "
64 + "uid=" + Binder.getCallingUid());
65 return;
66 }
67
68 // Save the android ID so the new system can get it erased.
69 try {
Doug Zongker1af33d02010-01-05 11:28:55 -080070 RecoverySystem.rebootToggleEFS(mContext, efsEnabled);
Oscar Montemayor3baf1bf2009-11-30 10:37:37 -080071 } catch (IOException e) {
72 Log.e(TAG, "Reboot for toggle EFS failed", e);
73 }
74 }
75
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080076 public void getParentalControlState(IParentalControlCallback p, String requestingApp)
77 throws android.os.RemoteException {
78 ParentalControlState state = new ParentalControlState();
79 state.isEnabled = false;
80 p.onResult(state);
81 }
82}