1 /* 2 * Copyright 2019 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 androidx.camera.integration.extensions; 18 19 import android.app.Application; 20 import android.util.Log; 21 22 import androidx.camera.camera2.Camera2Config; 23 import androidx.camera.core.CameraXConfig; 24 25 import org.jspecify.annotations.NonNull; 26 27 /** The application. */ 28 public class ExtensionsApplication extends Application implements CameraXConfig.Provider { 29 private static final String TAG = "ExtensionApplication"; 30 31 private CameraXConfig mCameraXConfig = Camera2Config.defaultConfig(); 32 33 @Override 34 @SuppressWarnings("ObjectToString") getCameraXConfig()35 public @NonNull CameraXConfig getCameraXConfig() { 36 Log.d(TAG, "Providing custom CameraXConfig through Application"); 37 return mCameraXConfig; 38 } 39 40 /** 41 * Sets the {@link CameraXConfig} we provide when CameraX invokes 42 * {@link CameraXConfig.Provider#getCameraXConfig}. 43 * 44 * @param cameraXConfig the CameraX config to set. 45 */ 46 @SuppressWarnings("ObjectToString") setCameraXConfig(@onNull CameraXConfig cameraXConfig)47 public void setCameraXConfig(@NonNull CameraXConfig cameraXConfig) { 48 if (cameraXConfig != mCameraXConfig) { 49 Log.d(TAG, "CameraXConfig changed through Application"); 50 mCameraXConfig = cameraXConfig; 51 } 52 } 53 } 54