韌館-LearnHouse

Archive for the '程式&軟體' Category

[轉]linux系統上source、sh、bash、./的區別

最近在寫shell script來做自動化,才發現原來source和sh是大大的不同,要謹慎使用,不然會一直鬼打牆...

資料來源:https://www.cnblogs.com/pcat/p/5467188.html
在linux裡,source、sh、bash、./都可以執行shell script文件,那它們有什麼不同嗎?
1、source

source a.sh

在當前shell內去讀取、執行a.sh,而a.sh不需要有"執行權限"
source命令可以簡寫為"."

. a.sh

注意:中間是有空格的。
Read more...

2022年8 月 posted by admin in 程式&軟體 and have No Comments

[Android]JNI呼叫C/C++函式傳遞Int Array參數與返回Array值

上層Java呼叫C/C++的函式

public native void 2DArrayInput(int[][] inputData);
public native int[] returnArray(int[] inputData2);

二維int陣列傳值:

public final static int[][] inputData = {
                                       {0x0226,0x00}
                                      ,{0x0227,0x40}
                                      ,{0x0228,0x00}
                                    };
JniTest jnitest = new JniTest();
jnitest.2DArrayInput(inputData);

Read more...

2022年7 月 posted by admin in 程式&軟體 and have No Comments

[Android]如何在AOSP下編譯JNI

JNI是什麼,我就不多作介紹,估狗一下應該資料就一堆,而且也會有很多教學。不過一般找到的教學都是透過Android Studio寫APP使用JNI的方式。卻找不到如果是AOSP開發者,如何撰寫JNI與配置Android.mk。

首先在你的上層JAVA的APP新增class介面來提供呼叫底層的API,其中System.loadLibrary的部分還可以不用先寫,不過寫了也不會影響產出header檔。
這裡宣告一個呼叫底層的函式,帶入整數值並回傳字串。 Read more...

2022年7 月 posted by admin in 程式&軟體 and have No Comments

[Android]Play Auto Installs (PAI),編譯失敗FAILED: ninja: unknown target 'MODULES-IN-PlayAutoInstallConfig'

由於Google有明確說此文件為Confidential material,也因為如此,當使用相關技術的開發時,常常會面臨實作不出來或遇到問題,上網Google卻又找不到相關討論或解決方法。
有鑑於此,在這記錄一下解決方法供給其他OEM的開發者參考,因此就不細說其運作原理,知道的人就知道要做什麼
不過還是要感謝對岸的作者,我也是參考它的範例進行修改:https://blog.csdn.net/xct841990555/article/details/80896429
Read more...

2022年1 月 posted by admin in 程式&軟體 and have No Comments

[Android]OTA差分包(Incremental OTA)升級失敗訊息與解法

我們都知道要產生Incremental OTA的方法可以透過下列指令:

$./build/tools/releasetools/ota_from_target_files -v --block -p out/host/linux-x86 -k YOUR_KEY -i target_files-old.zip target_files-new.zip update.zip

其中
-k YOUR_KEY指的是你的KEY路徑,通常是vendor/company/security/releasekey
-i target_files-old.zip是上一次build的target file,產生在./out/target/product/device/obj/PACKAGING/target_files_intermediates下;target_files-new.zip則是這次build的,路徑也是在一樣的地方;update.zip則是要產生的差分包。
紅色的部分是依你的project不同則有不同的名稱。
Read more...

2021年8 月 posted by admin in 程式&軟體 and have No Comments

[Android]監聽螢幕狀態與主動喚醒螢幕

由於需要APP能在Android TV進入sleep mode後還能透過網路被喚醒並播放聲音,經過一陣子的survey,發現可以用以下的方法來達到效果,先用wake lock喚醒螢幕再播放聲音。
首先要加入權限

<uses-permission android:name="android.permission.WAKE_LOCK" />

Read more...

2021年1 月 posted by admin in 程式&軟體 and have No Comments