1/* 2 * Copyright (C) 2009 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.cooliris.cache; 18 19import com.cooliris.media.LocalDataSource; 20import com.cooliris.media.PicasaDataSource; 21import com.cooliris.media.LocalDataSource; 22import com.cooliris.media.Utils; 23 24import android.content.BroadcastReceiver; 25import android.content.Context; 26import android.content.Intent; 27import android.net.Uri; 28import android.util.Log; 29 30public class BootReceiver extends BroadcastReceiver { 31 private static final String TAG = "BootReceiver"; 32 33 @Override 34 public void onReceive(final Context context, Intent intent) { 35 final String action = intent.getAction(); 36 Log.i(TAG, "Got intent with action " + action); 37 if (Intent.ACTION_MEDIA_SCANNER_FINISHED.equals(action)) { 38 ; 39 } else if (Intent.ACTION_MEDIA_MOUNTED.equals(action)) { 40 ; 41 } else if (action.equals(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE)) { 42 final Uri fileUri = intent.getData(); 43 final long bucketId = Utils.getBucketIdFromUri(context.getContentResolver(), fileUri); 44 if (!CacheService.isPresentInCache(bucketId)) { 45 CacheService.markDirty(); 46 } 47 } else if (action.equals(Intent.ACTION_MEDIA_EJECT)) { 48 LocalDataSource.sThumbnailCache.close(); 49 LocalDataSource.sThumbnailCacheVideo.close(); 50 PicasaDataSource.sThumbnailCache.close(); 51 CacheService.sAlbumCache.close(); 52 CacheService.sMetaAlbumCache.close(); 53 CacheService.sSkipThumbnailIds.flush(); 54 } 55 } 56} 57