blob: d9e96e93f090aa8a994e511fd27be3a89ff09957 [file] [log] [blame]
The Android Open Source Project9d9730a2009-03-03 19:32:37 -08001/*
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
17package com.android.stk;
18
Alex Yakavenkad41f1d92010-07-12 14:13:13 -070019import com.android.internal.telephony.cat.CatLog;
The Android Open Source Project9d9730a2009-03-03 19:32:37 -080020
21import android.content.ComponentName;
22import android.content.Context;
23import android.content.pm.PackageManager;
24
25/**
26 * Application installer for SIM Toolkit.
Wink Saville79085fc2009-06-09 10:27:23 -070027 *
The Android Open Source Project9d9730a2009-03-03 19:32:37 -080028 */
29abstract class StkAppInstaller {
30 private StkAppInstaller() {}
31
32 static void install(Context context) {
33 setAppState(context, true);
34 }
35
36 static void unInstall(Context context) {
37 setAppState(context, false);
38 }
39
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) {
Alex Yakavenkad41f1d92010-07-12 14:13:13 -070058 CatLog.d("StkAppInstaller", "Could not change STK app state");
The Android Open Source Project9d9730a2009-03-03 19:32:37 -080059 }
60 }
61}