Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions entry/src/main/ets/entryability/EntryAbility.ets
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import window from '@ohos.window';
import Want from '@ohos.app.ability.Want';
import AbilityConstant from '@ohos.app.ability.AbilityConstant';
import { Configuration } from '@ohos.app.ability.Configuration';
import { abilityAccessCtrl, common } from '@kit.AbilityKit';
import { abilityAccessCtrl, common, Permissions, PermissionRequestResult } from '@kit.AbilityKit';
import { Environment } from '@kit.CoreFileKit';
import fs from '@ohos.file.fs';

Expand All @@ -33,16 +33,13 @@ const TAG: string = 'ElectermEntryAbility';
// Permissions without "reason"/"usedScene" (INTERNET, GET_NETWORK_INFO,
// ACCESS_CERT_MANAGER, PRINT, GYROSCOPE, ACCELEROMETER) are normal or
// system-grant permissions that don't need runtime request.
const ALL_USER_PERMISSIONS: string[] = [
// Removed LOCATION, MICROPHONE, CAMERA, ACCESS_BLUETOOTH — a terminal/SSH
// app has no use for geolocation, audio/video capture, or Bluetooth.
const ALL_USER_PERMISSIONS: Permissions[] = [
'ohos.permission.READ_WRITE_DOWNLOAD_DIRECTORY',
'ohos.permission.READ_WRITE_DOCUMENTS_DIRECTORY',
'ohos.permission.READ_WRITE_DESKTOP_DIRECTORY',
'ohos.permission.LOCATION',
'ohos.permission.APPROXIMATELY_LOCATION',
'ohos.permission.MICROPHONE',
'ohos.permission.CAMERA',
'ohos.permission.READ_PASTEBOARD',
'ohos.permission.ACCESS_BLUETOOTH'
'ohos.permission.READ_PASTEBOARD'
];

export default class EntryAbility extends WebAbility {
Expand Down Expand Up @@ -95,8 +92,8 @@ export default class EntryAbility extends WebAbility {
try {
const atManager = abilityAccessCtrl.createAtManager();
const context = this.context as common.UIAbilityContext;
const result = await atManager.requestPermissionsFromUser(context, ALL_USER_PERMISSIONS);
const authResults = result.authResults;
const result: PermissionRequestResult = await atManager.requestPermissionsFromUser(context, ALL_USER_PERMISSIONS);
const authResults: number[] = result.authResults;
for (let i = 0; i < authResults.length; i++) {
if (authResults[i] === 0) {
console.info(`[${TAG}] Permission granted: ${ALL_USER_PERMISSIONS[i]}`);
Expand Down
40 changes: 0 additions & 40 deletions entry/src/main/module.json5
Original file line number Diff line number Diff line change
Expand Up @@ -43,41 +43,9 @@
"when": "always"
}
},
{
"name": "ohos.permission.LOCATION",
"reason": "$string:reason",
"usedScene": {
"abilities": ["EntryAbility"],
"when": "always"
}
},
{
"name": "ohos.permission.APPROXIMATELY_LOCATION",
"reason": "$string:reason",
"usedScene": {
"abilities": ["EntryAbility"],
"when": "always"
}
},
{
"name": "ohos.permission.ACCESS_CERT_MANAGER"
},
{
"name": "ohos.permission.MICROPHONE",
"reason": "$string:microphone",
"usedScene": {
"abilities": ["EntryAbility"],
"when": "inuse"
}
},
{
"name": "ohos.permission.CAMERA",
"reason": "$string:camera",
"usedScene": {
"abilities": ["EntryAbility"],
"when": "inuse"
}
},
{
"name": "ohos.permission.PRINT"
},
Expand All @@ -89,14 +57,6 @@
"when": "inuse"
}
},
{
"name": "ohos.permission.ACCESS_BLUETOOTH",
"reason": "$string:access_bluetooth",
"usedScene": {
"abilities": ["EntryAbility"],
"when": "always"
}
},
{
"name": "ohos.permission.GYROSCOPE"
},
Expand Down
4 changes: 1 addition & 3 deletions src/app/lib/create-window.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const {
isDev, packInfo, iconPath, isMac,
minWindowWidth, minWindowHeight
} = require('../common/runtime-constants')
const defaults = require('../common/default-setting')
const {
getWindowSize,
setWindowPos
Expand All @@ -28,7 +27,6 @@ exports.createWindow = async function (userConfig) {
globalState.set('closeAction', 'closeApp')
globalState.set('requireAuth', !!userConfig.hashedPassword)
const { width, height, x, y } = await getWindowSize()
const { useSystemTitleBar = defaults.useSystemTitleBar } = userConfig
// HarmonyOS: `transparent: true` and `titleBarStyle: 'hidden'` are NOT
// supported — they cause a double title bar (the OS title bar plus the
// app's custom one). We therefore always use the system title bar,
Expand All @@ -45,7 +43,7 @@ exports.createWindow = async function (userConfig) {
minWidth: minWindowWidth,
minHeight: minWindowHeight,
title: packInfo.name,
frame: useSystemTitleBar,
frame: true,
backgroundColor: '#333333',
autoHideMenuBar: true,
webPreferences: {
Expand Down
Loading