Loading core/java/android/app/ApplicationContext.java +50 −21 Original line number Diff line number Diff line Loading @@ -2164,6 +2164,11 @@ class ApplicationContext extends Context { filter.addDataScheme("package"); mContext.registerReceiverInternal(sPackageRemovedReceiver, filter, null, null, null); // Register for events related to sdcard installation. IntentFilter sdFilter = new IntentFilter(); sdFilter.addAction(Intent.ACTION_MEDIA_RESOURCES_UNAVAILABLE); mContext.registerReceiverInternal(sPackageRemovedReceiver, sdFilter, null, null, null); } } } Loading @@ -2181,10 +2186,25 @@ class ApplicationContext extends Context { private static final class PackageRemovedReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { String pkgList[] = null; String action = intent.getAction(); boolean immediateGc = false; if (Intent.ACTION_MEDIA_RESOURCES_UNAVAILABLE.equals(action)) { pkgList = intent.getStringArrayExtra(Intent.EXTRA_CHANGED_PACKAGE_LIST); immediateGc = true; } else { Uri data = intent.getData(); String ssp; if (data != null && (ssp=data.getSchemeSpecificPart()) != null) { if (data != null) { String ssp = data.getSchemeSpecificPart(); if (ssp != null) { pkgList = new String[] { ssp }; } } } if (pkgList != null && (pkgList.length > 0)) { boolean needCleanup = false; boolean hasPkgInfo = false; for (String ssp : pkgList) { synchronized (sSync) { Iterator<ResourceName> it = sIconCache.keySet().iterator(); while (it.hasNext()) { Loading @@ -2205,12 +2225,21 @@ class ApplicationContext extends Context { } } } if (needCleanup || ActivityThread.currentActivityThread().hasPackageInfo(ssp)) { if (!hasPkgInfo) { hasPkgInfo = ActivityThread.currentActivityThread().hasPackageInfo(ssp); } } if (needCleanup || hasPkgInfo) { if (immediateGc) { // Schedule an immediate gc. Runtime.getRuntime().gc(); } else { ActivityThread.currentActivityThread().scheduleGcIdler(); } } } } } private static final class ResourceName { final String packageName; Loading core/java/android/content/Intent.java +76 −1 Original line number Diff line number Diff line Loading @@ -1355,6 +1355,60 @@ public class Intent implements Parcelable, Cloneable { */ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED"; /** * Broadcast Action: Resources for a set of packages (which were * previously unavailable) are currently * available since the media on which they exist is available. * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a * list of packages whose availability changed. * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a * list of uids of packages whose availability changed. * Note that the * packages in this list do <em>not</em> receive this broadcast. * The specified set of packages are now available on the system. * <p>Includes the following extras: * <ul> * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages * whose resources(were previously unavailable) are currently available. * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the * packages whose resources(were previously unavailable) * are currently available. * </ul> * * <p class="note">This is a protected intent that can only be sent * by the system. * @hide */ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) public static final String ACTION_MEDIA_RESOURCES_AVAILABLE = "android.intent.action.MEDIA_RESOURCES_AVAILABILE"; /** * Broadcast Action: Resources for a set of packages are currently * unavailable since the media on which they exist is unavailable. * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a * list of packages whose availability changed. * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a * list of uids of packages whose availability changed. * The specified set of packages can no longer be * launched and are practically unavailable on the system. * <p>Inclues the following extras: * <ul> * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages * whose resources are no longer available. * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages * whose resources are no longer available. * </ul> * * <p class="note">This is a protected intent that can only be sent * by the system. * @hide */ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) public static final String ACTION_MEDIA_RESOURCES_UNAVAILABLE = "android.intent.action.MEDIA_RESOURCES_UNAVAILABILE"; /** * Broadcast Action: The current system wallpaper has changed. See * {@link android.app.WallpaperManager} for retrieving the new wallpaper. Loading Loading @@ -2136,12 +2190,33 @@ public class Intent implements Parcelable, Cloneable { "android.intent.extra.changed_component_name"; /** * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED} * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED}, * and contains a string array of all of the components that have changed. */ public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST = "android.intent.extra.changed_component_name_list"; /** * This field is part of * {@link android.content.Intent#ACTION_MEDIA_RESOURCES_AVAILABLE}, * {@link android.content.Intent#ACTION_MEDIA_RESOURCES_UNAVAILABLE} * and contains a string array of all of the components that have changed. * @hide */ public static final String EXTRA_CHANGED_PACKAGE_LIST = "android.intent.extra.changed_package_list"; /** * This field is part of * {@link android.content.Intent#ACTION_MEDIA_RESOURCES_AVAILABLE}, * {@link android.content.Intent#ACTION_MEDIA_RESOURCES_UNAVAILABLE} * and contains an integer array of uids of all of the components * that have changed. * @hide */ public static final String EXTRA_CHANGED_UID_LIST = "android.intent.extra.changed_uid_list"; /** * @hide * Magic extra system code can use when binding, to give a label for Loading core/java/android/content/pm/RegisteredServicesCache.java +5 −0 Original line number Diff line number Diff line Loading @@ -115,6 +115,11 @@ public abstract class RegisteredServicesCache<V> { intentFilter.addAction(Intent.ACTION_PACKAGE_REMOVED); intentFilter.addDataScheme("package"); mContext.registerReceiver(receiver, intentFilter); // Register for events related to sdcard installation. IntentFilter sdFilter = new IntentFilter(); sdFilter.addAction(Intent.ACTION_MEDIA_RESOURCES_AVAILABLE); sdFilter.addAction(Intent.ACTION_MEDIA_RESOURCES_UNAVAILABLE); mContext.registerReceiver(receiver, sdFilter); } public void dump(FileDescriptor fd, PrintWriter fout, String[] args) { Loading core/java/android/server/search/SearchManagerService.java +8 −1 Original line number Diff line number Diff line Loading @@ -73,6 +73,11 @@ public class SearchManagerService extends ISearchManager.Stub { packageFilter.addAction(Intent.ACTION_PACKAGE_CHANGED); packageFilter.addDataScheme("package"); mContext.registerReceiver(mPackageChangedReceiver, packageFilter); // Register for events related to sdcard installation. IntentFilter sdFilter = new IntentFilter(); sdFilter.addAction(Intent.ACTION_MEDIA_RESOURCES_AVAILABLE); sdFilter.addAction(Intent.ACTION_MEDIA_RESOURCES_UNAVAILABLE); mContext.registerReceiver(mPackageChangedReceiver, sdFilter); } private synchronized Searchables getSearchables() { Loading @@ -90,7 +95,9 @@ public class SearchManagerService extends ISearchManager.Stub { if (Intent.ACTION_PACKAGE_ADDED.equals(action) || Intent.ACTION_PACKAGE_REMOVED.equals(action) || Intent.ACTION_PACKAGE_CHANGED.equals(action)) { Intent.ACTION_PACKAGE_CHANGED.equals(action) || Intent.ACTION_MEDIA_RESOURCES_AVAILABLE.equals(action) || Intent.ACTION_MEDIA_RESOURCES_UNAVAILABLE.equals(action)) { if (DBG) Log.d(TAG, "Got " + action); // Update list of searchable activities getSearchables().buildSearchableList(); Loading packages/DefaultContainerService/src/com/android/defcontainer/DefaultContainerService.java +10 −3 Original line number Diff line number Diff line Loading @@ -97,11 +97,13 @@ public class DefaultContainerService extends Service { int errCode = CREATE_FAILED; // Create new container if ((newCachePath = createSdDir(packageURI, newCacheId, key)) != null) { if (localLOGV) Log.i(TAG, "Created container for " + newCacheId + " at path : " + newCachePath); File resFile = new File(newCachePath, resFileName); errCode = COPY_FAILED; if (localLOGV) Log.i(TAG, "Trying to copy " + codePath + " to " + resFile); // Copy file from codePath if (FileUtils.copyFile(new File(codePath), resFile)) { if (localLOGV) Log.i(TAG, "Copied " + codePath + " to " + resFile); errCode = FINALIZE_FAILED; if (finalizeSdDir(newCacheId)) { errCode = PASS; Loading @@ -116,18 +118,23 @@ public class DefaultContainerService extends Service { break; case COPY_FAILED: errMsg = "COPY_FAILED"; if (localLOGV) Log.i(TAG, "Destroying " + newCacheId + " at path " + newCachePath + " after " + errMsg); destroySdDir(newCacheId); break; case FINALIZE_FAILED: errMsg = "FINALIZE_FAILED"; if (localLOGV) Log.i(TAG, "Destroying " + newCacheId + " at path " + newCachePath + " after " + errMsg); destroySdDir(newCacheId); break; default: errMsg = "PASS"; if (localLOGV) Log.i(TAG, "Unmounting " + newCacheId + " at path " + newCachePath + " after " + errMsg); unMountSdDir(newCacheId); break; } Log.i(TAG, "Status: " + errMsg); if (errCode != PASS) { return null; } Loading Loading
core/java/android/app/ApplicationContext.java +50 −21 Original line number Diff line number Diff line Loading @@ -2164,6 +2164,11 @@ class ApplicationContext extends Context { filter.addDataScheme("package"); mContext.registerReceiverInternal(sPackageRemovedReceiver, filter, null, null, null); // Register for events related to sdcard installation. IntentFilter sdFilter = new IntentFilter(); sdFilter.addAction(Intent.ACTION_MEDIA_RESOURCES_UNAVAILABLE); mContext.registerReceiverInternal(sPackageRemovedReceiver, sdFilter, null, null, null); } } } Loading @@ -2181,10 +2186,25 @@ class ApplicationContext extends Context { private static final class PackageRemovedReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { String pkgList[] = null; String action = intent.getAction(); boolean immediateGc = false; if (Intent.ACTION_MEDIA_RESOURCES_UNAVAILABLE.equals(action)) { pkgList = intent.getStringArrayExtra(Intent.EXTRA_CHANGED_PACKAGE_LIST); immediateGc = true; } else { Uri data = intent.getData(); String ssp; if (data != null && (ssp=data.getSchemeSpecificPart()) != null) { if (data != null) { String ssp = data.getSchemeSpecificPart(); if (ssp != null) { pkgList = new String[] { ssp }; } } } if (pkgList != null && (pkgList.length > 0)) { boolean needCleanup = false; boolean hasPkgInfo = false; for (String ssp : pkgList) { synchronized (sSync) { Iterator<ResourceName> it = sIconCache.keySet().iterator(); while (it.hasNext()) { Loading @@ -2205,12 +2225,21 @@ class ApplicationContext extends Context { } } } if (needCleanup || ActivityThread.currentActivityThread().hasPackageInfo(ssp)) { if (!hasPkgInfo) { hasPkgInfo = ActivityThread.currentActivityThread().hasPackageInfo(ssp); } } if (needCleanup || hasPkgInfo) { if (immediateGc) { // Schedule an immediate gc. Runtime.getRuntime().gc(); } else { ActivityThread.currentActivityThread().scheduleGcIdler(); } } } } } private static final class ResourceName { final String packageName; Loading
core/java/android/content/Intent.java +76 −1 Original line number Diff line number Diff line Loading @@ -1355,6 +1355,60 @@ public class Intent implements Parcelable, Cloneable { */ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED"; /** * Broadcast Action: Resources for a set of packages (which were * previously unavailable) are currently * available since the media on which they exist is available. * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a * list of packages whose availability changed. * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a * list of uids of packages whose availability changed. * Note that the * packages in this list do <em>not</em> receive this broadcast. * The specified set of packages are now available on the system. * <p>Includes the following extras: * <ul> * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages * whose resources(were previously unavailable) are currently available. * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the * packages whose resources(were previously unavailable) * are currently available. * </ul> * * <p class="note">This is a protected intent that can only be sent * by the system. * @hide */ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) public static final String ACTION_MEDIA_RESOURCES_AVAILABLE = "android.intent.action.MEDIA_RESOURCES_AVAILABILE"; /** * Broadcast Action: Resources for a set of packages are currently * unavailable since the media on which they exist is unavailable. * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a * list of packages whose availability changed. * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a * list of uids of packages whose availability changed. * The specified set of packages can no longer be * launched and are practically unavailable on the system. * <p>Inclues the following extras: * <ul> * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages * whose resources are no longer available. * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages * whose resources are no longer available. * </ul> * * <p class="note">This is a protected intent that can only be sent * by the system. * @hide */ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) public static final String ACTION_MEDIA_RESOURCES_UNAVAILABLE = "android.intent.action.MEDIA_RESOURCES_UNAVAILABILE"; /** * Broadcast Action: The current system wallpaper has changed. See * {@link android.app.WallpaperManager} for retrieving the new wallpaper. Loading Loading @@ -2136,12 +2190,33 @@ public class Intent implements Parcelable, Cloneable { "android.intent.extra.changed_component_name"; /** * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED} * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED}, * and contains a string array of all of the components that have changed. */ public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST = "android.intent.extra.changed_component_name_list"; /** * This field is part of * {@link android.content.Intent#ACTION_MEDIA_RESOURCES_AVAILABLE}, * {@link android.content.Intent#ACTION_MEDIA_RESOURCES_UNAVAILABLE} * and contains a string array of all of the components that have changed. * @hide */ public static final String EXTRA_CHANGED_PACKAGE_LIST = "android.intent.extra.changed_package_list"; /** * This field is part of * {@link android.content.Intent#ACTION_MEDIA_RESOURCES_AVAILABLE}, * {@link android.content.Intent#ACTION_MEDIA_RESOURCES_UNAVAILABLE} * and contains an integer array of uids of all of the components * that have changed. * @hide */ public static final String EXTRA_CHANGED_UID_LIST = "android.intent.extra.changed_uid_list"; /** * @hide * Magic extra system code can use when binding, to give a label for Loading
core/java/android/content/pm/RegisteredServicesCache.java +5 −0 Original line number Diff line number Diff line Loading @@ -115,6 +115,11 @@ public abstract class RegisteredServicesCache<V> { intentFilter.addAction(Intent.ACTION_PACKAGE_REMOVED); intentFilter.addDataScheme("package"); mContext.registerReceiver(receiver, intentFilter); // Register for events related to sdcard installation. IntentFilter sdFilter = new IntentFilter(); sdFilter.addAction(Intent.ACTION_MEDIA_RESOURCES_AVAILABLE); sdFilter.addAction(Intent.ACTION_MEDIA_RESOURCES_UNAVAILABLE); mContext.registerReceiver(receiver, sdFilter); } public void dump(FileDescriptor fd, PrintWriter fout, String[] args) { Loading
core/java/android/server/search/SearchManagerService.java +8 −1 Original line number Diff line number Diff line Loading @@ -73,6 +73,11 @@ public class SearchManagerService extends ISearchManager.Stub { packageFilter.addAction(Intent.ACTION_PACKAGE_CHANGED); packageFilter.addDataScheme("package"); mContext.registerReceiver(mPackageChangedReceiver, packageFilter); // Register for events related to sdcard installation. IntentFilter sdFilter = new IntentFilter(); sdFilter.addAction(Intent.ACTION_MEDIA_RESOURCES_AVAILABLE); sdFilter.addAction(Intent.ACTION_MEDIA_RESOURCES_UNAVAILABLE); mContext.registerReceiver(mPackageChangedReceiver, sdFilter); } private synchronized Searchables getSearchables() { Loading @@ -90,7 +95,9 @@ public class SearchManagerService extends ISearchManager.Stub { if (Intent.ACTION_PACKAGE_ADDED.equals(action) || Intent.ACTION_PACKAGE_REMOVED.equals(action) || Intent.ACTION_PACKAGE_CHANGED.equals(action)) { Intent.ACTION_PACKAGE_CHANGED.equals(action) || Intent.ACTION_MEDIA_RESOURCES_AVAILABLE.equals(action) || Intent.ACTION_MEDIA_RESOURCES_UNAVAILABLE.equals(action)) { if (DBG) Log.d(TAG, "Got " + action); // Update list of searchable activities getSearchables().buildSearchableList(); Loading
packages/DefaultContainerService/src/com/android/defcontainer/DefaultContainerService.java +10 −3 Original line number Diff line number Diff line Loading @@ -97,11 +97,13 @@ public class DefaultContainerService extends Service { int errCode = CREATE_FAILED; // Create new container if ((newCachePath = createSdDir(packageURI, newCacheId, key)) != null) { if (localLOGV) Log.i(TAG, "Created container for " + newCacheId + " at path : " + newCachePath); File resFile = new File(newCachePath, resFileName); errCode = COPY_FAILED; if (localLOGV) Log.i(TAG, "Trying to copy " + codePath + " to " + resFile); // Copy file from codePath if (FileUtils.copyFile(new File(codePath), resFile)) { if (localLOGV) Log.i(TAG, "Copied " + codePath + " to " + resFile); errCode = FINALIZE_FAILED; if (finalizeSdDir(newCacheId)) { errCode = PASS; Loading @@ -116,18 +118,23 @@ public class DefaultContainerService extends Service { break; case COPY_FAILED: errMsg = "COPY_FAILED"; if (localLOGV) Log.i(TAG, "Destroying " + newCacheId + " at path " + newCachePath + " after " + errMsg); destroySdDir(newCacheId); break; case FINALIZE_FAILED: errMsg = "FINALIZE_FAILED"; if (localLOGV) Log.i(TAG, "Destroying " + newCacheId + " at path " + newCachePath + " after " + errMsg); destroySdDir(newCacheId); break; default: errMsg = "PASS"; if (localLOGV) Log.i(TAG, "Unmounting " + newCacheId + " at path " + newCachePath + " after " + errMsg); unMountSdDir(newCacheId); break; } Log.i(TAG, "Status: " + errMsg); if (errCode != PASS) { return null; } Loading