Skip to content

Commit f823c88

Browse files
committed
Fix recording failed problem after upgrade projects. Use lower target sdk version to avoid strict system storage access check.
1 parent 14255f3 commit f823c88

File tree

7 files changed

+55
-24
lines changed

7 files changed

+55
-24
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ ext {
2525
compileSdkVersion: 30,
2626
buildToolsVersion: '30.0.3',
2727
minSdkVersion : 16,
28-
targetSdkVersion : 30,
28+
targetSdkVersion : 25, // higher target version needs more storage permission request.
2929
versionCode : 1,
3030
versionName : "1.0.0",
3131
applicationId : "org.wysaid.cgeDemo",

cgeDemo/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ android {
2424
targetSdkVersion rootProject.ext.android.targetSdkVersion
2525
versionCode rootProject.ext.android.versionCode
2626
versionName rootProject.ext.android.versionName
27+
signingConfig signingConfigs.debug
2728
}
2829
buildTypes {
2930
release {

cgeDemo/src/main/AndroidManifest.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
3-
<!-- <uses-sdk android:minSdkVersion="14" -->
4-
<!-- android:targetSdkVersion="22" -->
5-
<!-- /> -->
63
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
74
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
85
<uses-permission android:name="android.permission.CAMERA" />

gradle.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryErro
1616
# org.gradle.parallel=true
1717

1818
android.useAndroidX=true
19-
android.enableJetifier=true
19+
android.enableJetifier=true
20+
android.injected.testOnly=false

library/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ android {
3131

3232
if (usingCMakeCompileDebug()) {
3333
cmakeBuildType = "-DCMAKE_BUILD_TYPE=Debug"
34-
cppExtraFlags = "-DDEBUG=1 -D_DEBUG=1"
34+
cppExtraFlags = "-DDEBUG=1 -D_DEBUG=1 -Od -g"
3535
} else {
3636
cmakeBuildType = "-DCMAKE_BUILD_TYPE=Release"
37-
cppExtraFlags = "-Os -DNDEBUG=1 -D_NDEBUG=1"
37+
cppExtraFlags = "-O2 -DNDEBUG=1 -D_NDEBUG=1"
3838
}
3939

4040
arguments "-DCGE_USE_VIDEO_MODULE=ON",

library/src/main/java/org/wysaid/myUtils/PermissionUtil.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public class PermissionUtil {
1414
private static final int REQUEST_PERMISSION = 0;
1515
private static String[] PERMISSIONS_STORAGE = {
1616
Manifest.permission.CAMERA,
17+
Manifest.permission.RECORD_AUDIO,
1718
Manifest.permission.WRITE_EXTERNAL_STORAGE,
1819
Manifest.permission.READ_EXTERNAL_STORAGE};
1920

vscode_tasks.sh

Lines changed: 48 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,23 @@ function setupProject() {
2323
}
2424

2525
function runAndroidApp() {
26-
. "$ADB_COMMAND" -d shell am start -n "$PACKAGE_NAME/$PACKAGE_NAME.$LAUNCH_ACTIVITY" &&
27-
. "$ADB_COMMAND" -d logcat | grep -iE "(cge|demo|wysaid)"
26+
27+
if . "$ADB_COMMAND" -d shell am start -n "$PACKAGE_NAME/$PACKAGE_NAME.$LAUNCH_ACTIVITY"; then
28+
if [[ -z "$(ps -ef | grep -i adb | grep -v grep | grep logcat)" ]]; then
29+
if [[ $(uname -s) == "Linux" ]] || [[ $(uname -s) == "Darwin" ]]; then
30+
APP_PROC_ID=$(adb shell ps | grep org.wysaid.cgeDemo | tr -s ' ' | cut -d' ' -f2)
31+
if [[ -n "$APP_PROC_ID" ]]; then
32+
. "$ADB_COMMAND" -d logcat | grep -F "$APP_PROC_ID"
33+
else
34+
echo "Can not find proc id of org.wysaid.cgeDemo"
35+
fi
36+
else
37+
. "$ADB_COMMAND" -d logcat | grep -iE "(cge|demo|wysaid| E |crash)"
38+
fi
39+
fi
40+
else
41+
echo "Launch $PACKAGE_NAME/$PACKAGE_NAME.$LAUNCH_ACTIVITY failed."
42+
fi
2843
}
2944

3045
function cleanProject() {
@@ -42,12 +57,17 @@ function buildProject() {
4257
exit 1
4358
fi
4459

45-
echo "apk generated at:"
46-
find "$THIS_DIR/cgeDemo/build" -iname "*.apk" | grep -i "${ANDROID_BUILD_TYPE/assemble/}"
60+
GENERATED_APK_FILE=$(find "$THIS_DIR/cgeDemo/build" -iname "*.apk" | grep -i "${ANDROID_BUILD_TYPE/assemble/}")
61+
echo "apk generated at: $GENERATED_APK_FILE"
4762

48-
if [[ -n "$GRADLEW_RUN_TASK" ]] && [[ $(. "$ADB_COMMAND" -d devices | grep -v 'List' | tr -d ' \n' | wc -l) -ne 0 ]]; then
49-
if ! ./gradlew -p cgeDemo "$GRADLEW_RUN_TASK"; then
50-
echo "Install failed." >&2
63+
if [[ -n "$GRADLEW_RUN_TASK" ]] && [[ $(. "$ADB_COMMAND" -d devices | grep -v 'List' | grep -vE '^$' | wc -l | tr -d ' ') -ne 0 ]]; then
64+
if [[ "$GRADLEW_RUN_TASK" == "installRelease" ]]; then
65+
# release can not be installed directly. do adb install.
66+
. $ADB_COMMAND -d install "$GENERATED_APK_FILE"
67+
else
68+
if ! ./gradlew -p cgeDemo "$GRADLEW_RUN_TASK"; then
69+
echo "Install failed." >&2
70+
fi
5171
fi
5272
else
5373
echo "No device connected, skip installation."
@@ -66,6 +86,23 @@ if [[ ! -f "local.properties" ]]; then
6686
fi
6787
fi
6888

89+
function changeProperty() {
90+
TARGET_FILE="$1"
91+
MATCH_PATTERN="$2"
92+
SED_PATTERN="$3"
93+
DEFAULT_VALUE="$4"
94+
if [[ -f "$TARGET_FILE" ]] && grep -E "$MATCH_PATTERN" "$TARGET_FILE" >/dev/null; then
95+
# Stupid diff between the command.
96+
if [[ "$(uname -s)" == "Darwin" ]]; then # Mac OS
97+
sed -I "" -E "$SED_PATTERN" "$TARGET_FILE"
98+
else
99+
sed -i"" -E "$SED_PATTERN" "$TARGET_FILE"
100+
fi
101+
else
102+
echo "$DEFAULT_VALUE" >>"$TARGET_FILE"
103+
fi
104+
}
105+
69106
while [[ $# > 0 ]]; do
70107

71108
PARSE_KEY="$1"
@@ -84,12 +121,15 @@ while [[ $# > 0 ]]; do
84121
;;
85122
--release)
86123
ANDROID_BUILD_TYPE="assembleRelease"
124+
# ANDROID_BUILD_TYPE="assembleDebug" # use this if the release apk can not be installed.
87125
GRADLEW_RUN_TASK="installRelease"
126+
changeProperty "local.properties" '^usingCMakeCompileDebug=' 's/usingCMakeCompileDebug=.*/usingCMakeCompileDebug=false/' 'usingCMakeCompileDebug=false'
88127
shift
89128
;;
90129
--debug)
91130
ANDROID_BUILD_TYPE="assembleDebug"
92131
GRADLEW_RUN_TASK="installDebug"
132+
changeProperty "local.properties" '^usingCMakeCompileDebug=' 's/usingCMakeCompileDebug=.*/usingCMakeCompileDebug=true/' 'usingCMakeCompileDebug=true'
93133
shift
94134
;;
95135
--setup-project)
@@ -113,16 +153,7 @@ while [[ $# > 0 ]]; do
113153
shift # past argument
114154
;;
115155
--enable-cmake)
116-
if [[ -f "local.properties" ]] && grep -E '^usingCMakeCompile=' "local.properties" >/dev/null; then
117-
# Stupid diff between the command.
118-
if [[ "$(uname -s)" == "Darwin" ]]; then # Mac OS
119-
sed -I "" -E 's/usingCMakeCompile=.*/usingCMakeCompile=true/' "local.properties"
120-
else
121-
sed -i"" -E 's/usingCMakeCompile=.*/usingCMakeCompile=true/' "local.properties"
122-
fi
123-
else
124-
echo "usingCMakeCompile=true" >>"local.properties"
125-
fi
156+
changeProperty "local.properties" '^usingCMakeCompile=' 's/usingCMakeCompile=.*/usingCMakeCompile=true/' 'usingCMakeCompile=true'
126157
shift # past argument
127158
;;
128159
*)

0 commit comments

Comments
 (0)