• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2013 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.app;
18 
19 import android.content.Context;
20 
21 import com.android.camera.module.ModuleController;
22 import com.android.camera.settings.SettingsManager;
23 
24 import java.util.List;
25 
26 /**
27  * The module manager which maintains the
28  * {@link ModuleManagerImpl.ModuleAgent}.
29  */
30 public interface ModuleManager {
31     public static int MODULE_INDEX_NONE = -1;
32 
33     /**
34      * The module agent which is responsible for maintaining the static
35      * characteristics and the creation of the module.
36      */
37     public static interface ModuleAgent {
38 
39         /**
40          * @return The module ID.
41          */
getModuleId()42         public int getModuleId();
43 
44         /**
45          * @return Whether the module will request the app for the camera.
46          */
requestAppForCamera()47         public boolean requestAppForCamera();
48 
49         /**
50          * Creates the module.
51          *
52          * @param app The {@link com.android.camera.app.AppController} which
53          *            creates this module.
54          * @return The module.
55          */
createModule(AppController app)56         public ModuleController createModule(AppController app);
57     }
58 
59     /**
60      * Registers a module. A module will be available only if its agent is
61      * registered. The registration might fail.
62      *
63      * @param agent The {@link com.android.camera.app.ModuleManager.ModuleAgent}
64      *              of the module.
65      * @throws java.lang.NullPointerException if the {@code agent} is null.
66      * @throws java.lang.IllegalArgumentException if the module ID is
67      * {@code MODULE_INDEX} or another module with the sameID is registered
68      * already.
69      */
registerModule(ModuleAgent agent)70     void registerModule(ModuleAgent agent);
71 
72     /**
73      * Unregister a module.
74      *
75      * @param moduleId The module ID.
76      * @return Whether the un-registration succeeds.
77      */
unregisterModule(int moduleId)78     boolean unregisterModule(int moduleId);
79 
80     /**
81      * @return A {@link java.util.List} of the
82      * {@link com.android.camera.app.ModuleManager.ModuleAgent} of all the
83      * registered modules.
84      */
getRegisteredModuleAgents()85     List<ModuleAgent> getRegisteredModuleAgents();
86 
87     /**
88      * @return A {@link java.util.List} of the
89      * {@link com.android.camera.app.ModuleManager.ModuleAgent} of all the
90      * registered modules' indices.
91      */
getSupportedModeIndexList()92     List<Integer> getSupportedModeIndexList();
93 
94     /**
95      * Sets the default module index. No-op if the module index does not exist.
96      *
97      * @param moduleId The ID of the default module.
98      * @return Whether the {@code moduleId} exists.
99      */
setDefaultModuleIndex(int moduleId)100     boolean setDefaultModuleIndex(int moduleId);
101 
102     /**
103      * @return The default module index. {@code MODULE_INDEX_NONE} if not set.
104      */
getDefaultModuleIndex()105     int getDefaultModuleIndex();
106 
107     /**
108      * Returns the {@link com.android.camera.app.ModuleManager.ModuleAgent} by
109      * the module ID.
110      *
111      * @param moduleId The module ID.
112      * @return The agent.
113      */
getModuleAgent(int moduleId)114     ModuleAgent getModuleAgent(int moduleId);
115 
116     /**
117      * Gets the mode that can be switched to from the given mode id through
118      * quick switch.
119      *
120      * @param moduleId index of the mode to switch from
121      * @param settingsManager settings manager for querying last used camera module
122      * @param context the context the activity is running in
123      * @return mode id to quick switch to if index is valid, otherwise returns
124      *         the given mode id itself
125      */
getQuickSwitchToModuleId(int moduleId, SettingsManager settingsManager, Context context)126     int getQuickSwitchToModuleId(int moduleId, SettingsManager settingsManager, Context context);
127 }
128