Home | History | Annotate | Download | only in errorhandling
      1 /*
      2  * Copyright (C) 2015 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.android.camera.one.v2.errorhandling;
     18 
     19 import com.android.camera.FatalErrorHandler;
     20 import com.android.camera.stats.UsageStatistics;
     21 import com.google.common.logging.eventprotos;
     22 
     23 import javax.annotation.ParametersAreNonnullByDefault;
     24 
     25 /**
     26  * Handles repeat failure by displaying the fatal error dialog (which also
     27  * finishes the activity).
     28  */
     29 @ParametersAreNonnullByDefault
     30 final class FatalErrorDialogFailureHandler implements FailureHandler {
     31     private final FatalErrorHandler mFatalErrorHandler;
     32     private final UsageStatistics mUsageStats;
     33 
     34     FatalErrorDialogFailureHandler(FatalErrorHandler fatalErrorHandler,
     35             UsageStatistics usageStats) {
     36         mFatalErrorHandler = fatalErrorHandler;
     37         mUsageStats = usageStats;
     38     }
     39 
     40     @Override
     41     public void run() {
     42         mUsageStats.cameraFailure(eventprotos.CameraFailure.FailureReason.UNKNOWN_REASON,
     43                 "api2_repeated_failure_2", UsageStatistics.NONE, UsageStatistics.NONE);
     44         // TODO Add another {@link FatalErrorHandler.Reason} for this situation
     45         mFatalErrorHandler.handleFatalError(FatalErrorHandler.Reason.CANNOT_CONNECT_TO_CAMERA);
     46     }
     47 }
     48