Home | History | Annotate | Download | only in cache
      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 
     17 package com.cooliris.cache;
     18 
     19 import com.cooliris.media.LocalDataSource;
     20 import com.cooliris.media.PicasaDataSource;
     21 import com.cooliris.media.LocalDataSource;
     22 import com.cooliris.media.Utils;
     23 
     24 import android.content.BroadcastReceiver;
     25 import android.content.Context;
     26 import android.content.Intent;
     27 import android.net.Uri;
     28 import android.util.Log;
     29 
     30 public 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