• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (C) 2024 Huawei Device Co., Ltd.
2 // Licensed under the Apache License, Version 2.0 (the "License");
3 // you may not use this file except in compliance with the License.
4 // You may obtain a copy of the License at
5 //
6 //     http://www.apache.org/licenses/LICENSE-2.0
7 //
8 // Unless required by applicable law or agreed to in writing, software
9 // distributed under the License is distributed on an "AS IS" BASIS,
10 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 // See the License for the specific language governing permissions and
12 // limitations under the License.
13 
14 #[allow(unused)]
15 #[cxx::bridge(namespace = "OHOS::Request")]
16 mod ffi {
17     struct AppInfo {
18         ret: bool,
19         index: i32,
20         name: String,
21     }
22 
23     unsafe extern "C++" {
24         include!("bundle.h");
GetNameAndIndex(uid: i32) -> AppInfo25         fn GetNameAndIndex(uid: i32) -> AppInfo;
26     }
27 }
28 
get_name_and_index(uid: i32) -> Option<(i32, String)>29 pub(crate) fn get_name_and_index(uid: i32) -> Option<(i32, String)> {
30     let app_info = ffi::GetNameAndIndex(uid);
31     match app_info.ret {
32         true => Some((app_info.index, app_info.name)),
33         false => None,
34     }
35 }
36