1 /*
2  * Copyright (C) 2007 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.example.android.platform.upgrade;
18 
19 import android.content.BroadcastReceiver;
20 import android.content.ComponentName;
21 import android.content.Context;
22 import android.content.Intent;
23 import android.content.pm.PackageManager;
24 import android.util.Log;
25 
26 /**
27  * This will be launched during system boot, after the core system has
28  * been brought up but before any non-persistent processes have been
29  * started.  It is launched in a special state, with no content provider
30  * or custom application class associated with the process running.
31  */
32 public class Upgrade extends BroadcastReceiver {
33     @Override
onReceive(Context context, Intent intent)34     public void onReceive(Context context, Intent intent) {
35         // We are now running with the system up, but no apps started,
36         // so can do whatever cleanup after an upgrade that we want.
37         Log.i("Example", "******************* UPGRADE HERE *******************");
38 
39         // And now disable this component so it won't get launched during
40         // the following system boots.
41 
42         context.getPackageManager().setComponentEnabledSetting(
43                 new ComponentName(context, getClass()),
44                 PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
45                 PackageManager.DONT_KILL_APP);
46     }
47 }
48 
49