韌館-LearnHouse

Archive for the '程式&軟體' Category

[Android]如何在APP透過USB OTA zip實作AB update

由於一開始是在trace原生的AOSP在recovery mode下是如何透過USB更新,因此這裡還是會紀錄一下native下是如何進行的,然後再說如何使用UpdateEngine這個Java layer的API來實作。

Read more...

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

執行CTS一直遇到 AAPT_PARSER_FAILED

運行CTS會發現有些測項會出現類似以下的error message:

Early failure resulting in no testRunStart. Results might be inconsistent:
com.android.tradefed.targetprep.TargetSetupError[AAPT_PARSER_FAILED|520050|DEPENDENCY_ISSUE]: AaptParser failed for file CtsContentTestCases.apk. The APK won't be installed [XXXX AA]

代表你的aapt2版本太舊,需要到官網下載最新版本取代
https://maven.google.com/web/index.html#com.android.tools.build:aapt2
Read more...

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

[轉][Android]兩個APP如何實作IPC呼叫

資料來源:https://givemepass.blogspot.com/2015/11/aidl_27.html

為了預防哪天該網站的重要資料失聯,因此在這裡備份一下,以下為該網誌的內容:

如果想要透過另外一個Process幫你執行程式, 你可以利用AIDL去跟Process溝通,
如何使用AIDL中有簡單介紹一下AIDL,
但是其實有很多細節並沒有說明, 所以這邊來實作非同步的範例。
更多的AIDL可以參考[官網]。

Read more...
2022年11 月 posted by admin in 程式&軟體 and have No Comments

[轉]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