• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021-2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef INTERFACES_INNERKITS_NATIVE_INCLUDE_MEDIA_DATA_ABILITY_CONST_H_
17 #define INTERFACES_INNERKITS_NATIVE_INCLUDE_MEDIA_DATA_ABILITY_CONST_H_
18 
19 #include "medialibrary_type_const.h"
20 namespace OHOS {
21 namespace Media {
22 #ifdef RDB_UPGRADE_MOCK
23 const int32_t MEDIA_RDB_VERSION = 2;
24 #else
25 const int32_t MEDIA_RDB_VERSION = 1;
26 #endif
27 const std::string MEDIA_LIBRARY_VERSION = "1.0";
28 
29 const int32_t DEVICE_SYNCSTATUSING = 0;
30 const int32_t DEVICE_SYNCSTATUS_COMPLETE = 1;
31 
32 const std::string MEDIA_DATA_DEVICE_PATH = "local";
33 const std::string MEDIALIBRARY_TABLE = "Files";
34 const std::string SMARTALBUM_TABLE = "SmartAlbum";
35 const std::string SMARTALBUM_MAP_TABLE = "SmartAlbumMap";
36 const std::string CATEGORY_SMARTALBUM_MAP_TABLE = "CategorySmartAlbumMap";
37 const std::string MEDIATYPE_DIRECTORY_TABLE = "MediaTypeDirectory";
38 const std::string DEVICE_TABLE = "Device";
39 const std::string BUNDLE_PERMISSION_TABLE = "BundlePermission";
40 const std::string MEDIA_DATA_ABILITY_DB_NAME = "media_library.db";
41 
42 const std::string BUNDLE_NAME = "com.ohos.medialibrary.medialibrarydata";
43 
44 const std::string MEDIALIBRARY_DATA_ABILITY_PREFIX = "datashare://";
45 const std::string MEDIALIBRARY_DATA_URI_IDENTIFIER = "/media";
46 const std::string MEDIALIBRARY_MEDIA_PREFIX = MEDIALIBRARY_DATA_ABILITY_PREFIX +
47                                                      MEDIALIBRARY_DATA_URI_IDENTIFIER;
48 const std::string MEDIALIBRARY_TYPE_AUDIO_URI = "/audio";
49 const std::string MEDIALIBRARY_TYPE_VIDEO_URI = "/video";
50 const std::string MEDIALIBRARY_TYPE_IMAGE_URI = "/image";
51 const std::string MEDIALIBRARY_TYPE_FILE_URI  =  "/file";
52 const std::string MEDIALIBRARY_TYPE_ALBUM_URI  =  "/album";
53 const std::string MEDIALIBRARY_TYPE_SMARTALBUM_CHANGE_URI  =  "/smartalbum";
54 const std::string MEDIALIBRARY_TYPE_DEVICE_URI  =  "/device";
55 const std::string MEDIALIBRARY_TYPE_SMART_URI = "/smart";
56 
57 const std::string MEDIALIBRARY_DATA_URI = "datashare:///media";
58 const std::string MEDIALIBRARY_SMARTALBUM_URI = MEDIALIBRARY_DATA_URI + "/" + SMARTALBUM_TABLE;
59 const std::string MEDIALIBRARY_SMARTALBUM_MAP_URI = MEDIALIBRARY_DATA_URI + "/" + SMARTALBUM_MAP_TABLE;
60 const std::string MEDIALIBRARY_CATEGORY_SMARTALBUM_MAP_URI = MEDIALIBRARY_DATA_URI + "/"
61                                                              + CATEGORY_SMARTALBUM_MAP_TABLE;
62 const std::string MEDIALIBRARY_DIRECTORY_URI = MEDIALIBRARY_DATA_URI + "/" + MEDIATYPE_DIRECTORY_TABLE;
63 const std::string MEDIALIBRARY_BUNDLEPERM_URI = MEDIALIBRARY_DATA_URI + "/" + BUNDLE_PERMISSION_TABLE;
64 
65 const std::string MEDIALIBRARY_AUDIO_URI = MEDIALIBRARY_DATA_URI + '/' + "audio";
66 const std::string MEDIALIBRARY_VIDEO_URI = MEDIALIBRARY_DATA_URI + '/' + "video";
67 const std::string MEDIALIBRARY_IMAGE_URI = MEDIALIBRARY_DATA_URI + '/' + "image";
68 const std::string MEDIALIBRARY_FILE_URI  =  MEDIALIBRARY_DATA_URI + '/' + "file";
69 const std::string MEDIALIBRARY_ALBUM_URI  =  MEDIALIBRARY_DATA_URI + '/' + "album";
70 const std::string MEDIALIBRARY_SMARTALBUM_CHANGE_URI  =  MEDIALIBRARY_DATA_URI + '/' + "smartalbum";
71 const std::string MEDIALIBRARY_DEVICE_URI  =  MEDIALIBRARY_DATA_URI + '/' + "device";
72 const std::string MEDIALIBRARY_SMART_URI = MEDIALIBRARY_DATA_URI + '/' + "smart";
73 const std::string MEDIALIBRARY_REMOTEFILE_URI = MEDIALIBRARY_DATA_URI + '/' + "remotfile";
74 
75 const std::string MEDIA_DATA_DB_ID = "file_id";
76 const std::string MEDIA_DATA_DB_URI = "uri";
77 const std::string MEDIA_DATA_DB_FILE_PATH = "data";
78 const std::string MEDIA_DATA_DB_SIZE = "size";
79 const std::string MEDIA_DATA_DB_PARENT_ID = "parent";
80 const std::string MEDIA_DATA_DB_DATE_MODIFIED = "date_modified";
81 const std::string MEDIA_DATA_DB_DATE_ADDED = "date_added";
82 const std::string MEDIA_DATA_DB_MIME_TYPE = "mime_type";
83 const std::string MEDIA_DATA_DB_TITLE = "title";
84 const std::string MEDIA_DATA_DB_DESCRIPTION = "description";
85 const std::string MEDIA_DATA_DB_NAME = "display_name";
86 const std::string MEDIA_DATA_DB_ORIENTATION = "orientation";
87 const std::string MEDIA_DATA_DB_LATITUDE = "latitude";
88 const std::string MEDIA_DATA_DB_LONGITUDE = "longitude";
89 const std::string MEDIA_DATA_DB_DATE_TAKEN = "date_taken";
90 const std::string MEDIA_DATA_DB_THUMBNAIL = "thumbnail";
91 const std::string MEDIA_DATA_DB_CONTENT_CREATE_TIME = "content_create_time";
92 
93 const std::string MEDIA_DATA_DB_LCD = "lcd";
94 const std::string MEDIA_DATA_DB_TIME_VISIT = "time_visit";
95 const std::string MEDIA_DATA_DB_BUCKET_ID = "bucket_id";
96 const std::string MEDIA_DATA_DB_BUCKET_NAME = "bucket_display_name";
97 const std::string MEDIA_DATA_DB_DURATION = "duration";
98 const std::string MEDIA_DATA_DB_ARTIST = "artist";
99 
100 const std::string MEDIA_DATA_DB_AUDIO_ALBUM = "audio_album";
101 const std::string MEDIA_DATA_DB_MEDIA_TYPE = "media_type";
102 
103 const std::string MEDIA_DATA_DB_HEIGHT = "height";
104 const std::string MEDIA_DATA_DB_WIDTH = "width";
105 const std::string MEDIA_DATA_DB_OWNER_PACKAGE = "owner_package";
106 
107 const std::string MEDIA_DATA_DB_IS_FAV = "is_favorite";
108 const std::string MEDIA_DATA_DB_IS_TRASH = "is_trash";
109 const std::string MEDIA_DATA_DB_RECYCLE_PATH = "recycle_path";
110 const std::string MEDIA_DATA_DB_DATE_TRASHED = "date_trashed";
111 const std::string MEDIA_DATA_DB_IS_PENDING = "is_pending";
112 const std::string MEDIA_DATA_DB_TIME_PENDING = "time_pending";
113 const std::string MEDIA_DATA_DB_RELATIVE_PATH = "relative_path";
114 const std::string MEDIA_DATA_DB_VOLUME_NAME = "volume_name";
115 const std::string MEDIA_DATA_DB_SELF_ID = "self_id";
116 
117 const std::string MEDIA_DATA_DB_ALBUM = "album";
118 const std::string MEDIA_DATA_DB_ALBUM_ID = "album_id";
119 const std::string MEDIA_DATA_DB_ALBUM_NAME = "album_name";
120 const std::string MEDIA_DATA_DB_COUNT = "count";
121 
122 // ringtone uri constants
123 const std::string MEDIA_DATA_DB_RINGTONE_URI = "ringtone_uri";
124 const std::string MEDIA_DATA_DB_ALARM_URI = "alarm_uri";
125 const std::string MEDIA_DATA_DB_NOTIFICATION_URI = "notification_uri";
126 const std::string MEDIA_DATA_DB_RINGTONE_TYPE = "ringtone_type";
127 
128 const std::string MEDIA_DATA_IMAGE_BITS_PER_SAMPLE = "BitsPerSample";
129 const std::string MEDIA_DATA_IMAGE_ORIENTATION = "Orientation";
130 const std::string MEDIA_DATA_IMAGE_IMAGE_LENGTH = "ImageLength";
131 const std::string MEDIA_DATA_IMAGE_IMAGE_WIDTH = "ImageWidth";
132 const std::string MEDIA_DATA_IMAGE_GPS_LATITUDE = "GPSLatitude";
133 const std::string MEDIA_DATA_IMAGE_GPS_LONGITUDE = "GPSLongitude";
134 const std::string MEDIA_DATA_IMAGE_GPS_LATITUDE_REF = "GPSLatitudeRef";
135 const std::string MEDIA_DATA_IMAGE_GPS_LONGITUDE_REF = "GPSLongitudeRef";
136 const std::string MEDIA_DATA_IMAGE_DATE_TIME_ORIGINAL = "DateTimeOriginalForMedia";
137 const std::string MEDIA_DATA_IMAGE_EXPOSURE_TIME = "ExposureTime";
138 const std::string MEDIA_DATA_IMAGE_F_NUMBER = "FNumber";
139 const std::string MEDIA_DATA_IMAGE_ISO_SPEED_RATINGS = "ISOSpeedRatings";
140 const std::string MEDIA_DATA_IMAGE_SCENE_TYPE = "SceneType";
141 
142 const std::string PERMISSION_ID = "id";
143 const std::string PERMISSION_BUNDLE_NAME = "bundle_name";
144 const std::string PERMISSION_FILE_ID = "file_id";
145 const std::string PERMISSION_MODE = "mode";
146 
147 const std::string CREATE_MEDIA_TABLE = "CREATE TABLE IF NOT EXISTS " + MEDIALIBRARY_TABLE + " (" +
148                                        MEDIA_DATA_DB_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
149                                        MEDIA_DATA_DB_FILE_PATH + " TEXT, " +
150                                        MEDIA_DATA_DB_SIZE + " BIGINT, " +
151                                        MEDIA_DATA_DB_PARENT_ID + " INT DEFAULT 0, " +
152                                        MEDIA_DATA_DB_DATE_ADDED + " BIGINT, " +
153                                        MEDIA_DATA_DB_DATE_MODIFIED + " BIGINT, " +
154                                        MEDIA_DATA_DB_MIME_TYPE + " TEXT, " +
155                                        MEDIA_DATA_DB_TITLE + " TEXT, " +
156                                        MEDIA_DATA_DB_DESCRIPTION + " TEXT, " +
157                                        MEDIA_DATA_DB_NAME + " TEXT, " +
158                                        MEDIA_DATA_DB_ORIENTATION + " INT DEFAULT 0, " +
159                                        MEDIA_DATA_DB_LATITUDE + " DOUBLE DEFAULT 0, " +
160                                        MEDIA_DATA_DB_LONGITUDE + " DOUBLE DEFAULT 0, " +
161                                        MEDIA_DATA_DB_DATE_TAKEN + " BIGINT DEFAULT 0, " +
162                                        MEDIA_DATA_DB_THUMBNAIL + " TEXT, " +
163                                        MEDIA_DATA_DB_LCD + " TEXT, " +
164                                        MEDIA_DATA_DB_TIME_VISIT + " BIGINT DEFAULT 0, " +
165                                        MEDIA_DATA_DB_BUCKET_ID + " INT DEFAULT 0, " +
166                                        MEDIA_DATA_DB_BUCKET_NAME + " TEXT, " +
167                                        MEDIA_DATA_DB_DURATION + " INT, " +
168                                        MEDIA_DATA_DB_ARTIST + " TEXT, " +
169                                        MEDIA_DATA_DB_AUDIO_ALBUM + " TEXT, " +
170                                        MEDIA_DATA_DB_MEDIA_TYPE + " INT, " +
171                                        MEDIA_DATA_DB_HEIGHT + " INT, " +
172                                        MEDIA_DATA_DB_WIDTH + " INT, " +
173                                        MEDIA_DATA_DB_IS_TRASH + " INT DEFAULT 0, " +
174                                        MEDIA_DATA_DB_RECYCLE_PATH + " TEXT, " +
175                                        MEDIA_DATA_DB_IS_FAV + " BOOL DEFAULT 0, " +
176                                        MEDIA_DATA_DB_OWNER_PACKAGE + " TEXT, " +
177                                        MEDIA_DATA_DB_IS_PENDING + " BOOL DEFAULT 0, " +
178                                        MEDIA_DATA_DB_TIME_PENDING + " BIGINT DEFAULT 0, " +
179                                        MEDIA_DATA_DB_DATE_TRASHED + " BIGINT DEFAULT 0, " +
180                                        MEDIA_DATA_DB_RELATIVE_PATH + " TEXT, " +
181                                        MEDIA_DATA_DB_VOLUME_NAME + " TEXT, " +
182                                        MEDIA_DATA_DB_SELF_ID + " TEXT DEFAULT '1', " +
183                                        MEDIA_DATA_DB_ALBUM_NAME + " TEXT, " +
184                                        MEDIA_DATA_DB_URI + " TEXT, " +
185                                        MEDIA_DATA_DB_ALBUM + " TEXT)";
186 
187 const std::string CREATE_BUNDLE_PREMISSION_TABLE = "CREATE TABLE IF NOT EXISTS " +
188                                       BUNDLE_PERMISSION_TABLE + " (" +
189                                       PERMISSION_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
190                                       PERMISSION_BUNDLE_NAME + " TEXT NOT NULL, " +
191                                       PERMISSION_FILE_ID + " INT NOT NULL, " +
192                                       PERMISSION_MODE + " TEXT NOT NULL)";
193 
194 const std::string CREATE_IMAGE_VIEW = "CREATE VIEW Image AS SELECT " +
195                                       MEDIA_DATA_DB_ID + ", " +
196                                       MEDIA_DATA_DB_FILE_PATH + ", " +
197                                       MEDIA_DATA_DB_SIZE + ", " +
198                                       MEDIA_DATA_DB_NAME + ", " +
199                                       MEDIA_DATA_DB_TITLE + ", " +
200                                       MEDIA_DATA_DB_DESCRIPTION + ", " +
201                                       MEDIA_DATA_DB_DATE_ADDED + ", " +
202                                       MEDIA_DATA_DB_DATE_MODIFIED + ", " +
203                                       MEDIA_DATA_DB_DATE_TAKEN + ", " +
204                                       MEDIA_DATA_DB_MIME_TYPE + ", " +
205                                       MEDIA_DATA_DB_LATITUDE + ", " +
206                                       MEDIA_DATA_DB_LONGITUDE + ", " +
207                                       MEDIA_DATA_DB_ORIENTATION + ", " +
208                                       MEDIA_DATA_DB_WIDTH + ", " +
209                                       MEDIA_DATA_DB_HEIGHT + ", " +
210                                       MEDIA_DATA_DB_BUCKET_ID + ", " +
211                                       MEDIA_DATA_DB_BUCKET_NAME + ", " +
212                                       MEDIA_DATA_DB_THUMBNAIL + ", " +
213                                       MEDIA_DATA_DB_LCD + ", " +
214                                       MEDIA_DATA_DB_SELF_ID + " " +
215                                       "FROM Files WHERE " +
216                                       MEDIA_DATA_DB_MEDIA_TYPE + " = 3";
217 
218 const std::string CREATE_VIDEO_VIEW = "CREATE VIEW Video AS SELECT " +
219                                       MEDIA_DATA_DB_ID + ", " +
220                                       MEDIA_DATA_DB_FILE_PATH + ", " +
221                                       MEDIA_DATA_DB_SIZE + ", " +
222                                       MEDIA_DATA_DB_NAME + ", " +
223                                       MEDIA_DATA_DB_TITLE + ", " +
224                                       MEDIA_DATA_DB_DESCRIPTION + ", " +
225                                       MEDIA_DATA_DB_DATE_ADDED + ", " +
226                                       MEDIA_DATA_DB_DATE_MODIFIED + ", " +
227                                       MEDIA_DATA_DB_MIME_TYPE + ", " +
228                                       MEDIA_DATA_DB_ORIENTATION + ", " +
229                                       MEDIA_DATA_DB_WIDTH + ", " +
230                                       MEDIA_DATA_DB_HEIGHT + ", " +
231                                       MEDIA_DATA_DB_DURATION + ", " +
232                                       MEDIA_DATA_DB_BUCKET_ID + ", " +
233                                       MEDIA_DATA_DB_BUCKET_NAME + ", " +
234                                       MEDIA_DATA_DB_THUMBNAIL + ", " +
235                                       MEDIA_DATA_DB_SELF_ID + " " +
236                                       "FROM Files WHERE " +
237                                       MEDIA_DATA_DB_MEDIA_TYPE + " = 4";
238 
239 const std::string CREATE_AUDIO_VIEW = "CREATE VIEW Audio AS SELECT " +
240                                       MEDIA_DATA_DB_ID + ", " +
241                                       MEDIA_DATA_DB_FILE_PATH + ", " +
242                                       MEDIA_DATA_DB_SIZE + ", " +
243                                       MEDIA_DATA_DB_NAME + ", " +
244                                       MEDIA_DATA_DB_TITLE + ", " +
245                                       MEDIA_DATA_DB_DESCRIPTION + ", " +
246                                       MEDIA_DATA_DB_DATE_ADDED + ", " +
247                                       MEDIA_DATA_DB_DATE_MODIFIED + ", " +
248                                       MEDIA_DATA_DB_MIME_TYPE + ", " +
249                                       MEDIA_DATA_DB_ARTIST + ", " +
250                                       MEDIA_DATA_DB_DURATION + ", " +
251                                       MEDIA_DATA_DB_BUCKET_ID + ", " +
252                                       MEDIA_DATA_DB_BUCKET_NAME + ", " +
253                                       MEDIA_DATA_DB_THUMBNAIL + ", " +
254                                       MEDIA_DATA_DB_SELF_ID + " " +
255                                       "FROM Files WHERE " +
256                                       MEDIA_DATA_DB_MEDIA_TYPE + " = 5";
257 
258 const std::string REMOTE_THUMBNAIL_TABLE = "RemoteThumbnailMap";
259 const std::string REMOTE_THUMBNAIL_DB_ID = "id";
260 const std::string REMOTE_THUMBNAIL_DB_FILE_ID = "file_id";
261 const std::string REMOTE_THUMBNAIL_DB_UDID = "udid";
262 const std::string CREATE_REMOTE_THUMBNAIL_TABLE = "CREATE TABLE IF NOT EXISTS " + REMOTE_THUMBNAIL_TABLE + " (" +
263                                             REMOTE_THUMBNAIL_DB_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
264                                             REMOTE_THUMBNAIL_DB_FILE_ID + " INT, " +
265                                             REMOTE_THUMBNAIL_DB_UDID + " TEXT, " +
266                                             MEDIA_DATA_DB_THUMBNAIL + " TEXT, " +
267                                             MEDIA_DATA_DB_LCD + " TEXT, " +
268                                             MEDIA_DATA_DB_TIME_VISIT + " BIGINT DEFAULT 0) ";
269 const std::string FILE_TABLE = "file";
270 const std::string ABLUM_TABLE = "album";
271 const std::string ABLUM_VIEW_NAME = "Album";
272 const std::string DISTRIBUTED_ABLUM_COLUMNS = "SELECT count( " + FILE_TABLE + "." +
273                                               MEDIA_DATA_DB_DATE_TRASHED + " = 0 OR NULL) AS " +
274                                               MEDIA_DATA_DB_COUNT + ", " +
275                                               ABLUM_TABLE + "." + MEDIA_DATA_DB_RELATIVE_PATH + ", " +
276                                               ABLUM_TABLE + "." + MEDIA_DATA_DB_ID + " AS " +
277                                               MEDIA_DATA_DB_BUCKET_ID + ", " +
278                                               ABLUM_TABLE + "." + MEDIA_DATA_DB_FILE_PATH + ", " +
279                                               ABLUM_TABLE + "." + MEDIA_DATA_DB_TITLE + " AS " +
280                                               MEDIA_DATA_DB_BUCKET_NAME + ", " +
281                                               ABLUM_TABLE + "." + MEDIA_DATA_DB_TITLE + ", " +
282                                               ABLUM_TABLE + "." + MEDIA_DATA_DB_DESCRIPTION + ", " +
283                                               ABLUM_TABLE + "." + MEDIA_DATA_DB_DATE_ADDED + ", " +
284                                               ABLUM_TABLE + "." + MEDIA_DATA_DB_DATE_MODIFIED + ", " +
285                                               ABLUM_TABLE + "." + MEDIA_DATA_DB_THUMBNAIL + ", " +
286                                               FILE_TABLE + "." + MEDIA_DATA_DB_MEDIA_TYPE + ", " +
287                                               ABLUM_TABLE + "." + MEDIA_DATA_DB_SELF_ID + ", " +
288                                               ABLUM_TABLE + "." + MEDIA_DATA_DB_IS_TRASH;
289 const std::string DISTRIBUTED_ABLUM_WHERE_AND_GROUPBY = " WHERE " +
290                                                         FILE_TABLE + "." + MEDIA_DATA_DB_BUCKET_ID + " = " +
291                                                         ABLUM_TABLE + "." + MEDIA_DATA_DB_ID + " AND " +
292                                                         FILE_TABLE + "." + MEDIA_DATA_DB_MEDIA_TYPE + " <> " +
293                                                         std::to_string(MEDIA_TYPE_ALBUM) + " AND " +
294                                                         FILE_TABLE + "." + MEDIA_DATA_DB_MEDIA_TYPE + " <> " +
295                                                         std::to_string(MEDIA_TYPE_FILE) +
296                                                         " GROUP BY " +
297                                                         FILE_TABLE + "." + MEDIA_DATA_DB_BUCKET_ID +", " +
298                                                         FILE_TABLE + "." + MEDIA_DATA_DB_BUCKET_NAME + ", " +
299                                                         FILE_TABLE + "." + MEDIA_DATA_DB_MEDIA_TYPE + ", " +
300                                                         ABLUM_TABLE + "." + MEDIA_DATA_DB_SELF_ID;
301 const std::string CREATE_ABLUM_VIEW = "CREATE VIEW " + ABLUM_VIEW_NAME +
302                                       " AS " + DISTRIBUTED_ABLUM_COLUMNS +
303                                       " FROM Files " + FILE_TABLE + ", " +
304                                       " Files " + ABLUM_TABLE +
305                                       DISTRIBUTED_ABLUM_WHERE_AND_GROUPBY;
306 const std::string SMARTALBUM_DB_ID = "album_id";
307 const std::string SMARTALBUM_DB_ALBUM_TYPE = "album_type";
308 const std::string SMARTALBUM_DB_NAME = "album_name";
309 const std::string SMARTALBUM_DB_DESCRIPTION = "description";
310 const std::string SMARTALBUM_DB_CAPACITY = "capacity";
311 const std::string SMARTALBUM_DB_LATITUDE = "latitude";
312 const std::string SMARTALBUM_DB_LONGITUDE = "longitude";
313 const std::string SMARTALBUM_DB_COVER_URI = "cover_uri";
314 const std::string SMARTALBUM_DB_EXPIRED_TIME = "expired_id";
315 const std::string SMARTALBUM_DB_SELF_ID = "self_id";
316 const std::string CREATE_SMARTALBUM_TABLE = "CREATE TABLE IF NOT EXISTS " + SMARTALBUM_TABLE + " (" +
317                                             SMARTALBUM_DB_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
318                                             SMARTALBUM_DB_NAME + " TEXT, " +
319                                             SMARTALBUM_DB_DESCRIPTION + " TEXT, " +
320                                             SMARTALBUM_DB_ALBUM_TYPE + " INT, " +
321                                             SMARTALBUM_DB_CAPACITY + " INT, " +
322                                             SMARTALBUM_DB_LATITUDE + " DOUBLE DEFAULT 0, " +
323                                             SMARTALBUM_DB_LONGITUDE + " DOUBLE DEFAULT 0, " +
324                                             SMARTALBUM_DB_COVER_URI + " TEXT, " +
325                                             SMARTALBUM_DB_EXPIRED_TIME + " INT DEFAULT 30, " +
326                                             SMARTALBUM_DB_SELF_ID + " TEXT) ";
327 
328 const std::string SMARTALBUMMAP_DB_ID = "map_id";
329 const std::string SMARTALBUMMAP_DB_ALBUM_ID = "album_id";
330 const std::string SMARTALBUMMAP_DB_CHILD_ALBUM_ID = "child_album_id";
331 const std::string SMARTALBUMMAP_DB_CHILD_ASSET_ID = "child_asset_id";
332 const std::string SMARTALBUMMAP_DB_SELF_ID = "self_id";
333 const std::string CREATE_SMARTALBUMMAP_TABLE = "CREATE TABLE IF NOT EXISTS " + SMARTALBUM_MAP_TABLE + " (" +
334                                             SMARTALBUMMAP_DB_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
335                                             SMARTALBUMMAP_DB_ALBUM_ID + " INT, " +
336                                             SMARTALBUMMAP_DB_CHILD_ALBUM_ID + " INT, " +
337                                             SMARTALBUMMAP_DB_CHILD_ASSET_ID + " INT, " +
338                                             SMARTALBUMMAP_DB_SELF_ID + " TEXT) ";
339 const std::string CATEGORY_SMARTALBUMMAP_DB_ID = "category_map_id";
340 const std::string CATEGORY_SMARTALBUMMAP_DB_CATEGORY_ID = "category_id";
341 const std::string CATEGORY_SMARTALBUMMAP_DB_CATEGORY_NAME = "category_name";
342 const std::string CATEGORY_SMARTALBUMMAP_DB_ALBUM_ID = "album_id";
343 const std::string CATEGORY_SMARTALBUMMAP_DB_SELF_ID = "self_id";
344 const std::string CREATE_CATEGORY_SMARTALBUMMAP_TABLE = "CREATE TABLE IF NOT EXISTS " +
345                                             CATEGORY_SMARTALBUM_MAP_TABLE + " (" +
346                                             CATEGORY_SMARTALBUMMAP_DB_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
347                                             CATEGORY_SMARTALBUMMAP_DB_CATEGORY_ID + " INT, " +
348                                             CATEGORY_SMARTALBUMMAP_DB_CATEGORY_NAME + " TEXT, " +
349                                             CATEGORY_SMARTALBUMMAP_DB_ALBUM_ID + " INT, " +
350                                             SMARTALBUMMAP_DB_SELF_ID + " TEXT) ";
351 const std::string CATEGORY_MEDIATYPE_DIRECTORY_DB_DIRECTORY_TYPE = "directory_type";
352 const std::string CATEGORY_MEDIATYPE_DIRECTORY_DB_MEDIA_TYPE = "media_type";
353 const std::string CATEGORY_MEDIATYPE_DIRECTORY_DB_DIRECTORY = "directory";
354 const std::string CATEGORY_MEDIATYPE_DIRECTORY_DB_EXTENSION = "extension";
355 const std::string CREATE_MEDIATYPE_DIRECTORY_TABLE = "CREATE TABLE IF NOT EXISTS " +
356                                             MEDIATYPE_DIRECTORY_TABLE + " (" +
357                                             CATEGORY_MEDIATYPE_DIRECTORY_DB_DIRECTORY_TYPE + " INTEGER PRIMARY KEY, " +
358                                             CATEGORY_MEDIATYPE_DIRECTORY_DB_MEDIA_TYPE + " TEXT, " +
359                                             CATEGORY_MEDIATYPE_DIRECTORY_DB_DIRECTORY + " TEXT, " +
360                                             CATEGORY_MEDIATYPE_DIRECTORY_DB_EXTENSION + " TEXT) ";
361 
362 const std::string DEVICE_DB_ID = "id";
363 const std::string DEVICE_DB_UDID = "device_udid";
364 const std::string DEVICE_DB_NETWORK_ID = "network_id";
365 const std::string DEVICE_DB_NAME = "device_name";
366 const std::string DEVICE_DB_IP = "device_ip";
367 const std::string DEVICE_DB_SYNC_STATUS = "sync_status";
368 const std::string DEVICE_DB_SELF_ID = "self_id";
369 const std::string DEVICE_DB_TYPE = "device_type";
370 const std::string DEVICE_DB_PREPATH = "pre_path";
371 const std::string DEVICE_DB_DATE_ADDED = "date_added";
372 const std::string DEVICE_DB_DATE_MODIFIED = "date_modified";
373 const std::string CREATE_DEVICE_TABLE = "CREATE TABLE IF NOT EXISTS " + DEVICE_TABLE + " (" +
374                                             DEVICE_DB_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
375                                             DEVICE_DB_UDID + " TEXT, " +
376                                             DEVICE_DB_NETWORK_ID + " TEXT, " +
377                                             DEVICE_DB_NAME + " TEXT, " +
378                                             DEVICE_DB_IP + " TEXT DEFAULT '', " +
379                                             DEVICE_DB_SYNC_STATUS + " INT DEFAULT 0, " +
380                                             DEVICE_DB_SELF_ID + " TEXT, " +
381                                             DEVICE_DB_TYPE + " INT, " +
382                                             DEVICE_DB_PREPATH + " TEXT, " +
383                                             DEVICE_DB_DATE_ADDED + " BIGINT DEFAULT 0, " +
384                                             DEVICE_DB_DATE_MODIFIED + " BIGINT DEFAULT 0) ";
385 const std::string SMARTALBUM_TABLE_NAME = "smartalbum";
386 const std::string SMARTALBUMMAP_TABLE_NAME = "smartAlbumMap";
387 const std::string CATEGORY_SMARTALBUMMAP_TABLE_NAME = "categorySmartAlbumMap";
388 const std::string SMARTABLUMASSETS_VIEW_NAME = "SmartAlbumAssets";
389 const std::string SMARTABLUMASSETS_ALBUMCAPACITY = "albumCapacity";
390 const std::string CREATE_SMARTABLUMASSETS_VIEW = "CREATE VIEW " + SMARTABLUMASSETS_VIEW_NAME +
391                         " AS SELECT COUNT(" +
392                         MEDIALIBRARY_TABLE + "."+ MEDIA_DATA_DB_DATE_TRASHED + " = 0 OR (" +
393                         SMARTALBUM_TABLE_NAME + "." + SMARTALBUM_DB_ID + " = " +
394                         std::to_string(TRASH_ALBUM_ID_VALUES) + " AND " +
395                         MEDIALIBRARY_TABLE + "."+ MEDIA_DATA_DB_IS_TRASH + "<> 0)" +
396                         " OR NULL ) AS " + SMARTABLUMASSETS_ALBUMCAPACITY + ", " +
397                         SMARTALBUM_TABLE_NAME + "." + SMARTALBUM_DB_ID + ", " +
398                         SMARTALBUM_TABLE_NAME + "." + SMARTALBUM_DB_NAME + ", " +
399                         SMARTALBUM_TABLE_NAME + "." + SMARTALBUM_DB_SELF_ID + ", " +
400                         SMARTALBUM_TABLE_NAME + "." + SMARTALBUM_DB_ALBUM_TYPE + ", " +
401                         SMARTALBUM_MAP_TABLE + "." + SMARTALBUMMAP_DB_ID +
402                         " FROM " + SMARTALBUM_TABLE +" "+SMARTALBUM_TABLE_NAME +
403                         " LEFT JOIN " + SMARTALBUM_MAP_TABLE +
404                         " ON " + SMARTALBUM_MAP_TABLE + "." + SMARTALBUMMAP_DB_ALBUM_ID + " = " +
405                         SMARTALBUM_TABLE_NAME + "." + SMARTALBUM_DB_ID +
406                         " LEFT JOIN " + MEDIALIBRARY_TABLE +
407                         " ON " + SMARTALBUM_MAP_TABLE + "." + SMARTALBUMMAP_DB_CHILD_ASSET_ID + " = " +
408                         MEDIALIBRARY_TABLE + "." + MEDIA_DATA_DB_ID +
409                         " GROUP BY IFNULL( " + SMARTALBUM_MAP_TABLE + "." + SMARTALBUMMAP_DB_ALBUM_ID + ", " +
410                         SMARTALBUM_TABLE_NAME + "." + SMARTALBUM_DB_ID + " ), " +
411                         SMARTALBUM_TABLE_NAME + "." + SMARTALBUM_DB_SELF_ID;
412 const std::string ASSETMAP_VIEW_NAME = "AssetMap";
413 const std::string CREATE_ASSETMAP_VIEW = "CREATE VIEW " + ASSETMAP_VIEW_NAME +
414                         " AS SELECT * FROM " +
415                         MEDIALIBRARY_TABLE + " a " + ", " +
416                         SMARTALBUM_MAP_TABLE + " b " +
417                         " WHERE " +
418                         "a." + MEDIA_DATA_DB_ID + " = " +
419                         "b." + SMARTALBUMMAP_DB_CHILD_ASSET_ID;
420 
421 const std::string QUERY_MEDIA_VOLUME = "SELECT sum(" + MEDIA_DATA_DB_SIZE + ") AS " +
422                         MEDIA_DATA_DB_SIZE + "," +
423                         MEDIA_DATA_DB_MEDIA_TYPE + " FROM " +
424                         MEDIALIBRARY_TABLE + " WHERE " +
425                         MEDIA_DATA_DB_MEDIA_TYPE + " = " + std::to_string(MEDIA_TYPE_FILE) + " OR " +
426                         MEDIA_DATA_DB_MEDIA_TYPE + " = " + std::to_string(MEDIA_TYPE_IMAGE) + " OR " +
427                         MEDIA_DATA_DB_MEDIA_TYPE + " = " + std::to_string(MEDIA_TYPE_VIDEO) + " OR " +
428                         MEDIA_DATA_DB_MEDIA_TYPE + " = " + std::to_string(MEDIA_TYPE_AUDIO) + " AND " +
429                         MEDIA_DATA_DB_DATE_TRASHED + " = 0" +
430                         " GROUP BY " + MEDIA_DATA_DB_MEDIA_TYPE;
431 
432 // File operations constants
433 const std::string MEDIA_OPERN_KEYWORD = "operation";
434 const std::string MEDIA_FILEOPRN = "file_operation";
435 const std::string MEDIA_ALBUMOPRN = "album_operation";
436 const std::string MEDIA_DIROPRN = "dir_operation";
437 const std::string MEDIA_QUERYOPRN = "query_operation";
438 const std::string MEDIA_SMARTALBUMOPRN = "albumsmart_operation";
439 const std::string MEDIA_SMARTALBUMMAPOPRN = "smartalbummap_operation";
440 const std::string MEDIA_FILEOPRN_CREATEASSET = "create_asset";
441 const std::string MEDIA_FILEOPRN_MODIFYASSET = "modify_asset";
442 const std::string MEDIA_FILEOPRN_DELETEASSET = "delete_asset";
443 const std::string MEDIA_FILEOPRN_TRASHASSET = "trash_asset";
444 const std::string MEDIA_FILEOPRN_GETALBUMCAPACITY = "get_album_capacity";
445 const std::string MEDIA_FILEOPRN_OPENASSET = "open_asset";
446 const std::string MEDIA_FILEOPRN_CLOSEASSET = "close_asset";
447 const std::string MEDIA_FILEOPRN_ISDIRECTORY = "isdirectory_asset";
448 
449 // BoardCast operation
450 const std::string MEDIA_BOARDCASTOPRN = "boardcast";
451 const std::string MEDIA_SCAN_OPERATION = "boardcast_scan";
452 
453 const std::string THU_OPRN_GENERATES = "thumbnail_generate_operation";
454 const std::string THU_OPRN_AGING = "thumbnail_aging_operation";
455 const std::string DISTRIBUTE_THU_OPRN_GENERATES = "thumbnail_distribute_generate_operation";
456 const std::string DISTRIBUTE_THU_OPRN_AGING = "thumbnail_distribute_aging_operation";
457 const std::string DISTRIBUTE_THU_OPRN_CREATE = "thumbnail_distribute_create_operation";
458 const std::string BUNDLE_PERMISSION_INSERT = "bundle_permission_insert_operation";
459 
460 const std::string MEDIA_ALBUMOPRN_CREATEALBUM = "create_album";
461 const std::string MEDIA_ALBUMOPRN_MODIFYALBUM = "modify_album";
462 const std::string MEDIA_ALBUMOPRN_DELETEALBUM = "delete_album";
463 const std::string MEDIA_ALBUMOPRN_QUERYALBUM = "query_album";
464 const std::string MEDIA_SMARTALBUMOPRN_CREATEALBUM = "create_smartalbum";
465 const std::string MEDIA_SMARTALBUMOPRN_MODIFYALBUM = "modify_smartalbum";
466 const std::string MEDIA_SMARTALBUMOPRN_DELETEALBUM = "delete_smartalbum";
467 const std::string MEDIA_DIROPRN_DELETEDIR = "delete_dir";
468 const std::string MEDIA_DIROPRN_CHECKDIR_AND_EXTENSION = "check_dir_and_extension";
469 const std::string MEDIA_DIROPRN_FMS_CREATEDIR = "fms_create_dir";
470 const std::string MEDIA_DIROPRN_FMS_DELETEDIR = "fms_delete_dir";
471 const std::string MEDIA_DIROPRN_FMS_TRASHDIR = "fms_trash_dir";
472 const std::string MEDIA_QUERYOPRN_QUERYVOLUME = "query_media_volume";
473 const std::string MEDIA_SMARTALBUMMAPOPRN_ADDSMARTALBUM = "add_smartalbum_map";
474 const std::string MEDIA_SMARTALBUMMAPOPRN_REMOVESMARTALBUM = "remove_smartalbum_map";
475 const std::string MEDIA_SMARTALBUMMAPOPRN_AGEINGSMARTALBUM = "ageing_smartalbum_map";
476 const std::string MEDIA_FILEMODE = "mode";
477 
478 const std::string MEDIA_DEVICE_QUERYALLDEVICE = "query_all_device";
479 const std::string MEDIA_DEVICE_QUERYACTIVEDEVICE = "query_active_device";
480 } // namespace Media
481 } // namespace OHOS
482 
483 #endif  // INTERFACES_INNERKITS_NATIVE_INCLUDE_MEDIA_DATA_ABILITY_CONST_H_
484