mirror of
https://gitee.com/openharmony/security_privacy_center
synced 2024-11-23 07:39:58 +00:00
整理去掉冗余代码
This commit is contained in:
parent
43706cdc8d
commit
6428944936
@ -1,3 +1,18 @@
|
||||
/**
|
||||
* Copyright (c) 2022-2023 Huawei Device Co., Ltd.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import { hapTasks } from '@ohos/hvigor-ohos-plugin';
|
||||
|
||||
export default {
|
||||
|
@ -1,3 +1,18 @@
|
||||
/**
|
||||
* Copyright (c) 2022-2023 Huawei Device Co., Ltd.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
{
|
||||
"license": "",
|
||||
"devDependencies": {},
|
||||
|
@ -1,92 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2022-2023 Huawei Device Co., Ltd.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import settings from '@ohos.settings';
|
||||
|
||||
export class ConfigData {
|
||||
FILE_URI = '/data/accounts/account_0/applications/com.ohos.settings'
|
||||
+ '/com.ohos.settings/assets/phone/resources/rawfile/';
|
||||
PREFERENCES_PATH = '/data/accounts/account_0/appdata/com.ohos.settings/sharedPreference/SettingPreferences';
|
||||
BRIGHTNESS_SAVE_VALUE_KEY = 'BrightnessSaveValue';
|
||||
SENT_EVENT_BROADCAST_BRIGHTNESS_VALUE = 'BRIGHTNESS_VALUE';
|
||||
SENT_EVENT_BROADCAST_VOLUME_VALUE = 'VOLUME_VALUE';
|
||||
SENT_EVENT_WIFI_CONNECT_NAME = 'WIFI_CONNECT_NAME';
|
||||
SENT_EVENT_AUDIO_RINGER_MODE = 'AUDIO_RINGER_MODE';
|
||||
SENT_EVENT_AUDIO_VOLUME_VALUE = 'AUDIO_VOLUME_VALUE';
|
||||
BRIGHTNESS_DEFAULT_VALUE = 50;
|
||||
DEFAULT_BUNDLE_NAME = 'com.ohos.settings';
|
||||
DATE_AND_TIME_YEAR = 'DATE_AND_TIME_YEAR';
|
||||
DATE_AND_TIME_MONTH = 'DATE_AND_TIME_MONTH';
|
||||
DATE_AND_TIME_DAY = 'DATE_AND_TIME_DAY';
|
||||
TAG = 'Settings ';
|
||||
// page request
|
||||
PAGE_REQUEST_CODE_KEY = 'pageRequestCode';
|
||||
PAGE_RESULT_KEY = 'pageResult';
|
||||
PAGE_RESULT_OK = -1;
|
||||
PAGE_RESULT_NG = 0;
|
||||
// password request code
|
||||
PAGE_REQUEST_CODE_PASSWORD_CREATE = 20001;
|
||||
PAGE_REQUEST_CODE_PASSWORD_CHANGE = 20003;
|
||||
PAGE_REQUEST_CODE_PASSWORD_DISABLE = 20004;
|
||||
WH_100_100 = '100%';
|
||||
WH_25_100 = '25%';
|
||||
WH_30_100 = '30%';
|
||||
WH_33_100 = '33%';
|
||||
WH_35_100 = '35%';
|
||||
WH_40_100 = '40%';
|
||||
WH_45_100 = '45%';
|
||||
WH_50_100 = '50%';
|
||||
WH_55_100 = '55%';
|
||||
WH_83_100 = '83%';
|
||||
WH_90_100 = '90%';
|
||||
GRID_CONTAINER_GUTTER_24 = 24;
|
||||
GRID_CONTAINER_MARGIN_24 = 24;
|
||||
LAYOUT_WEIGHT_1 = 1;
|
||||
value_20 = 20;
|
||||
font_20 = 20;
|
||||
MAX_LINES_1 = 1;
|
||||
MAX_LINES_2 = 2;
|
||||
MAX_LINES_3 = 3;
|
||||
DURATION_TIME = 200;
|
||||
FUNCTION_TYPE_HDC = 4;
|
||||
TIME_FORMAT_24 = "24";
|
||||
TIME_FORMAT_12 = "12";
|
||||
TIME_FORMAT_KEY = settings.date.TIME_FORMAT;
|
||||
SETTINGSDATA_DEVICE_NAME = settings.general.DEVICE_NAME;
|
||||
SETTINGSDATA_BRIGHTNESS = settings.display.SCREEN_BRIGHTNESS_STATUS;
|
||||
SLIDER_CHANG_MODE_MOVING = 1;
|
||||
SLIDER_CHANG_MODE_END = 2;
|
||||
//Language And Region
|
||||
ADDLANGUAGES = 'addedLanguages';
|
||||
CURRENTREGION = 'currentRegion';
|
||||
//Key of StoragePath
|
||||
STORAGEPATHKEY = 'storagePath';
|
||||
//StartAbility
|
||||
FACEAUTH_BUNDLE_NAME = 'com.ohos.settings.faceauth';
|
||||
FACEAUTH_ABILITY_NAME = 'com.ohos.settings.faceauth.enrollmentstartview';
|
||||
PERMISSION_MANAGER_BUNDLE_NAME = 'com.ohos.permissionmanager';
|
||||
PERMISSION_MANAGER_ABILITY_NAME = 'com.ohos.permissionmanager.MainAbility';
|
||||
MOBILE_DATA_BUNDLE_NAME = 'com.ohos.callui';
|
||||
MOBILE_DATA_ABILITY_NAME = 'com.ohos.mobiledatasettings.MainAbility';
|
||||
softWareUpDatesBundleName = 'com.ohos.updateapp';
|
||||
softWareUpDatesAbilityName = 'com.ohos.updateapp.MainAbility';
|
||||
SECURITY_BUNDLE_NAME = 'com.ohos.certmanager';
|
||||
SECURITY_ABILITY_NAME = 'MainAbility';
|
||||
DEVICE_NAME = 'OpenHarmony 2.0 Canary';
|
||||
}
|
||||
|
||||
let configData = new ConfigData();
|
||||
|
||||
export default configData as ConfigData;
|
@ -12,7 +12,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import Router from '@system.router';
|
||||
import ComponentConfig from './ComponentConfig';
|
||||
import router from '@ohos.router';
|
||||
|
||||
|
@ -57,7 +57,7 @@ export class AutoMenuViewModel extends BaseViewModel<AutoMenuModel, AutoMenuView
|
||||
model.handleMenuClick(intents.menuInfo);
|
||||
return ProcessResult.SUCCESS;
|
||||
}
|
||||
Logger.error(TAG, 'undefined intent: ' + intents.getIntentTag());
|
||||
Logger.error(TAG, 'undefined intents: ' + intents.getIntentTag());
|
||||
return ProcessResult.FAIL;
|
||||
}
|
||||
}
|
@ -15,10 +15,11 @@
|
||||
|
||||
import geolocation from '@ohos.geoLocationManager';
|
||||
import Logger from '../../common/utils/Logger';
|
||||
import ConfigData from '../../common/baseUtile/ConfigData';
|
||||
import { BusinessError } from '@ohos.base';
|
||||
import { ListenerBean } from './ListenerBean';
|
||||
|
||||
const TAG:string = 'LocationService'
|
||||
|
||||
export class LocationService {
|
||||
mIsStart: boolean = false;
|
||||
mListener: ListenerBean = new ListenerBean(() => {
|
||||
@ -28,49 +29,49 @@ export class LocationService {
|
||||
if (this.mIsStart) {
|
||||
return;
|
||||
}
|
||||
Logger.info(ConfigData.TAG, 'start location service')
|
||||
Logger.info(TAG, 'start location service')
|
||||
this.mIsStart = true;
|
||||
geolocation.on('locationEnabledChange', (isChanged: boolean) => {
|
||||
Logger.info(ConfigData.TAG, `start location service isChanged: ${JSON.stringify(isChanged)}`)
|
||||
Logger.info(TAG, `start location service isChanged: ${JSON.stringify(isChanged)}`)
|
||||
this.getServiceState();
|
||||
});
|
||||
}
|
||||
|
||||
registerListener(listener: ListenerBean) {
|
||||
Logger.info(ConfigData.TAG, `register locations listener : ${listener}`)
|
||||
Logger.info(TAG, `register locations listener : ${listener}`)
|
||||
this.mListener = listener;
|
||||
}
|
||||
|
||||
async getServiceState(): Promise<void> {
|
||||
Logger.info(ConfigData.TAG, 'get location state');
|
||||
Logger.info(TAG, 'get location state');
|
||||
try {
|
||||
let state: boolean = await geolocation.isLocationEnabled();
|
||||
Logger.info(ConfigData.TAG, `get location state, data: ${JSON.stringify(state)}`);
|
||||
Logger.info(TAG, `get location state, data: ${JSON.stringify(state)}`);
|
||||
this.mListener?.updateServiceState(state);
|
||||
} catch (error) {
|
||||
Logger.info(ConfigData.TAG, `get location state, data: ${error}`);
|
||||
Logger.info(TAG, `get location state, data: ${error}`);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
enableLocation() {
|
||||
Logger.info(ConfigData.TAG, 'enable location');
|
||||
Logger.info(TAG, 'enable location');
|
||||
try {
|
||||
geolocation.enableLocation()
|
||||
.then((res): void => Logger.info(ConfigData.TAG, `enable location, result: ${JSON.stringify(res)}`))
|
||||
.catch((error: BusinessError): void => Logger.info(ConfigData.TAG, `enable location, result: ${error}`));
|
||||
.then((res): void => Logger.info(TAG, `enable location, result: ${JSON.stringify(res)}`))
|
||||
.catch((error: BusinessError): void => Logger.info(TAG, `enable location, result: ${error}`));
|
||||
} catch (err) {
|
||||
Logger.info(ConfigData.TAG, `enable location, result: ${err}`);
|
||||
Logger.info(TAG, `enable location, result: ${err}`);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
disableLocation() {
|
||||
Logger.info(ConfigData.TAG, 'disable location');
|
||||
Logger.info(TAG, 'disable location');
|
||||
try {
|
||||
geolocation.disableLocation();
|
||||
} catch (err) {
|
||||
Logger.info(ConfigData.TAG, `disenable location, result: ${err}`);
|
||||
Logger.info(TAG, `disenable location, result: ${err}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,8 @@
|
||||
|
||||
import LocationService from './LocationService';
|
||||
import Logger from '../../common/utils/Logger';
|
||||
import ConfigData from '../../common/baseUtile/ConfigData';
|
||||
|
||||
const TAG:string = 'LocationViewModel'
|
||||
|
||||
export const LocationServiceOpenStatusKey = "LocationServiceStatus";
|
||||
|
||||
@ -26,7 +27,7 @@ export class LocationVM {
|
||||
if (this.mIsStart) {
|
||||
return;
|
||||
}
|
||||
Logger.info(ConfigData.TAG, 'init location view model')
|
||||
Logger.info(TAG, 'init location view model')
|
||||
this.mIsStart = true;
|
||||
LocationService.registerListener(this);
|
||||
LocationService.startService();
|
||||
@ -34,17 +35,17 @@ export class LocationVM {
|
||||
}
|
||||
|
||||
updateServiceState(state: boolean) {
|
||||
Logger.info(ConfigData.TAG, `update location service state, state: ${state} `)
|
||||
Logger.info(TAG, `update location service state, state: ${state} `)
|
||||
AppStorage.setOrCreate(LocationServiceOpenStatusKey, state);
|
||||
}
|
||||
|
||||
enableLocation() {
|
||||
Logger.info(ConfigData.TAG, 'enable location')
|
||||
Logger.info(TAG, 'enable location')
|
||||
LocationService.enableLocation();
|
||||
}
|
||||
|
||||
disableLocation() {
|
||||
Logger.info(ConfigData.TAG, 'disable location')
|
||||
Logger.info(TAG, 'disable location')
|
||||
LocationService.disableLocation();
|
||||
}
|
||||
}
|
||||
|
@ -15,11 +15,12 @@
|
||||
|
||||
import ViewModel from '../model/locationServicesImpl/LocationViewModel';
|
||||
import Logger from '../common/utils/Logger';
|
||||
import ConfigData from '../common/baseUtile/ConfigData';
|
||||
import HeadComponent from '../common/components/headComponent';
|
||||
import HiSysEventUtil from '../common/utils/HiSysEventUtil';
|
||||
import HiSysEventConstant from '../common/constants/HiSysEventConstant';
|
||||
|
||||
const TAG:string = 'LocationServicesPage'
|
||||
|
||||
/**
|
||||
* LocationServices
|
||||
*/
|
||||
@ -30,7 +31,7 @@ struct LocationServices {
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
GridContainer({ gutter: ConfigData.GRID_CONTAINER_GUTTER_24, margin: ConfigData.GRID_CONTAINER_MARGIN_24 }) {
|
||||
GridContainer({ gutter: 24, margin: 24}) {
|
||||
Column() {
|
||||
HeadComponent({ headName: $r('app.string.locationServicesTab'), isActive: true });
|
||||
|
||||
@ -47,7 +48,7 @@ struct LocationServices {
|
||||
.height('20vp')
|
||||
.selectedColor('#007DFF')
|
||||
.onChange((isOn: boolean) => {
|
||||
Logger.info(ConfigData.TAG, 'location service status is :' + this.locationServiceStatus);
|
||||
Logger.info(TAG, 'location service status is :' + this.locationServiceStatus);
|
||||
if (isOn) {
|
||||
ViewModel.enableLocation();
|
||||
HiSysEventUtil.reportLocationClick(HiSysEventConstant.BUNDLE_NAME, 1)
|
||||
@ -70,20 +71,20 @@ struct LocationServices {
|
||||
lg: { span: 8, offset: 2 }
|
||||
})
|
||||
}
|
||||
.width(ConfigData.WH_100_100)
|
||||
.height(ConfigData.WH_100_100)
|
||||
.width('100%')
|
||||
.height('100%')
|
||||
}
|
||||
.backgroundColor($r("sys.color.ohos_id_color_sub_background"))
|
||||
.width(ConfigData.WH_100_100)
|
||||
.height(ConfigData.WH_100_100)
|
||||
.width('100%')
|
||||
.height('100%')
|
||||
}
|
||||
|
||||
aboutToAppear(): void {
|
||||
Logger.info(ConfigData.TAG, 'location service about to appear');
|
||||
Logger.info(TAG, 'location service about to appear');
|
||||
ViewModel.initViewModel();
|
||||
}
|
||||
|
||||
aboutToDisappear(): void {
|
||||
Logger.info(ConfigData.TAG, 'location service about to disappear');
|
||||
Logger.info(TAG, 'location service about to disappear');
|
||||
}
|
||||
}
|
@ -1,3 +1,17 @@
|
||||
/**
|
||||
* Copyright (c) 2022-2023 Huawei Device Co., Ltd.
|
||||
* 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.
|
||||
*/
|
||||
{
|
||||
"module": {
|
||||
"name": "entry",
|
||||
|
@ -50,7 +50,7 @@ export default function ModelTest() {
|
||||
})
|
||||
|
||||
it('BundleInfoModelTest_01', 0, async () => {
|
||||
let bundleName: string = 'com.ohos.security_privacy_center'
|
||||
let bundleName: string = 'com.ohos.certmanager'
|
||||
await bundleManager.getApplicationInfo(bundleName, bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT)
|
||||
.then((data) => {
|
||||
BundleInfoModel.getAllBundleLabelAndIcon([data]).then((value) => {
|
||||
@ -65,7 +65,7 @@ export default function ModelTest() {
|
||||
})
|
||||
})
|
||||
it('BundleInfoModelTest_03', 0, async () => {
|
||||
let bundleName: string = 'com.ohos.security_privacy_center'
|
||||
let bundleName: string = 'com.ohos.certmanager'
|
||||
await bundleManager.getApplicationInfo(bundleName, bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT)
|
||||
.then((info) => {
|
||||
let bundleInfo: BundleInfoBean = {
|
||||
@ -95,7 +95,7 @@ export default function ModelTest() {
|
||||
})
|
||||
})
|
||||
it('BundleInfoModelTest_05', 0, async () => {
|
||||
let bundleName: string = 'com.ohos.security_privacy_center'
|
||||
let bundleName: string = 'com.ohos.certmanager'
|
||||
await bundleManager.getApplicationInfo(bundleName, bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT)
|
||||
.then((info) => {
|
||||
let bundleInfo: BundleInfoBean = {
|
||||
|
@ -15,8 +15,6 @@
|
||||
|
||||
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
|
||||
import LocationService from '../../../../../../main/ets/model/locationServicesImpl/LocationService';
|
||||
import geolocation from '@ohos.geoLocationManager';
|
||||
import ConfigData from '../../../../../../main/ets/common/baseUtile/ConfigData';
|
||||
import { ListenerBean } from '../../../../../../main/ets/model/locationServicesImpl/ListenerBean';
|
||||
|
||||
export default function LocationServiceTest() {
|
||||
|
@ -16,7 +16,6 @@
|
||||
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
|
||||
import LocationService from '../../../../../../main/ets/model/locationServicesImpl/LocationService';
|
||||
import LocationViewModel from '../../../../../../main/ets/model/locationServicesImpl/LocationViewModel';
|
||||
import ConfigData from '../../../../../../main/ets/common/baseUtile/ConfigData';
|
||||
|
||||
export default function LocationViewModelTest() {
|
||||
describe('LocationViewModelTest', () => {
|
||||
|
@ -1,3 +1,17 @@
|
||||
/**
|
||||
* Copyright (c) 2022-2023 Huawei Device Co., Ltd.
|
||||
* 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.
|
||||
*/
|
||||
{
|
||||
"lockfileVersion": 1,
|
||||
"ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.",
|
||||
|
@ -1,3 +1,18 @@
|
||||
/**
|
||||
* Copyright (c) 2022-2023 Huawei Device Co., Ltd.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
{
|
||||
"license": "",
|
||||
"devDependencies": {
|
||||
|
Loading…
Reference in New Issue
Block a user