четверг, 16 мая 2019 г.

Git hooks

Original info:
https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks

My goal:
Validate commit message and deny commit if a comment didn't contain required tag

Step 1
Create copy of file from ~project folder~/.git/hooks/
File name - commit-msg.sample

Step 2
Rename copy to "commit-msg"

Step 3
Perform command: chmod +x commit-msg

Step 4
Edit file:



Now try to perform commit ;)

Example of second validation message:



Additional info:

If you want to share your hooks with all members of project - perform next steps:

Step 1

Create folder 'git-hooks' in root project directory

Step 2

Store here created files with your hooks

Step 3

In android gradle file (in my case - build.gradle for app.module ) add next:



Step 4

Now rebuild your project. All your hooks will be copied to .git/hooks folder

WARNING:

If you want to remove hooks - don't forget to remove it manually from folder .git/hooks/

Android Studio in my post case use only hooks from .git/hooks/ folder


среда, 13 июня 2018 г.

Print custom data to JUnit success result

    @Test
    public void test()
    {
        out("Current device = SM-G920F");
    }

    private void out(String str) {
        Bundle b = new Bundle();
        b.putString(Instrumentation.REPORT_KEY_STREAMRESULT, "\n" + str);
        InstrumentationRegistry.getInstrumentation().sendStatus(0, b);
    }



Add KV data to JUnit test (console run)

adb shell am instrument -w -e class com.example.developer.appname.SomeTests#testName -e key1 param1 -e key2 param2 com.example.developer.appname.test/android.support.test.runner.AndroidJUnitRunner

Spaces and some other characters is not supported in key or value
in android test use InstrumentationRegistry.getArguments().get(key)

Run anroid JUnit test with android JUnit runner from console

adb shell am instrument -w -e class com.example.developer.appname.SomeTests#testName  com.example.developer.appname.test/android.support.test.runner.AndroidJUnitRunner

вторник, 20 февраля 2018 г.

adb getprop

Get device properties by adb (tested on API 19, 25)

adb shell getprop

for custom prop(example: get device name (String)) (tested on API 19, 25)

adb shell getprop ro.product.model

Example:

adb get settings system

Get system device settings by adb (tested on API 25)

adb shell settings list system

for custom setting (example: get current system volume (int))(tested on API 19)

adb shell settings get system volume_ring

For more info:

https://developer.android.com/reference/android/provider/Settings.System.html

Example:

adb get settings secure

Get secure device settings by adb (tested on API 25)

adb shell settings list secure

for custom setting (example: get current mock_location state (enabled/disabled))(tested on API 19)

adb shell settings get secure mock_location

For more info:

https://developer.android.com/reference/android/provider/Settings.Secure.html

Example:

adb get settings global

Get global device settings by adb (tested on API 25)

adb shell settings list global

for custom setting (example: get current bluetooth state (enabled/disabled))(tested on API 19)

adb shell settings get global bluetooth_on

For more info:

https://developer.android.com/reference/android/provider/Settings.Global.html

Example:

Git hooks

Original info: https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks My goal: Validate commit message and deny commit if a comment di...