summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorSuchi Amalapurapu <asuchitra@google.com>2009-06-12 10:09:58 -0700
committerSuchi Amalapurapu <asuchitra@google.com>2009-06-17 11:31:26 -0700
commit1ccac75e1f1b97eccb916a8de04fc1012b30f6e5 (patch)
tree181c91a427de2ea609eff1f42c3970a441225b45 /services
parentef29f6afb4746eae8263ab901a5d3677bc04574b (diff)
downloadframeworks_base-1ccac75e1f1b97eccb916a8de04fc1012b30f6e5.zip
frameworks_base-1ccac75e1f1b97eccb916a8de04fc1012b30f6e5.tar.gz
frameworks_base-1ccac75e1f1b97eccb916a8de04fc1012b30f6e5.tar.bz2
Remove circular dependency in PackageManager. api freeStorage uses PendingIntent from android.app
Create a new public IntentSender class that can be used by PackageManager instead. This new class uses IIntentSender internally and can only be created by PendingIntent for now. Provide a new getIntentSender api in PendingIntent to create an instance of this class. Move IIntentSender and IIntentReceiver from android.app to android.content Change imports of IIntentSender and IIntentReceiver to reflect the new package name The PackageManager api has been named as freeStorageWithIntent and will be renamed as freeStorage once the older api(which has been deprecated) will be removed shortly.
Diffstat (limited to 'services')
-rw-r--r--services/java/com/android/server/PackageManagerService.java30
-rw-r--r--services/java/com/android/server/am/ActivityManagerService.java4
-rw-r--r--services/java/com/android/server/am/BroadcastRecord.java2
-rw-r--r--services/java/com/android/server/am/PendingIntentRecord.java4
-rw-r--r--services/java/com/android/server/am/ReceiverList.java2
5 files changed, 36 insertions, 6 deletions
diff --git a/services/java/com/android/server/PackageManagerService.java b/services/java/com/android/server/PackageManagerService.java
index 0d142da..73478e4 100644
--- a/services/java/com/android/server/PackageManagerService.java
+++ b/services/java/com/android/server/PackageManagerService.java
@@ -34,6 +34,8 @@ import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.content.IntentSender;
+import android.content.IntentSender.SendIntentException;
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.ComponentInfo;
@@ -955,6 +957,34 @@ class PackageManagerService extends IPackageManager.Stub {
}
});
}
+
+ public void freeStorageWithIntent(final long freeStorageSize, final IntentSender pi) {
+ mContext.enforceCallingOrSelfPermission(
+ android.Manifest.permission.CLEAR_APP_CACHE, null);
+ // Queue up an async operation since clearing cache may take a little while.
+ mHandler.post(new Runnable() {
+ public void run() {
+ mHandler.removeCallbacks(this);
+ int retCode = -1;
+ if (mInstaller != null) {
+ retCode = mInstaller.freeCache(freeStorageSize);
+ if (retCode < 0) {
+ Log.w(TAG, "Couldn't clear application caches");
+ }
+ }
+ if(pi != null) {
+ try {
+ // Callback via pending intent
+ int code = (retCode >= 0) ? 1 : 0;
+ pi.sendIntent(null, code, null,
+ null, null);
+ } catch (SendIntentException e1) {
+ Log.i(TAG, "Failed to send pending intent");
+ }
+ }
+ }
+ });
+ }
public ActivityInfo getActivityInfo(ComponentName component, int flags) {
synchronized (mPackages) {
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index c0d4496..ae867fb 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -34,8 +34,6 @@ import android.app.Dialog;
import android.app.IActivityWatcher;
import android.app.IApplicationThread;
import android.app.IInstrumentationWatcher;
-import android.app.IIntentReceiver;
-import android.app.IIntentSender;
import android.app.IServiceConnection;
import android.app.IThumbnailReceiver;
import android.app.Instrumentation;
@@ -48,6 +46,8 @@ import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.content.IIntentReceiver;
+import android.content.IIntentSender;
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.ConfigurationInfo;
diff --git a/services/java/com/android/server/am/BroadcastRecord.java b/services/java/com/android/server/am/BroadcastRecord.java
index 4057ae8..da55049 100644
--- a/services/java/com/android/server/am/BroadcastRecord.java
+++ b/services/java/com/android/server/am/BroadcastRecord.java
@@ -16,7 +16,7 @@
package com.android.server.am;
-import android.app.IIntentReceiver;
+import android.content.IIntentReceiver;
import android.content.ComponentName;
import android.content.Intent;
import android.content.pm.ActivityInfo;
diff --git a/services/java/com/android/server/am/PendingIntentRecord.java b/services/java/com/android/server/am/PendingIntentRecord.java
index 4381392..fa2a100 100644
--- a/services/java/com/android/server/am/PendingIntentRecord.java
+++ b/services/java/com/android/server/am/PendingIntentRecord.java
@@ -17,8 +17,8 @@
package com.android.server.am;
import android.app.IActivityManager;
-import android.app.IIntentSender;
-import android.app.IIntentReceiver;
+import android.content.IIntentSender;
+import android.content.IIntentReceiver;
import android.app.PendingIntent;
import android.content.Intent;
import android.os.Binder;
diff --git a/services/java/com/android/server/am/ReceiverList.java b/services/java/com/android/server/am/ReceiverList.java
index 0facefc..32c24c6 100644
--- a/services/java/com/android/server/am/ReceiverList.java
+++ b/services/java/com/android/server/am/ReceiverList.java
@@ -16,7 +16,7 @@
package com.android.server.am;
-import android.app.IIntentReceiver;
+import android.content.IIntentReceiver;
import android.content.Intent;
import android.os.Binder;
import android.os.Bundle;