Failed = 2
}
+ internal enum AppInfoAppComponentType
+ {
+ UiApp = 0,
+ ServiceApp = 1,
+ WidgetApp = 2,
+ WatchApp = 3
+ }
+
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate void AppManagerEventCallback(string appType, string appId, AppManagerEventType eventType, AppManagerEventState eventState, IntPtr eventHandle, IntPtr userData);
//void(* app_manager_event_cb)(const char *type, const char *app_id, app_manager_event_type_e event_type, app_manager_event_state_e event_state, app_manager_event_h handle, void *user_data)
internal delegate bool AppInfoMetadataCallback(string key, string value, IntPtr userData);
//bool(* app_info_metadata_cb )(const char *metadata_key, const char *metadata_value, void *user_data)
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate bool AppInfoCategoryCallback(string category, IntPtr userData);
+ //bool (*app_info_category_cb) (const char *category, void *user_data)
+
[DllImport(Libraries.AppManager, EntryPoint = "app_manager_set_app_context_event_cb")]
internal static extern ErrorCode AppManagerSetAppContextEvent(AppManagerAppContextEventCallback callback, IntPtr userData);
//int app_manager_set_app_context_event_cb( app_manager_app_context_event_cb callback, void * user_data)
internal static extern ErrorCode AppInfoGetType(IntPtr handle, out string type);
//int app_info_get_type (app_info_h app_info, char **type)
+ [DllImport(Libraries.AppManager, EntryPoint = "app_info_get_app_component_type")]
+ internal static extern ErrorCode AppInfoGetAppComponentType(IntPtr handle, out AppInfoAppComponentType type);
+ //int app_info_get_app_component_type(app_info_h app_info, app_info_app_component_type_e *type)
+
[DllImport(Libraries.AppManager, EntryPoint = "app_info_foreach_metadata")]
internal static extern ErrorCode AppInfoForeachMetadata(IntPtr handle, AppInfoMetadataCallback callback, IntPtr userData);
//int app_info_foreach_metadata(app_info_h app_info, app_info_metadata_cb callback, void *user_data)
internal static extern ErrorCode AppInfoClone(out IntPtr destination, IntPtr source);
//int app_info_clone(app_info_h * clone, app_info_h app_info)
+ [DllImport(Libraries.AppManager, EntryPoint = "app_info_foreach_category")]
+ internal static extern ErrorCode AppInfoForeachCategory(IntPtr handle, AppInfoCategoryCallback callback, IntPtr userData);
+ //int app_info_foreach_category(app_info_h app_info, app_info_category_cb callback, void *user_data)
+
[DllImport(Libraries.AppManager, EntryPoint = "app_info_filter_create")]
internal static extern ErrorCode AppInfoFilterCreate(out IntPtr handle);
//int app_info_filter_create(app_info_filter_h * handle)
--- /dev/null
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Applications
+{
+ /// <summary>
+ /// Enumeration for application component type.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public enum ApplicationComponentType
+ {
+ /// <summary>
+ /// Component type is ui application.
+ /// </summary>
+ UIApplication = 0,
+
+ /// <summary>
+ /// Component type is service application.
+ /// </summary>
+ ServiceApplication,
+
+ /// <summary>
+ /// Component type is widget application.
+ /// </summary>
+ WidgetApplication,
+
+ /// <summary>
+ /// Component type is watch application.
+ /// </summary>
+ WatchApplication,
+ }
+}
}
/// <summary>
+ /// Gets the application component type.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public ApplicationComponentType ComponentType
+ {
+ get
+ {
+ IntPtr infoHandle = GetInfoHandle();
+ Interop.ApplicationManager.AppInfoAppComponentType componentType = 0;
+ if (infoHandle != IntPtr.Zero)
+ {
+ err = Interop.ApplicationManager.AppInfoGetAppComponentType(infoHandle, out componentType);
+ if (err != Interop.ApplicationManager.ErrorCode.None)
+ {
+ Log.Warn(LogTag, "Failed to get the application component type of " + _applicationId + ". err = " + err);
+ }
+ }
+ return (ApplicationComponentType)componentType;
+ }
+ }
+
+ /// <summary>
/// Gets the application's metadata.
/// </summary>
/// <since_tizen> 3 </since_tizen>
}
/// <summary>
+ /// Gets the application's category values specified in the tizen-manifest
+ /// </summary>
+ /// <privilege>http://tizen.org/privilege/packagemanager.admin</privilege>
+ /// <privlevel>platform</privlevel>
+ /// <since_tizen> 6 </since_tizen>
+ public IEnumerable<string> Categories
+ {
+ get
+ {
+ List<string> categories = new List<string>();
+
+ Interop.ApplicationManager.AppInfoCategoryCallback cb = (string category, IntPtr userData) =>
+ {
+ categories.Add(category);
+ return true;
+ };
+
+ IntPtr infoHandle = GetInfoHandle();
+ if (infoHandle != IntPtr.Zero)
+ {
+ err = Interop.ApplicationManager.AppInfoForeachCategory(infoHandle, cb, IntPtr.Zero);
+ if (err != Interop.ApplicationManager.ErrorCode.None)
+ {
+ Log.Warn(LogTag, "Failed to get application category of " + _applicationId + ". err = " + err);
+ }
+ }
+ return categories;
+ }
+ }
+
+ /// <summary>
/// Gets the shared data path.
/// </summary>
/// <remarks>
/// <summary>
/// Service applications.
/// </summary>
- Service = 2
+ Service = 2,
+ /// <summary>
+ /// Service applications.
+ /// </summary>
+ Widget = 3,
+ /// <summary>
+ /// Service applications.
+ /// </summary>
+ Watch = 4
}
}
}
/// <summary>
+ /// Retrieves all the application IDs of this package.
+ /// </summary>
+ /// <param name="componentType">Optional: AppType enumeration value.</param>
+ /// <returns>Returns a dictionary containing all the application information for a given application type.</returns>
+ /// <since_tizen> 6 </since_tizen>
+ public IEnumerable<ApplicationInfo> GetApplications(ApplicationComponentType componentType)
+ {
+ return GetApplications(ToApplicationType(componentType));
+ }
+
+ /// <summary>
/// Gets the package size information.
/// </summary>
/// <returns>Package size information.</returns>
}
return privileges;
}
+
+ private ApplicationType ToApplicationType(ApplicationComponentType componentType)
+ {
+ ApplicationType applicationType = 0;
+ if (componentType == Tizen.Applications.ApplicationComponentType.UIApplication)
+ applicationType = Tizen.Applications.ApplicationType.Ui;
+ else if (componentType == Tizen.Applications.ApplicationComponentType.ServiceApplication)
+ applicationType = Tizen.Applications.ApplicationType.Service;
+ else if (componentType == Tizen.Applications.ApplicationComponentType.WidgetApplication)
+ applicationType = Tizen.Applications.ApplicationType.Widget;
+ else if (componentType == Tizen.Applications.ApplicationComponentType.WatchApplication)
+ applicationType = Tizen.Applications.ApplicationType.Watch;
+
+ return applicationType;
+ }
}
}