blob: 32c15e944757add3cd6023dcf23272e5c6478e18 [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;
24import android.util.Log;
25
26import java.io.IOException;
27
28import com.android.internal.os.RecoverySystem;
29import 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;
37
38 public FallbackCheckinService(Context context) {
39 mContext = context;
40 }
41
42 public boolean checkin() {
43 return false; // failure, because not implemented
44 }
45
46 public void reportCrashSync(byte[] crashData) {
47 }
48
49 public void reportCrashAsync(byte[] crashData) {
50 }
51
52 public void masterClear() {
53 if (mContext.checkCallingOrSelfPermission("android.permission.MASTER_CLEAR") !=
54 PackageManager.PERMISSION_GRANTED) {
55 Log.e(TAG, "Permission Denial: can't invoke masterClear from "
56 + "pid=" + Binder.getCallingPid() + ", "
57 + "uid=" + Binder.getCallingUid());
58 return;
59 }
60
61 // Save the android ID so the new system can get it erased.
62 try {
63 RecoverySystem.rebootAndWipe();
64 } catch (IOException e) {
65 Log.e(TAG, "Reboot for masterClear() failed", e);
66 }
67 }
68
Oscar Montemayor3baf1bf2009-11-30 10:37:37 -080069 public void masterClearAndToggleEFS(boolean efsEnabled) {
70 if (mContext.checkCallingOrSelfPermission("android.permission.MASTER_CLEAR") !=
71 PackageManager.PERMISSION_GRANTED) {
72 Log.e(TAG, "Permission Denial: can't invoke masterClearAndToggleEFS from "
73 + "pid=" + Binder.getCallingPid() + ", "
74 + "uid=" + Binder.getCallingUid());
75 return;
76 }
77
78 // Save the android ID so the new system can get it erased.
79 try {
80 RecoverySystem.rebootAndToggleEFS(efsEnabled);
81 } catch (IOException e) {
82 Log.e(TAG, "Reboot for toggle EFS failed", e);
83 }
84 }
85
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080086 public void getParentalControlState(IParentalControlCallback p, String requestingApp)
87 throws android.os.RemoteException {
88 ParentalControlState state = new ParentalControlState();
89 state.isEnabled = false;
90 p.onResult(state);
91 }
92}