| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package com.android.server; |
| 18 | |
| 19 | import android.content.Context; |
| 20 | import android.content.pm.PackageManager; |
| 21 | import android.os.Binder; |
| 22 | import android.os.ICheckinService; |
| 23 | import android.os.IParentalControlCallback; |
| 24 | import android.util.Log; |
| 25 | |
| 26 | import java.io.IOException; |
| 27 | |
| 28 | import com.android.internal.os.RecoverySystem; |
| 29 | import com.google.android.net.ParentalControlState; |
| 30 | |
| 31 | /** |
| 32 | * @hide |
| 33 | */ |
| 34 | public 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 | |
| 69 | public void getParentalControlState(IParentalControlCallback p, String requestingApp) |
| 70 | throws android.os.RemoteException { |
| 71 | ParentalControlState state = new ParentalControlState(); |
| 72 | state.isEnabled = false; |
| 73 | p.onResult(state); |
| 74 | } |
| 75 | } |