| 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; |
| Doug Zongker | 1af33d0 | 2010-01-05 11:28:55 -0800 | [diff] [blame^] | 24 | import android.os.RecoverySystem; |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 25 | import android.util.Log; |
| 26 | |
| 27 | import java.io.IOException; |
| 28 | |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 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; |
| Dan Egnor | b7f0367 | 2009-12-09 16:22:32 -0800 | [diff] [blame] | 37 | |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 38 | public FallbackCheckinService(Context context) { |
| 39 | mContext = context; |
| 40 | } |
| 41 | |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 42 | 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 Zongker | 1af33d0 | 2010-01-05 11:28:55 -0800 | [diff] [blame^] | 53 | RecoverySystem.rebootWipeUserData(mContext); |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 54 | } catch (IOException e) { |
| 55 | Log.e(TAG, "Reboot for masterClear() failed", e); |
| 56 | } |
| 57 | } |
| 58 | |
| Oscar Montemayor | 3baf1bf | 2009-11-30 10:37:37 -0800 | [diff] [blame] | 59 | 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 Zongker | 1af33d0 | 2010-01-05 11:28:55 -0800 | [diff] [blame^] | 70 | RecoverySystem.rebootToggleEFS(mContext, efsEnabled); |
| Oscar Montemayor | 3baf1bf | 2009-11-30 10:37:37 -0800 | [diff] [blame] | 71 | } catch (IOException e) { |
| 72 | Log.e(TAG, "Reboot for toggle EFS failed", e); |
| 73 | } |
| 74 | } |
| 75 | |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 76 | 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 | } |