Skip to content

Commit 0c3d8e2

Browse files
committed
Android: Using standard location for cli
1 parent ded6ba5 commit 0c3d8e2

File tree

5 files changed

+17
-11
lines changed

5 files changed

+17
-11
lines changed

Changelog

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ version 0.84.01
44
Updating lens info database ( exiftool 10.200 )
55
Testing support for K-1
66
Small speedup
7+
Increase Android 5 compatibility
8+
Android version requires Android 4.1 (http://stackoverflow.com/a/26422855/21348 )
79

810
version 0.84.00 ( 2016-05-09 )
911
servermode subcommand: set_shutter_speed, set_iso, usleep

android/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
android:label="@string/titlePrefs">
1717
</activity>
1818
</application>
19-
<uses-sdk android:minSdkVersion="12" />
19+
<uses-sdk android:minSdkVersion="16" />
2020
<uses-permission android:name="android.permission.INTERNET" />
2121
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
2222
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

android/jni/Android.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ LOCAL_SRC_FILES := ../../pslr_enum.c \
1111
../../pktriggercord-servermode.c \
1212
../../pktriggercord-cli.c
1313
DEFINES := -DANDROID -DVERSION=\"$(VERSION)\"
14-
LOCAL_CFLAGS := $(DEFINES) -frtti -I.. -Istlport -g
15-
LOCAL_LDLIBS := -llog -lstdc++
14+
LOCAL_CFLAGS := $(DEFINES) -frtti -I.. -Istlport -g -fPIE
15+
LOCAL_LDLIBS := -llog -lstdc++ -fPIE -pie
1616

1717
include $(BUILD_EXECUTABLE)

android/project.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
1212

1313
# Project target.
14-
target=android-12
14+
target=android-16

android/src/info/melda/sala/pktriggercord/PkTriggerCord.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import android.content.res.AssetManager;
66
import android.content.SharedPreferences;
77
import android.preference.PreferenceManager;
8+
import android.widget.Toast;
89
import java.io.*;
910
import java.util.ArrayList;
1011
import java.util.List;
@@ -14,15 +15,18 @@
1415

1516
public class PkTriggerCord extends Application {
1617
public static final String TAG = "PkTriggerCord";
17-
private static final String CLI_HOME = "/data/local/";
18-
private static final String CLI_DIR = "pktriggercord";
18+
private String cliHome;
19+
// private static final String CLI_DIR = "pktriggercord";
1920
private static final int MARK_LIMIT = 1000000;
2021
private Process p;
2122
private SharedPreferences prefs;
2223

2324
@Override
2425
public void onCreate() {
2526
super.onCreate();
27+
28+
cliHome = getApplicationContext().getFilesDir().getAbsolutePath();
29+
2630
PreferenceManager.setDefaultValues(this, R.xml.prefs, false);
2731
prefs = PreferenceManager.getDefaultSharedPreferences(this);
2832
Log.v( TAG, "Before installCli");
@@ -42,7 +46,7 @@ public String getSaveDir() {
4246
private void startCli() {
4347
try {
4448
p = new ProcessBuilder()
45-
.command("su", "-c", CLI_HOME+CLI_DIR+"/pktriggercord-cli --servermode")
49+
.command("su", "-c", cliHome+"/pktriggercord-cli --servermode")
4650
.start();
4751
SystemClock.sleep(1000);
4852
} catch( Exception e ) {
@@ -137,7 +141,7 @@ private void copyAsset(String fileName) throws Exception {
137141
boolean needCliInstall;
138142
AssetManager assetManager = getAssets();
139143
InputStream in = assetManager.open(fileName);
140-
String fullFileName = CLI_HOME + CLI_DIR + "/" + fileName;
144+
String fullFileName = cliHome + "/" + fileName;
141145

142146
try {
143147
FileInputStream fis = new FileInputStream(fullFileName);
@@ -157,9 +161,9 @@ private void copyAsset(String fileName) throws Exception {
157161
final int myUid = android.os.Process.myUid();
158162
Log.v( TAG, "myUid:"+myUid);
159163
simpleSudoWrapper( new ArrayList<String>() {{
160-
add("mkdir -p "+CLI_HOME+CLI_DIR);
161-
add("chown "+myUid+" "+CLI_HOME+CLI_DIR);
162-
add("chmod 777 "+CLI_HOME+CLI_DIR);
164+
add("mkdir -p "+cliHome);
165+
add("chown "+myUid+" "+cliHome);
166+
add("chmod 777 "+cliHome);
163167
}});
164168
Log.v( TAG, "After first simpleSudoWrapper");
165169
simpleSudoWrapper("rm -f "+fullFileName);

0 commit comments

Comments
 (0)