blob: 2c08e14b4c00c7caf055b878ff36ddf781addb12 [file] [log] [blame]
Angus Kong20fad242013-11-11 18:23:46 -08001/*
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
17package com.android.camera.app;
18
19import com.android.camera.module.ModuleController;
20
21/**
22 * The module manager which maintains the
23 * {@link ModuleManagerImpl.ModuleAgent}.
24 */
25public interface ModuleManager {
26 public static int MODULE_INDEX_NONE = -1;
27
28 /**
29 * The module agent which is responsible for maintaining the static
30 * characteristics and the creation of the module.
31 */
32 public static interface ModuleAgent {
33
34 /**
35 * @return The module ID.
36 */
37 public int getModuleId();
38
39 /**
40 * @return Whether the module will request the app for the camera.
41 */
42 public boolean requestAppForCamera();
43
44 /**
45 * Creates the module.
46 * @return The module.
47 */
48 public ModuleController createModule();
49 }
50
51 /**
52 * Registers a module. A module will be available only if its agent is
53 * registered. The registration might fail.
54 *
55 * @param agent The {@link com.android.camera.app.ModuleManager.ModuleAgent}
56 * of the module.
57 * @throws java.lang.NullPointerException if the {@code agent} is null.
58 * @throws java.lang.IllegalArgumentException if the module ID is
59 * {@code MODULE_INDEX} or another module with the sameID is registered
60 * already.
61 */
62 void registerModule(ModuleAgent agent);
63
64 /**
65 * Unregister a module.
66 *
67 * @param moduleId The module ID.
68 * @return Whether the un-registration succeeds.
69 */
70 boolean unregisterModule(int moduleId);
71
72 /**
73 * Sets the default module index. No-op if the module index does not exist.
74 *
75 * @param moduleId The ID of the default module.
76 * @return Whether the {@code moduleId} exists.
77 */
78 boolean setDefaultModuleIndex(int moduleId);
79
80 /**
81 * @return The default module index. {@code MODULE_INDEX_NONE} if not set.
82 */
83 int getDefaultModuleIndex();
84
85 /**
86 * Returns the {@link com.android.camera.app.ModuleManager.ModuleAgent} by
87 * the module ID.
88 *
89 * @param moduleId The module ID.
90 * @return The agent.
91 */
92 ModuleAgent getModuleAgent(int moduleId);
93}