Skip to content

Commit

Permalink
Merge pull request #35 from smartdevicelink/release/2.11.0
Browse files Browse the repository at this point in the history
Release/2.11.0
  • Loading branch information
crokita authored Nov 10, 2022
2 parents 45b8d0d + 8ef78d1 commit 25c4d96
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 43 deletions.
Binary file added .DS_Store
Binary file not shown.
143 changes: 100 additions & 43 deletions cores/policy/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,7 @@ router.post('/api/v1/production/policy', async (ctx, next) => {
if (ctx.request.body.policy_table && ctx.request.body.policy_table.app_policies) {
for (let appId in ctx.request.body.policy_table.app_policies) {
if (appId !== "default" && appId !== "device" && appId !== "pre_DataConsent") {
if (appsRequestingWebView.includes(appId)) {
table.policy_table.app_policies[appId] = webViewPolicyObj;
} else if (table.policy_table.app_policies[appId] === undefined) {
if (table.policy_table.app_policies[appId] === undefined) { // give default permissions to unknown apps
table.policy_table.app_policies[appId] = "default";
}
}
Expand All @@ -102,6 +100,31 @@ const cloudPostSchema = Joi.object().keys({
nicknames: Joi.array().items(Joi.string()).required()
})

router.get('/api/v1/cloud', async (ctx, next) => {
let table = JSON.parse(await readFile(ptPath))
let results = []
for (let appId in table.policy_table.app_policies) {
if (appId !== "default" && appId !== "device" && appId !== "pre_DataConsent") {
const appObj = table.policy_table.app_policies[appId]
// only retrieve cloud apps here. check for existing parameters for specifically cloud apps
if (appObj.endpoint !== undefined && appObj.auth_token !== undefined) {
let request = {
app_id: appId,
endpoint: appObj.endpoint,
auth_token: appObj.auth_token,
nicknames: appObj.nicknames
}
results.push(request);
}
}
}
ctx.response.status = 200
return ctx.body = {
app_policies: results,
webEngineApps: appsRequestingWebView
}
})

//the Manticore UI hits this endpoint
router.post('/api/v1/cloud', async (ctx, next) => {
const { body } = ctx.request
Expand Down Expand Up @@ -130,6 +153,29 @@ router.post('/api/v1/cloud', async (ctx, next) => {
}
})

// the Manticore UI hits this endpoint
// Adds an app to the list of apps requesting the WEB_VIEW HMI Type
router.post('/api/v1/webview', async (ctx, next) => {
const { body } = ctx.request;

if (body.app_id && body.hasWebViewFlipped !== undefined) {
let table = JSON.parse(await readFile(ptPath))
// add the app to the table
table.policy_table.app_policies[body.app_id] = createWebEngineObj(!body.hasWebViewFlipped)
// remember the input information because it's not saved in the policy table
appsRequestingWebView.push({
app_id: body.app_id,
hasWebViewFlipped: body.hasWebViewFlipped,
nicknames: body.nicknames,
url: body.url
})
await writeFile(ptPath, JSON.stringify(table, null, 4))
await writeFile(ptOutPath, JSON.stringify(table, null, 4))
ctx.response.status = 200
return
}
})

const cloudDeleteSchema = Joi.object().keys({
app_id: Joi.string().regex(/^[A-z0-9\-]+$/, 'Alphanumeric Plus Hyphens').required()
})
Expand Down Expand Up @@ -164,51 +210,62 @@ router.delete('/api/v1/cloud', async (ctx, next) => {
})

// the Manticore UI hits this endpoint
// Adds an app to the list of apps requesting the WEB_VIEW HMI Type
router.post('/api/v1/webview', async (ctx, next) => {
const { body } = ctx.request;
// Removes an app from the list of apps requesting the WEB_VIEW HMI Type
router.delete('/api/v1/webview', async (ctx, next) => {
const { body } = ctx.request

if (body.app_id) {
// make sure it isn't in our webengine in-memory array
appsRequestingWebView = appsRequestingWebView.filter((obj) => {
return obj.app_id !== body.app_id
})

if (body.app_id && body.hasWebView) {
// The app wants WEB_VIEW, add it to the list
appsRequestingWebView.push(body.app_id);
} else {
// The app doesn't want WEB_VIEW or wants it removed, make sure it isn't in the list
appsRequestingWebView = appsRequestingWebView.filter((id) => {
return id !== body.app_id;
});
let table = JSON.parse(await readFile(ptPath))
//remove the app id from the table
if (table.policy_table.app_policies[body.app_id]) {
delete table.policy_table.app_policies[body.app_id];
}
await writeFile(ptPath, JSON.stringify(table, null, 4))
await writeFile(ptOutPath, JSON.stringify(table, null, 4))
}
ctx.response.status = 200
});

const webViewPolicyObj = {
"keep_context": false,
"steal_focus": false,
"priority": "EMERGENCY",
"default_hmi": "NONE",
"groups": ["Base-4", "Location-1", "Notifications", "Notifications-RC", "DrivingCharacteristics-3", "VehicleInfo-3", "PropriataryData-1", "PropriataryData-2", "ProprietaryData-3", "CloudAppStore", "CloudApp", "AppServiceProvider", "AppServiceConsumer", "RemoteControl", "Emergency-1", "Navigation-1", "Base-6", "OnKeyboardInputOnlyGroup", "OnTouchEventOnlyGroup", "DiagnosticMessageOnly", "DataConsent-2", "BaseBeforeDataConsent", "SendLocation", "WayPoints", "BackgroundAPT", "HapticGroup", "WidgetSupport"],
"moduleType": ["CLIMATE", "RADIO", "SEAT", "AUDIO", "LIGHT", "HMI_SETTINGS"],
"RequestType": [],
"RequestSubType": [],
"AppHMIType": ["DEFAULT", "COMMUNICATION", "MEDIA", "MESSAGING", "NAVIGATION", "INFORMATION", "SOCIAL", "BACKGROUND_PROCESS", "TESTING", "SYSTEM", "PROJECTION", "REMOTE_CONTROL", "WEB_VIEW"],
"app_services": {
"MEDIA": {
"handled_rpcs": [
{ "function_id": 41 }
]
},
"NAVIGATION": {
"handled_rpcs": [
{ "function_id": 39 },
{ "function_id": 45 },
{ "function_id": 46 },
{ "function_id": 32784 }
]
},
"WEATHER": {
"handled_rpcs": [
]
})

function createWebEngineObj (withWebView) {
const obj = {
"keep_context": false,
"steal_focus": false,
"priority": "EMERGENCY",
"default_hmi": "NONE",
"groups": ["Base-4", "Location-1", "Notifications", "Notifications-RC", "DrivingCharacteristics-3", "VehicleInfo-3", "PropriataryData-1", "PropriataryData-2", "ProprietaryData-3", "CloudAppStore", "CloudApp", "AppServiceProvider", "AppServiceConsumer", "RemoteControl", "Emergency-1", "Navigation-1", "Base-6", "OnKeyboardInputOnlyGroup", "OnTouchEventOnlyGroup", "DiagnosticMessageOnly", "DataConsent-2", "BaseBeforeDataConsent", "SendLocation", "WayPoints", "BackgroundAPT", "HapticGroup", "WidgetSupport"],
"moduleType": ["CLIMATE", "RADIO", "SEAT", "AUDIO", "LIGHT", "HMI_SETTINGS"],
"RequestType": [],
"RequestSubType": [],
"AppHMIType": ["DEFAULT", "COMMUNICATION", "MEDIA", "MESSAGING", "NAVIGATION", "INFORMATION", "SOCIAL", "BACKGROUND_PROCESS", "TESTING", "SYSTEM", "PROJECTION", "REMOTE_CONTROL"],
"app_services": {
"MEDIA": {
"handled_rpcs": [
{ "function_id": 41 }
]
},
"NAVIGATION": {
"handled_rpcs": [
{ "function_id": 39 },
{ "function_id": 45 },
{ "function_id": 46 },
{ "function_id": 32784 }
]
},
"WEATHER": {
"handled_rpcs": [
]
}
}
}
if (withWebView) {
obj.AppHMIType.push("WEB_VIEW")
}
return obj;
}

function createAppPolicyObj (cloudPost, isSecure) {
Expand Down
7 changes: 7 additions & 0 deletions cores/sdl_preloaded_pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -1051,6 +1051,13 @@
"LIMITED"
]
},
"OnTBTClientState": {
"hmi_levels": [
"BACKGROUND",
"FULL",
"LIMITED"
]
},
"ShowConstantTBT": {
"hmi_levels": [
"BACKGROUND",
Expand Down

0 comments on commit 25c4d96

Please sign in to comment.