Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Svistelnikoff@work review #28

Open
wants to merge 5 commits into
base: Vladimir.Svistelnikov
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "apps/gl-android-training"]
path = apps/gl-android-training
url = [email protected]:svistelnikoff/gl-android-training-2019.git
branch = svistelnikoff@work-03
6 changes: 6 additions & 0 deletions 02-Git/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Homework
Create a question-answer game (e.g. guess a number, paper-rock-scissors etc).

1. Main goal is not the game itself, but the proper commit structure.
2. Minimum 3 commits.
3. Follow all the rules.
60 changes: 58 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,58 @@
# gl-android-training-2019
Android system general course by GlobalLogic Kharkiv, 2019
# GL hikey960 android howto

## Sources locations

Android manifest - [email protected]:svistelnikoff/android_manifest.git ( branch gl-hikey960 )
Hikey960 BSP - [email protected]:svistelnikoff/hikey-linaro-device.git ( branch svistelnikoff@gl-hikey960-base )
Hikey960 kernel - [email protected]:svistelnikoff/hikey-linaro-kernel.git ( branch [email protected] )

Vendor specific sources
Software - [email protected]:svistelnikoff/gl-android-training-2019.git ( branch svistelnikoff@vendor-gl )

.
├── apps vendor-specific applications
│   └── gl-android-training pllcications implemented as submodule ( svistelnikoff@work-03 )
│   └── 03-Service
│   ├── GetSetService service: serves get/set random value requests, interacts with HAL
│   ├── GetterApp getter: reads value of saved random value on button click
│   └── SetterApp setter: sets new random, sends intents to control leds
├── config hal: config
├── interfaces hal: interface
│   └── ledcontrol
│   └── 1.0
│   └── default
└── sepolicy hal: policies

## Build HOWTO

Pull sources:
`$ cd ~/`
`$ mkdir hikey960`
`$ cd hikey960`
`$ repo init -u [email protected]:svistelnikoff/android_manifest.git -b gl-hikey960`
`$ repo sync -j4 -c -f`

Download and extract HDMI proprietary binaries for Hikey960 (from the project home folder):
`$ wget https://dl.google.com/dl/android/aosp/arm-hikey960-OPR-cf4e0c80.tgz`
`$ tar xzf arm-hikey960-OPR-cf4e0c80.tgz`
`$ ./extract-arm-hikey960.sh`

Build
`$ cd hikey960`
`$ . ./build/envsetup.sh`
`$ lunch hikey960-userdebug`
`$ make -j8`

## Flash firmware

Enter fastboot mode. There are two options:
- power off the board, turn ON dipswitch 1 and 3, power on the board.
- connect the board via USB and run from host machine:
`$ adb reboot bootloader`
Check if device has entered bootloader, run from host machine:
`fastboot devices`
Flash device:
`$ cd device/linaro/hikey/installer/hikey960`
`$ ./flash-all.sh`


1 change: 1 addition & 0 deletions apps/gl-android-training
Submodule gl-android-training added at cd524d
8 changes: 8 additions & 0 deletions config/Android.bp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
*
*/

hidl_package_root {
name: "vendor.gl",
path: "vendor/gl/interfaces"
}
8 changes: 8 additions & 0 deletions config/config.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[AID_VENDOR_LEDCONTROL]
value: 2901

[system/vendor/bin/hw/[email protected]]
mode: 0775
user: AID_VENDOR_LEDCONTROL
group: AID_VENDOR_LEDCONTROL
caps: 0
17 changes: 17 additions & 0 deletions config/gl-hikey960.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
##

PRODUCT_PACKAGES += \
[email protected] \
vendor.gl.ledcontrol-V1.0-java

DEVICE_MANIFEST_FILE += \
vendor/gl/interfaces/manifest.xml

DEVICE_MATRIX_FILE += \
vendor/gl/interfaces/compatibility_matrix.xml

BOARD_SEPOLICY_DIRS += \
vendor/gl/sepolicy

TARGET_FS_CONFIG_GEN += \
vendor/gl/config/config.fs
4 changes: 4 additions & 0 deletions gl-vendor.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

PRODUCT_PACKAGES += GetSetService
PRODUCT_PACKAGES += GetterApp
PRODUCT_PACKAGES += SetterApp
71 changes: 71 additions & 0 deletions interfaces/compatibility_matrix.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<compatibility-matrix version="1.0" type="device">
<hal format="hidl" optional="false">
<name>android.frameworks.schedulerservice</name>
<version>1.0</version>
<interface>
<name>ISchedulingPolicyService</name>
<instance>default</instance>
</interface>
</hal>
<hal format="hidl" optional="false">
<name>android.frameworks.sensorservice</name>
<version>1.0</version>
<interface>
<name>ISensorManager</name>
<instance>default</instance>
</interface>
</hal>
<hal format="hidl" optional="false">
<name>android.hidl.allocator</name>
<version>1.0</version>
<interface>
<name>IAllocator</name>
<instance>ashmem</instance>
</interface>
</hal>
<hal format="hidl" optional="false">
<name>android.hidl.manager</name>
<version>1.0</version>
<interface>
<name>IServiceManager</name>
<instance>default</instance>
</interface>
</hal>
<hal format="hidl" optional="false">
<name>android.hidl.memory</name>
<version>1.0</version>
<interface>
<name>IMapper</name>
<instance>ashmem</instance>
</interface>
</hal>
<hal format="hidl" optional="false">
<name>android.hidl.token</name>
<version>1.0</version>
<interface>
<name>ITokenManager</name>
<instance>default</instance>
</interface>
</hal>
<hal format="hidl" optional="false">
<name>android.system.wifi.keystore</name>
<version>1.0</version>
<interface>
<name>IKeystore</name>
<instance>default</instance>
</interface>
</hal>
<hal format="native" optional="false">
<name>netutils-wrapper</name>
<!--
netutils-wrapper should only list a single version x.0.
netutils-wrapper next version has less functionalities than
previous versions, so unlike a HAL, netutils-wrapper are not
backwards compatible. Hence the major version must be bumped for
each update.
Vendor code should switch to (x+1).0 completely before when the
requirement is updated here.
-->
<version>1.0</version>
</hal>
</compatibility-matrix>
19 changes: 19 additions & 0 deletions interfaces/ledcontrol/1.0/Android.bp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// This file is autogenerated by hidl-gen -Landroidbp.

hidl_interface {
name: "[email protected]",
root: "vendor.gl",
srcs: [
"types.hal",
"ILedControl.hal",
],
interfaces: [
"[email protected]",
],
types: [
"LedState",
"Leds",
],
gen_java: true,
}

34 changes: 34 additions & 0 deletions interfaces/ledcontrol/1.0/ILedControl.hal
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* (License Notice)
*/

package [email protected];

/**
* ILedControl interface description
*/
interface ILedControl {

/**
* ILedControl initialization function.
*
* @return result 0 if successful, nonzero otherwise.
*/
initialize() generates (int32_t result);

/**
* ILedControl SetLedState function.
*
* @return result 0 if successful, nonzero otherwise.
*/
setLedState(Leds led, LedState state) generates (int32_t result);

/**
* ILedControl terminate function.
*
* @return result 0 if successful, nonzero otherwise.
*/
terminate() generates (int32_t result);


};
17 changes: 17 additions & 0 deletions interfaces/ledcontrol/1.0/default/Android.bp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
cc_binary {
name: "[email protected]",
init_rc: ["[email protected]"],
relative_install_path: "hw",
vendor: true,
srcs: [
"LedControl.cpp",
"service.cpp",
],
shared_libs: [
"libhidlbase",
"libhidltransport",
"libutils",
"liblog",
"[email protected]",
],
}
68 changes: 68 additions & 0 deletions interfaces/ledcontrol/1.0/default/LedControl.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/**
* Copyrights
*/

#include "LedControl.h"
#include <log/log.h>
#include <cstdio>
#include <cerrno>
#include <cstring>

namespace vendor {
namespace gl {
namespace ledcontrol {
namespace V1_0 {


LedControl::LedControl() {
ALOGI( "LedControl::LedControl() - instance created" );
}

LedControl::~LedControl() {
ALOGI( "LedControl::LedControl(): instance destroyed" );
}

Return<int32_t> LedControl::initialize(void) {
ALOGI( "LedControl::initialize()" );
return 0;
}

Return<int32_t> LedControl::terminate(void) {
ALOGI( "LedControl::terminate()" );
return 0;
}

Return<int32_t> LedControl::setLedState(Leds led, LedState state) {
ALOGI( "LedControl::setLedState(): led %hhu -> %hhu", led, state );
char ledDevice[64] = { 0 };
if(snprintf(ledDevice, sizeof(ledDevice), "/sys/class/leds/user_led%hhu/brightness", led) <= 0) {
ALOGE( "Failed to init ledDevice string" );
return -1;
}
FILE* fdLed = fopen(ledDevice, "w");
if(nullptr == fdLed) {
ALOGE( "Failed to open ledDevice: led %hhu", led );
ALOGE( "Errno: %d - %s", errno, std::strerror(errno));
return -1;
}
fprintf(fdLed, "%hhu\n", state);
fclose(fdLed);

return 0;
}

// private
bool LedControl::setTrigger(Leds led, const std::string& trigger) {
ALOGI( "LedControl::setTrigger(): led %hhu -> %s", led, trigger.c_str() );
return true;
}

bool LedControl::setBrightness(Leds led, LedState state) {
ALOGI( "LedControl::setBrightness(): led %hhu -> %hhu", led, state );
return true;
}

} // namespace V1_0
} // namespace ledcontrol
} // namespace gl
} // namespace vendor
36 changes: 36 additions & 0 deletions interfaces/ledcontrol/1.0/default/LedControl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* Copyrights
*/

#ifndef vendor_gl_ledcontrol_V1_0_LedControl_H_
#define vendor_gl_ledcontrol_V1_0_LedControl_H_
#pragma once

#include <vendor/gl/ledcontrol/1.0/ILedControl.h>

namespace vendor {
namespace gl {
namespace ledcontrol {
namespace V1_0 {

using namespace android::hardware;

class LedControl : public ILedControl {
public:
LedControl();
~LedControl();
Return<int32_t> initialize(void) override;
Return<int32_t> terminate(void) override;
Return<int32_t> setLedState(Leds led, LedState state) override;

private:
bool setTrigger(Leds led, const std::string& trigger);
bool setBrightness(Leds led, LedState state);
};

} // namespace V1_0
} // namespace ledcontrol
} // namespace gl
} // namespace vendor

#endif //vendor_gl_ledcontrol_V1_0_LedControl_H_
Loading