• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.android.stk;
18 
19 import com.android.internal.telephony.cat.CatLog;
20 
21 import android.content.ComponentName;
22 import android.content.Context;
23 import android.content.pm.PackageManager;
24 
25 /**
26  * Application installer for SIM Toolkit.
27  *
28  */
29 abstract class StkAppInstaller {
StkAppInstaller()30     private StkAppInstaller() {}
31 
install(Context context)32     static void install(Context context) {
33         setAppState(context, true);
34     }
35 
unInstall(Context context)36     static void unInstall(Context context) {
37         setAppState(context, false);
38     }
39 
setAppState(Context context, boolean install)40     private static void setAppState(Context context, boolean install) {
41         if (context == null) {
42             return;
43         }
44         PackageManager pm = context.getPackageManager();
45         if (pm == null) {
46             return;
47         }
48         // check that STK app package is known to the PackageManager
49         ComponentName cName = new ComponentName("com.android.stk",
50                 "com.android.stk.StkLauncherActivity");
51         int state = install ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED
52                 : PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
53 
54         try {
55             pm.setComponentEnabledSetting(cName, state,
56                     PackageManager.DONT_KILL_APP);
57         } catch (Exception e) {
58             CatLog.d("StkAppInstaller", "Could not change STK app state");
59         }
60     }
61 }
62