blob: d4dfe9713ad0c603425dd002e1be4206c3213853 [file] [log] [blame]
The Android Open Source Projectde2d9f52008-10-21 07:00:00 -07001
2
3/**
4 * Copyright (C) 2007 The Android Open Source Project
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
7 * use this file except in compliance with the License. You may obtain a copy
8 * of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15 * License for the specific language governing permissions and limitations
16 * under the License.
17 */
18
19package com.android.settings;
20
21import com.android.settings.R;
22import android.app.Activity;
23import android.app.ActivityManager;
24import android.app.AlertDialog;
25import android.content.Context;
26import android.content.DialogInterface;
27import android.content.Intent;
28import android.content.IntentFilter;
29import android.content.pm.ApplicationInfo;
30import android.content.pm.IPackageDataObserver;
31import android.content.pm.IPackageStatsObserver;
The Android Open Source Projectde2d9f52008-10-21 07:00:00 -070032import android.content.pm.PackageManager;
33import android.content.pm.PackageStats;
34import android.content.pm.PackageManager.NameNotFoundException;
35import android.net.Uri;
36import android.os.Bundle;
37import android.os.Handler;
38import android.os.Message;
The Android Open Source Projectabc48f82008-12-17 18:06:01 -080039import android.text.format.Formatter;
The Android Open Source Projectde2d9f52008-10-21 07:00:00 -070040import android.util.Config;
41import android.util.Log;
42import java.util.ArrayList;
43import java.util.List;
44import android.content.ComponentName;
45import android.view.View;
46import android.widget.AppSecurityPermissions;
47import android.widget.Button;
48import android.widget.ImageView;
49import android.widget.LinearLayout;
50import android.widget.TextView;
51
52/**
The Android Open Source Projectabc48f82008-12-17 18:06:01 -080053 * Activity to display application information from Settings. This activity presents
54 * extended information associated with a package like code, data, total size, permissions
55 * used by the application and also the set of default launchable activities.
56 * For system applications, an option to clear user data is displayed only if data size is > 0.
57 * System applications that do not want clear user data do not have this option.
58 * For non-system applications, there is no option to clear data. Instead there is an option to
59 * uninstall the application.
The Android Open Source Projectde2d9f52008-10-21 07:00:00 -070060 */
61public class InstalledAppDetails extends Activity implements View.OnClickListener, DialogInterface.OnClickListener {
62 private static final String TAG="InstalledAppDetails";
63 private static final int _UNKNOWN_APP=R.string.unknown;
The Android Open Source Projectde2d9f52008-10-21 07:00:00 -070064 private ApplicationInfo mAppInfo;
The Android Open Source Projectabc48f82008-12-17 18:06:01 -080065 private Button mAppButton;
The Android Open Source Projectde2d9f52008-10-21 07:00:00 -070066 private Button mActivitiesButton;
The Android Open Source Projectabc48f82008-12-17 18:06:01 -080067 private boolean mCanUninstall;
68 private boolean localLOGV=Config.LOGV || false;
The Android Open Source Project1feaa852009-02-10 15:44:05 -080069 private TextView mAppSnippetSize;
The Android Open Source Projectde2d9f52008-10-21 07:00:00 -070070 private TextView mTotalSize;
71 private TextView mAppSize;
72 private TextView mDataSize;
The Android Open Source Projectabc48f82008-12-17 18:06:01 -080073 private PkgSizeObserver mSizeObserver;
74 private ClearUserDataObserver mClearDataObserver;
75 // Views related to cache info
76 private View mCachePanel;
77 private TextView mCacheSize;
78 private Button mClearCacheButton;
79 private ClearCacheObserver mClearCacheObserver;
The Android Open Source Project1feaa852009-02-10 15:44:05 -080080 private Button mForceStopButton;
The Android Open Source Projectabc48f82008-12-17 18:06:01 -080081
The Android Open Source Projectde2d9f52008-10-21 07:00:00 -070082 PackageStats mSizeInfo;
83 private Button mManageSpaceButton;
84 private PackageManager mPm;
The Android Open Source Projectde2d9f52008-10-21 07:00:00 -070085
86 //internal constants used in Handler
The Android Open Source Projectde2d9f52008-10-21 07:00:00 -070087 private static final int OP_SUCCESSFUL = 1;
88 private static final int OP_FAILED = 2;
The Android Open Source Projectabc48f82008-12-17 18:06:01 -080089 private static final int CLEAR_USER_DATA = 1;
The Android Open Source Projectde2d9f52008-10-21 07:00:00 -070090 private static final int GET_PKG_SIZE = 2;
The Android Open Source Projectabc48f82008-12-17 18:06:01 -080091 private static final int CLEAR_CACHE = 3;
The Android Open Source Projectde2d9f52008-10-21 07:00:00 -070092 private static final String ATTR_PACKAGE_STATS="PackageStats";
93
The Android Open Source Projectabc48f82008-12-17 18:06:01 -080094 // invalid size value used initially and also when size retrieval through PackageManager
95 // fails for whatever reason
96 private static final int SIZE_INVALID = -1;
97
98 // Resource strings
99 private CharSequence mInvalidSizeStr;
100 private CharSequence mComputingStr;
101 private CharSequence mAppButtonText;
102
103 // Possible btn states
104 private enum AppButtonStates {
105 CLEAR_DATA,
106 UNINSTALL,
107 NONE
108 }
109 private AppButtonStates mAppButtonState;
110
The Android Open Source Projectde2d9f52008-10-21 07:00:00 -0700111 private Handler mHandler = new Handler() {
112 public void handleMessage(Message msg) {
113 switch (msg.what) {
114 case CLEAR_USER_DATA:
115 processClearMsg(msg);
116 break;
117 case GET_PKG_SIZE:
118 refreshSizeInfo(msg);
119 break;
The Android Open Source Projectabc48f82008-12-17 18:06:01 -0800120 case CLEAR_CACHE:
121 // Refresh size info
122 mPm.getPackageSizeInfo(mAppInfo.packageName, mSizeObserver);
123 break;
The Android Open Source Projectde2d9f52008-10-21 07:00:00 -0700124 default:
125 break;
126 }
127 }
128 };
129
The Android Open Source Projectabc48f82008-12-17 18:06:01 -0800130 private boolean isUninstallable() {
131 if (((mAppInfo.flags&ApplicationInfo.FLAG_SYSTEM) != 0) &&
132 ((mAppInfo.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) == 0)) {
133 return false;
The Android Open Source Projectde2d9f52008-10-21 07:00:00 -0700134 }
The Android Open Source Projectabc48f82008-12-17 18:06:01 -0800135 return true;
The Android Open Source Projectde2d9f52008-10-21 07:00:00 -0700136 }
137
138 class ClearUserDataObserver extends IPackageDataObserver.Stub {
139 public void onRemoveCompleted(final String packageName, final boolean succeeded) {
140 final Message msg = mHandler.obtainMessage(CLEAR_USER_DATA);
141 msg.arg1 = succeeded?OP_SUCCESSFUL:OP_FAILED;
142 mHandler.sendMessage(msg);
143 }
144 }
145
146 class PkgSizeObserver extends IPackageStatsObserver.Stub {
147 public int idx;
148 public void onGetStatsCompleted(PackageStats pStats, boolean succeeded) {
149 Message msg = mHandler.obtainMessage(GET_PKG_SIZE);
150 Bundle data = new Bundle();
151 data.putParcelable(ATTR_PACKAGE_STATS, pStats);
152 msg.setData(data);
153 mHandler.sendMessage(msg);
154
155 }
156 }
157
The Android Open Source Projectabc48f82008-12-17 18:06:01 -0800158 class ClearCacheObserver extends IPackageDataObserver.Stub {
159 public void onRemoveCompleted(final String packageName, final boolean succeeded) {
160 final Message msg = mHandler.obtainMessage(CLEAR_CACHE);
161 msg.arg1 = succeeded?OP_SUCCESSFUL:OP_FAILED;
162 mHandler.sendMessage(msg);
163 }
164 }
165
The Android Open Source Projectde2d9f52008-10-21 07:00:00 -0700166 private String getSizeStr(long size) {
The Android Open Source Projectabc48f82008-12-17 18:06:01 -0800167 if (size == SIZE_INVALID) {
168 return mInvalidSizeStr.toString();
The Android Open Source Projectde2d9f52008-10-21 07:00:00 -0700169 }
The Android Open Source Projectabc48f82008-12-17 18:06:01 -0800170 return Formatter.formatFileSize(this, size);
171 }
172
173 private void setAppBtnState() {
174 boolean visible = false;
175 if(mCanUninstall) {
176 //app can clear user data
177 if((mAppInfo.flags & ApplicationInfo.FLAG_ALLOW_CLEAR_USER_DATA)
178 == ApplicationInfo.FLAG_ALLOW_CLEAR_USER_DATA) {
179 mAppButtonText = getText(R.string.clear_user_data_text);
180 mAppButtonState = AppButtonStates.CLEAR_DATA;
181 visible = true;
182 } else {
183 //hide button if diableClearUserData is set
184 visible = false;
185 mAppButtonState = AppButtonStates.NONE;
The Android Open Source Projectde2d9f52008-10-21 07:00:00 -0700186 }
The Android Open Source Projectabc48f82008-12-17 18:06:01 -0800187 } else {
188 visible = true;
189 mAppButtonState = AppButtonStates.UNINSTALL;
190 mAppButtonText = getText(R.string.uninstall_text);
The Android Open Source Projectde2d9f52008-10-21 07:00:00 -0700191 }
The Android Open Source Projectabc48f82008-12-17 18:06:01 -0800192 if(visible) {
193 mAppButton.setText(mAppButtonText);
194 mAppButton.setVisibility(View.VISIBLE);
195 } else {
196 mAppButton.setVisibility(View.GONE);
197 }
The Android Open Source Projectde2d9f52008-10-21 07:00:00 -0700198 }
199
200 /** Called when the activity is first created. */
201 @Override
202 protected void onCreate(Bundle icicle) {
203 super.onCreate(icicle);
204 //get package manager
205 mPm = getPackageManager();
206 //get application's name from intent
207 Intent intent = getIntent();
208 final String packageName = intent.getStringExtra(ManageApplications.APP_PKG_NAME);
The Android Open Source Projectabc48f82008-12-17 18:06:01 -0800209 mComputingStr = getText(R.string.computing_size);
210 // Try retrieving package stats again
211 CharSequence totalSizeStr, appSizeStr, dataSizeStr;
212 totalSizeStr = appSizeStr = dataSizeStr = mComputingStr;
213 if(localLOGV) Log.i(TAG, "Have to compute package sizes");
214 mSizeObserver = new PkgSizeObserver();
215 mPm.getPackageSizeInfo(packageName, mSizeObserver);
216
The Android Open Source Projectde2d9f52008-10-21 07:00:00 -0700217 try {
The Android Open Source Projectabc48f82008-12-17 18:06:01 -0800218 mAppInfo = mPm.getApplicationInfo(packageName,
219 PackageManager.GET_UNINSTALLED_PACKAGES);
The Android Open Source Projectde2d9f52008-10-21 07:00:00 -0700220 } catch (NameNotFoundException e) {
The Android Open Source Projectde2d9f52008-10-21 07:00:00 -0700221 Log.e(TAG, "Exception when retrieving package:"+packageName, e);
222 displayErrorDialog(R.string.app_not_found_dlg_text, true, true);
223 }
The Android Open Source Projectabc48f82008-12-17 18:06:01 -0800224 setContentView(R.layout.installed_app_details);
225 ((ImageView)findViewById(R.id.app_icon)).setImageDrawable(mAppInfo.loadIcon(mPm));
The Android Open Source Projectde2d9f52008-10-21 07:00:00 -0700226 //set application name TODO version
The Android Open Source Projectabc48f82008-12-17 18:06:01 -0800227 CharSequence appName = mAppInfo.loadLabel(mPm);
The Android Open Source Projectde2d9f52008-10-21 07:00:00 -0700228 if(appName == null) {
229 appName = getString(_UNKNOWN_APP);
230 }
231 ((TextView)findViewById(R.id.app_name)).setText(appName);
The Android Open Source Project1feaa852009-02-10 15:44:05 -0800232 mAppSnippetSize = ((TextView)findViewById(R.id.app_size));
233 mAppSnippetSize.setText(totalSizeStr);
The Android Open Source Projectde2d9f52008-10-21 07:00:00 -0700234 //TODO download str and download url
235 //set values on views
236 mTotalSize = (TextView)findViewById(R.id.total_size_text);
237 mTotalSize.setText(totalSizeStr);
238 mAppSize = (TextView)findViewById(R.id.application_size_text);
239 mAppSize.setText(appSizeStr);
240 mDataSize = (TextView)findViewById(R.id.data_size_text);
241 mDataSize.setText(dataSizeStr);
242
The Android Open Source Projectabc48f82008-12-17 18:06:01 -0800243 mAppButton = ((Button)findViewById(R.id.uninstall_button));
The Android Open Source Projectde2d9f52008-10-21 07:00:00 -0700244 //determine if app is a system app
The Android Open Source Projectabc48f82008-12-17 18:06:01 -0800245 mCanUninstall = !isUninstallable();
246 if(localLOGV) Log.i(TAG, "Is systemPackage "+mCanUninstall);
247 setAppBtnState();
248 mManageSpaceButton = (Button)findViewById(R.id.manage_space_button);
249 if(mAppInfo.manageSpaceActivityName != null) {
250 mManageSpaceButton.setVisibility(View.VISIBLE);
251 mManageSpaceButton.setOnClickListener(this);
The Android Open Source Projectde2d9f52008-10-21 07:00:00 -0700252 }
The Android Open Source Projectabc48f82008-12-17 18:06:01 -0800253
254 // Cache section
255 mCachePanel = findViewById(R.id.cache_panel);
256 mCacheSize = (TextView) findViewById(R.id.cache_size_text);
257 mClearCacheButton = (Button) findViewById(R.id.clear_cache_button);
The Android Open Source Project1feaa852009-02-10 15:44:05 -0800258 mForceStopButton = (Button) findViewById(R.id.force_stop_button);
259 mForceStopButton.setOnClickListener(this);
The Android Open Source Projectabc48f82008-12-17 18:06:01 -0800260
The Android Open Source Projectde2d9f52008-10-21 07:00:00 -0700261 //clear activities
262 mActivitiesButton = (Button)findViewById(R.id.clear_activities_button);
263 List<ComponentName> prefActList = new ArrayList<ComponentName>();
264 //intent list cannot be null. so pass empty list
265 List<IntentFilter> intentList = new ArrayList<IntentFilter>();
266 mPm.getPreferredActivities(intentList, prefActList, packageName);
267 if(localLOGV) Log.i(TAG, "Have "+prefActList.size()+" number of activities in prefered list");
268 TextView autoLaunchView = (TextView)findViewById(R.id.auto_launch);
269 if(prefActList.size() <= 0) {
270 //disable clear activities button
271 autoLaunchView.setText(R.string.auto_launch_disable_text);
272 mActivitiesButton.setEnabled(false);
273 } else {
274 autoLaunchView.setText(R.string.auto_launch_enable_text);
275 mActivitiesButton.setOnClickListener(this);
276 }
The Android Open Source Projectabc48f82008-12-17 18:06:01 -0800277
278 // security permissions section
279 LinearLayout permsView = (LinearLayout) findViewById(R.id.permissions_section);
280 AppSecurityPermissions asp = new AppSecurityPermissions(this, packageName);
281 if(asp.getPermissionCount() > 0) {
282 permsView.setVisibility(View.VISIBLE);
283 // Make the security sections header visible
284 LinearLayout securityList = (LinearLayout) permsView.findViewById(
285 R.id.security_settings_list);
286 securityList.addView(asp.getPermissionsView());
287 } else {
288 permsView.setVisibility(View.GONE);
The Android Open Source Projectde2d9f52008-10-21 07:00:00 -0700289 }
The Android Open Source Projectde2d9f52008-10-21 07:00:00 -0700290 }
291
292 private void displayErrorDialog(int msgId, final boolean finish, final boolean changed) {
293 //display confirmation dialog
294 new AlertDialog.Builder(this)
295 .setTitle(getString(R.string.app_not_found_dlg_title))
The Android Open Source Project5962e182009-01-09 17:51:25 -0800296 .setIcon(android.R.drawable.ic_dialog_alert)
The Android Open Source Projectde2d9f52008-10-21 07:00:00 -0700297 .setMessage(getString(msgId))
298 .setNeutralButton(getString(R.string.dlg_ok),
299 new DialogInterface.OnClickListener() {
300 public void onClick(DialogInterface dialog, int which) {
301 //force to recompute changed value
302 setIntentAndFinish(finish, changed);
303 }
304 }
305 )
306 .show();
307 }
308
309 private void setIntentAndFinish(boolean finish, boolean appChanged) {
310 if(localLOGV) Log.i(TAG, "appChanged="+appChanged);
311 Intent intent = new Intent();
312 intent.putExtra(ManageApplications.APP_CHG, appChanged);
313 setResult(ManageApplications.RESULT_OK, intent);
The Android Open Source Projectabc48f82008-12-17 18:06:01 -0800314 mAppButton.setEnabled(false);
The Android Open Source Projectde2d9f52008-10-21 07:00:00 -0700315 if(finish) {
316 finish();
317 }
318 }
319
320 /*
321 * Private method to handle get size info notification from observer when
322 * the async operation from PackageManager is complete. The current user data
323 * info has to be refreshed in the manage applications screen as well as the current screen.
324 */
325 private void refreshSizeInfo(Message msg) {
326 boolean changed = false;
The Android Open Source Projectde2d9f52008-10-21 07:00:00 -0700327 PackageStats newPs = msg.getData().getParcelable(ATTR_PACKAGE_STATS);
328 long newTot = newPs.cacheSize+newPs.codeSize+newPs.dataSize;
The Android Open Source Projectabc48f82008-12-17 18:06:01 -0800329 if(mSizeInfo == null) {
The Android Open Source Projectde2d9f52008-10-21 07:00:00 -0700330 mSizeInfo = newPs;
The Android Open Source Project1feaa852009-02-10 15:44:05 -0800331 String str = getSizeStr(newTot);
332 mTotalSize.setText(str);
333 mAppSnippetSize.setText(str);
The Android Open Source Projectabc48f82008-12-17 18:06:01 -0800334 mAppSize.setText(getSizeStr(newPs.codeSize));
335 mDataSize.setText(getSizeStr(newPs.dataSize+newPs.cacheSize));
336 } else {
337 long oldTot = mSizeInfo.cacheSize+mSizeInfo.codeSize+mSizeInfo.dataSize;
338 if(newTot != oldTot) {
The Android Open Source Project1feaa852009-02-10 15:44:05 -0800339 String str = getSizeStr(newTot);
340 mTotalSize.setText(str);
341 mAppSnippetSize.setText(str);
The Android Open Source Projectabc48f82008-12-17 18:06:01 -0800342 changed = true;
343 }
344 if(newPs.codeSize != mSizeInfo.codeSize) {
345 mAppSize.setText(getSizeStr(newPs.codeSize));
346 changed = true;
347 }
348 if((newPs.dataSize != mSizeInfo.dataSize) || (newPs.cacheSize != mSizeInfo.cacheSize)) {
349 mDataSize.setText(getSizeStr(newPs.dataSize+newPs.cacheSize));
350 }
351 if(changed) {
352 mSizeInfo = newPs;
353 }
The Android Open Source Projectde2d9f52008-10-21 07:00:00 -0700354 }
The Android Open Source Projectabc48f82008-12-17 18:06:01 -0800355
356 long data = mSizeInfo.dataSize+mSizeInfo.cacheSize;
357 // Disable button if data is 0
358 if(mAppButtonState != AppButtonStates.NONE){
359 mAppButton.setText(mAppButtonText);
360 if((mAppButtonState == AppButtonStates.CLEAR_DATA) && (data == 0)) {
361 mAppButton.setEnabled(false);
362 } else {
363 mAppButton.setEnabled(true);
364 mAppButton.setOnClickListener(this);
365 }
366 }
367 refreshCacheInfo(newPs.cacheSize);
368 }
369
370 private void refreshCacheInfo(long cacheSize) {
371 // Set cache info
372 mCacheSize.setText(getSizeStr(cacheSize));
373 if (cacheSize <= 0) {
374 mClearCacheButton.setEnabled(false);
375 } else {
376 mClearCacheButton.setOnClickListener(this);
377 }
The Android Open Source Projectde2d9f52008-10-21 07:00:00 -0700378 }
379
380 /*
381 * Private method to handle clear message notification from observer when
382 * the async operation from PackageManager is complete
383 */
384 private void processClearMsg(Message msg) {
385 int result = msg.arg1;
386 String packageName = mAppInfo.packageName;
387 if(result == OP_SUCCESSFUL) {
388 Log.i(TAG, "Cleared user data for system package:"+packageName);
The Android Open Source Projectabc48f82008-12-17 18:06:01 -0800389 mPm.getPackageSizeInfo(packageName, mSizeObserver);
The Android Open Source Projectde2d9f52008-10-21 07:00:00 -0700390 } else {
The Android Open Source Projectabc48f82008-12-17 18:06:01 -0800391 mAppButton.setText(R.string.clear_user_data_text);
392 mAppButton.setEnabled(true);
The Android Open Source Projectde2d9f52008-10-21 07:00:00 -0700393 }
394 }
395
396 /*
397 * Private method to initiate clearing user data when the user clicks the clear data
398 * button for a system package
399 */
400 private void initiateClearUserDataForSysPkg() {
The Android Open Source Projectabc48f82008-12-17 18:06:01 -0800401 mAppButton.setEnabled(false);
The Android Open Source Projectde2d9f52008-10-21 07:00:00 -0700402 //invoke uninstall or clear user data based on sysPackage
The Android Open Source Projectde2d9f52008-10-21 07:00:00 -0700403 String packageName = mAppInfo.packageName;
404 Log.i(TAG, "Clearing user data for system package");
The Android Open Source Projectabc48f82008-12-17 18:06:01 -0800405 if(mClearDataObserver == null) {
406 mClearDataObserver = new ClearUserDataObserver();
407 }
The Android Open Source Projectde2d9f52008-10-21 07:00:00 -0700408 ActivityManager am = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
The Android Open Source Projectabc48f82008-12-17 18:06:01 -0800409 boolean res = am.clearApplicationUserData(packageName, mClearDataObserver);
The Android Open Source Projectde2d9f52008-10-21 07:00:00 -0700410 if(!res) {
411 //doesnt initiate clear. some error. should not happen but just log error for now
412 Log.i(TAG, "Couldnt clear application user data for package:"+packageName);
413 displayErrorDialog(R.string.clear_data_failed, false, false);
414 } else {
The Android Open Source Projectabc48f82008-12-17 18:06:01 -0800415 mAppButton.setText(R.string.recompute_size);
The Android Open Source Projectde2d9f52008-10-21 07:00:00 -0700416 }
417 }
418
419 /*
420 * Method implementing functionality of buttons clicked
421 * @see android.view.View.OnClickListener#onClick(android.view.View)
422 */
423 public void onClick(View v) {
424 String packageName = mAppInfo.packageName;
The Android Open Source Projectabc48f82008-12-17 18:06:01 -0800425 if(v == mAppButton) {
426 if(mCanUninstall) {
The Android Open Source Projectde2d9f52008-10-21 07:00:00 -0700427 //display confirmation dialog
428 new AlertDialog.Builder(this)
429 .setTitle(getString(R.string.clear_data_dlg_title))
The Android Open Source Project5962e182009-01-09 17:51:25 -0800430 .setIcon(android.R.drawable.ic_dialog_alert)
The Android Open Source Projectde2d9f52008-10-21 07:00:00 -0700431 .setMessage(getString(R.string.clear_data_dlg_text))
432 .setPositiveButton(R.string.dlg_ok, this)
433 .setNegativeButton(R.string.dlg_cancel, this)
434 .show();
435 } else {
436 //create new intent to launch Uninstaller activity
437 Uri packageURI = Uri.parse("package:"+packageName);
438 Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageURI);
439 startActivity(uninstallIntent);
440 setIntentAndFinish(true, false);
441 }
442 } else if(v == mActivitiesButton) {
443 mPm.clearPackagePreferredActivities(packageName);
444 mActivitiesButton.setEnabled(false);
445 } else if(v == mManageSpaceButton) {
446 Intent intent = new Intent(Intent.ACTION_DEFAULT);
447 intent.setClassName(mAppInfo.packageName, mAppInfo.manageSpaceActivityName);
448 startActivityForResult(intent, -1);
The Android Open Source Projectabc48f82008-12-17 18:06:01 -0800449 } else if (v == mClearCacheButton) {
450 // Lazy initialization of observer
451 if (mClearCacheObserver == null) {
452 mClearCacheObserver = new ClearCacheObserver();
453 }
454 mPm.deleteApplicationCacheFiles(packageName, mClearCacheObserver);
The Android Open Source Project1feaa852009-02-10 15:44:05 -0800455 } else if (v == mForceStopButton) {
456 ActivityManager am = (ActivityManager)getSystemService(
457 Context.ACTIVITY_SERVICE);
458 am.restartPackage(packageName);
The Android Open Source Projectde2d9f52008-10-21 07:00:00 -0700459 }
460 }
461
462 public void onClick(DialogInterface dialog, int which) {
The Android Open Source Projectabc48f82008-12-17 18:06:01 -0800463 if(which == AlertDialog.BUTTON_POSITIVE) {
The Android Open Source Projectde2d9f52008-10-21 07:00:00 -0700464 //invoke uninstall or clear user data based on sysPackage
465 initiateClearUserDataForSysPkg();
466 } else {
467 //cancel do nothing just retain existing screen
468 }
469 }
470}
471