Commit Graph

234 Commits

Author SHA1 Message Date
Twaik Yont
3afcae5cec Various changes:
1. Fix for https://github.com/termux/termux-packages/issues/10940 working inside shell_loader
2. Getting rid of using `Reflection` API and `CrossVersionReflectedMethod` in the project
3. Unhiding some non-SDK API's to the project using gradle's `compileOnly` dependency
4. Getting rid of library unpacking and making loader open it directly from apk ( 6cdfb75c44 (commitcomment-77856313) ). @agnostic-apollo is the best!!!

Some cleanup...
Bumping versionCode
2022-07-25 16:17:56 +03:00
gradle-update-robot
d3485b2f69 Update Gradle Wrapper from 7.4.2 to 7.5.
Signed-off-by: gradle-update-robot <gradle-update-robot@regolo.cc>
2022-07-16 13:05:04 +05:30
dependabot[bot]
16924683b4 Bump annotation from 1.3.0 to 1.4.0
Bumps annotation from 1.3.0 to 1.4.0.

---
updated-dependencies:
- dependency-name: androidx.annotation:annotation
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-07-06 00:46:07 -04:00
agnostic-apollo
757c3e34ae Fixed: Fix ClassCastException for LAUNCHED_BY_COMPATION extra passed to MainActivity
com.termux.x11 W/Bundle: Key com.termux.x11.launched_by_companion expected String but value was a java.lang.Integer.  The default value <null> was returned.
com.termux.x11 W/Bundle: Attempt to cast generated internal exception:
    java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
        at android.os.BaseBundle.getString(BaseBundle.java:1199)
        at android.content.Intent.getStringExtra(Intent.java:8248)
        at com.termux.x11.MainActivity.onCreate(MainActivity.java:62)
2022-07-06 02:38:47 +05:00
agnostic-apollo
6cdfb75c44 Fixed: Fix UnsatisfiedLinkError exception while calling native methods on Android < 10
```
~ $ termux-x11 :0
java.lang.UnsatisfiedLinkError: No implementation found for void com.termux.x11.starter.Starter.checkXdgRuntimeDir() (tried Java_com_termux_x11_starter_Starter_checkXdgRuntimeDir and Java_com_termux_x11_starter_Starter_checkXdgRuntimeDir__)
        at com.termux.x11.starter.Starter.checkXdgRuntimeDir(Native Method)
        at com.termux.x11.starter.Starter.onRun(Starter.java:84)
        at com.termux.x11.starter.Starter.lambda$main$0(Starter.java:61)
        at com.termux.x11.starter.Starter$$ExternalSyntheticLambda1.run(Unknown Source)
        at java.lang.Thread.run(Thread.java:762)

```

The issue was fixed by calling `System.load()` instead of `Runtime.getRuntime().load()`.

Before 2018-07/f0346c9f/android 10, android was not using `Reflection.getCallerClass()` to get caller class of methods and was using either `VMStack.getCallerClass1()` or `VMStack.getCallerClass2()`. The `VMStack.getCallerClass2()` is a native method and returns class of the caller's caller. It is "normally not supposed" to be called directly and instead `VMStack.getCallerClass1()` should be called instead, which calls `VMStack.getCallerClass2()` itself, effectively returning caller's class, due to an additional stack frame for the `VMStack.getCallerClass1()` wrapper.

```
public static Class<?> getStackClass1() {
    return getStackClass2();
}

native public static Class<?> getStackClass2();
```

caller2() -> caller1() -> `VMStack.getCallerClass1()` -> `VMStack.getCallerClass2()` = Returns caller2's class

caller2() -> caller1() -> `VMStack.getCallerClass2()` = Returns caller2's caller class (caller3)

Now for issue at hand, let's check implementation of `System.load()` and `Runtime.load()`.

Before f0346c9f

```
System.load(String filename) {
    Runtime.getRuntime().load0(VMStack.getStackClass1(), filename);
}

Runtime.load(String filename) {
    load0(VMStack.getStackClass2(), filename);
}
```

After f0346c9f

```
System.load(String filename) {
    Runtime.getRuntime().load0(Reflection.getCallerClass(), filename);
}

Runtime.load(String filename) {
    load0(Reflection.getCallerClass(), filename);
}
```

The javadocs for `System.load()` say that `The call System.load(name) is effectively equivalent to the call: Runtime.getRuntime().load(name)`, but that is technically not true, before f0346c9f, they were not the same. As you can see, `Runtime.load()` will use caller's caller class instead of caller's class and so will use the wrong `ClassLoader` when calling `fromClass.getClassLoader()` later in `Runtime.load0()`. After f0346c9f, ClassLoader used will actually be same for both calls.

Now normally, this shouldn't be an issue if called in an app with nested method calls. But if you are using `/system/bin/app_process` to start a process from an apk, with its `main()` function as entry point, then both the `main()` function and the main class's static block, will have a different `caller3` class while loading, i.e `RuntimeInit`. So if `Runtime.getRuntime().load()` is used in either of them, the load call will fail and so `System.load()` must be used to make loading work on all android versions. However, you can use either inside any methods called from `main()`.

```
export CLASSPATH=/data/data/com.termux/files/usr/libexec/termux-x11/starter.apk
unset LD_LIBRARY_PATH LD_PRELOAD
exec /system/bin/app_process / com.termux.x11.starter.Starter "$@"
```

```
Log.i("starter", "caller=" + Thread.currentThread().getStackTrace()[2].getClassName());
Log.i("starter", "caller=" + Thread.currentThread().getStackTrace()[3].getClassName());

I/starter: caller2=com.termux.x11.starter.Starter
I/starter: caller3=com.android.internal.os.RuntimeInit
```

https://cs.android.com/android/_/android/platform/libcore/+/f0346c9f

https://cs.android.com/android/platform/superproject/+/android-7.0.0_r1:libcore/ojluni/src/main/java/java/lang/System.java;l=1505
https://cs.android.com/android/platform/superproject/+/android-12.0.0_r34:libcore/ojluni/src/main/java/java/lang/System.java;l=1620

https://cs.android.com/android/platform/superproject/+/android-7.0.0_r1:libcore/ojluni/src/main/java/java/lang/Runtime.java;l=871
https://cs.android.com/android/platform/superproject/+/android-12.0.0_r34:libcore/ojluni/src/main/java/java/lang/Runtime.java;l=892

https://cs.android.com/android/platform/superproject/+/android-7.0.0_r1:libcore/libart/src/main/java/dalvik/system/VMStack.java;l=40
https://cs.android.com/android/platform/superproject/+/android-12.0.0_r34:libcore/libart/src/main/java/dalvik/system/VMStack.java;l=67

https://cs.android.com/android/platform/superproject/+/android-12.0.0_r34:libcore/ojluni/src/main/java/sun/reflect/Reflection.java;l=75

https://github.com/termux/termux-x11/blob/f9a9ce31/termux-x11

Also changing native lib name since `libstarter` is too generic a name which may conflict with potential system libs causing similar issues. Related https://stackoverflow.com/a/27760201

Closes #56
2022-07-05 10:08:53 +05:00
agnostic-apollo
333de111dd Changed: Use compileSdkVersion 30 and do not use buildToolsVersion 2022-07-05 08:19:02 +05:00
agnostic-apollo
cd395e7c98 Fixed: Fix device doesn't support picture-in-picture mode on Android < 8 2022-07-05 08:17:36 +05:00
dependabot[bot]
30afd3244d Bump constraintlayout from 2.1.3 to 2.1.4
Bumps [constraintlayout](https://github.com/androidx/constraintlayout) from 2.1.3 to 2.1.4.
- [Release notes](https://github.com/androidx/constraintlayout/releases)
- [Commits](https://github.com/androidx/constraintlayout/commits)

---
updated-dependencies:
- dependency-name: androidx.constraintlayout:constraintlayout
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-06-01 08:22:20 +05:30
dependabot[bot]
d5c3b2f1fc Bump gradle from 7.1.3 to 7.2.1
Bumps gradle from 7.1.3 to 7.2.1.

---
updated-dependencies:
- dependency-name: com.android.tools.build:gradle
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-06-01 08:19:14 +05:30
gradle-update-robot
ab34e5462c Update Gradle Wrapper from 7.4 to 7.4.2.
Signed-off-by: gradle-update-robot <gradle-update-robot@regolo.cc>
2022-05-03 12:15:22 +05:30
dependabot[bot]
06f8f5020e Bump gradle from 7.1.2 to 7.1.3
Bumps gradle from 7.1.2 to 7.1.3.

---
updated-dependencies:
- dependency-name: com.android.tools.build:gradle
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-03 12:14:58 +05:30
Arvind Kaushik
bac5034ec3
NoActionBar for fullscreen mode (#103) 2022-04-01 11:28:00 +03:00
marcusz
491cc8304d
README: Start termux-x11 without suppressing the output
When suppressing it would be difficult to diagnose issues
2022-03-17 16:26:45 +08:00
gradle-update-robot
41f1f7f339 Update Gradle Wrapper from 7.3.3 to 7.4.
Signed-off-by: gradle-update-robot <gradle-update-robot@regolo.cc>
2022-03-12 08:50:26 +05:30
dependabot[bot]
879a7f291a Bump gradle from 7.1.1 to 7.1.2
Bumps gradle from 7.1.1 to 7.1.2.

---
updated-dependencies:
- dependency-name: com.android.tools.build:gradle
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-12 08:50:12 +05:30
dependabot[bot]
d97ee1562a Bump gradle from 7.0.4 to 7.1.1
Bumps gradle from 7.0.4 to 7.1.1.

---
updated-dependencies:
- dependency-name: com.android.tools.build:gradle
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-02-07 07:15:56 +05:30
dependabot[bot]
a390d5bf30 Bump constraintlayout from 2.1.2 to 2.1.3
Bumps [constraintlayout](https://github.com/androidx/constraintlayout) from 2.1.2 to 2.1.3.
- [Release notes](https://github.com/androidx/constraintlayout/releases)
- [Commits](https://github.com/androidx/constraintlayout/commits)

---
updated-dependencies:
- dependency-name: androidx.constraintlayout:constraintlayout
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-01-16 15:11:08 +05:30
gradle-update-robot
5cfd62de74 Update Gradle Wrapper from 7.3.2 to 7.3.3.
Signed-off-by: gradle-update-robot <gradle-update-robot@regolo.cc>
2021-12-26 12:17:34 +05:30
gradle-update-robot
956a620fa7 Update Gradle Wrapper from 7.3.1 to 7.3.2.
Signed-off-by: gradle-update-robot <gradle-update-robot@regolo.cc>
2021-12-18 12:19:44 +05:30
dependabot[bot]
5d8c2e1138 Bump constraintlayout from 2.1.1 to 2.1.2
Bumps [constraintlayout](https://github.com/androidx/constraintlayout) from 2.1.1 to 2.1.2.
- [Release notes](https://github.com/androidx/constraintlayout/releases)
- [Commits](https://github.com/androidx/constraintlayout/commits)

---
updated-dependencies:
- dependency-name: androidx.constraintlayout:constraintlayout
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-12-13 17:38:15 +05:30
gradle-update-robot
667b32296e Update Gradle Wrapper from 7.3 to 7.3.1.
Signed-off-by: gradle-update-robot <gradle-update-robot@regolo.cc>
2021-12-13 17:37:52 +05:30
dependabot[bot]
c2deb4b7b8 Bump gradle from 7.0.3 to 7.0.4
Bumps gradle from 7.0.3 to 7.0.4.

---
updated-dependencies:
- dependency-name: com.android.tools.build:gradle
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-12-13 17:37:31 +05:30
marcusz
99fe86eac0
Merge pull request #64 from termux/gradlew-update-7.3
Update Gradle Wrapper from 7.2 to 7.3
2021-11-14 16:03:11 +08:00
gradle-update-robot
8b56769017 Update Gradle Wrapper from 7.2 to 7.3.
Signed-off-by: gradle-update-robot <gradle-update-robot@regolo.cc>
2021-11-13 06:47:04 +00:00
dependabot[bot]
07f88ca44b Bump annotation from 1.2.0 to 1.3.0
Bumps annotation from 1.2.0 to 1.3.0.

---
updated-dependencies:
- dependency-name: androidx.annotation:annotation
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-11-05 12:07:06 +05:30
marcusz
03bbc4fdb1
Merge pull request #60 from SaicharanKandukuri/master
[Badge Fix] fix termux Discord server ID
2021-11-05 12:07:11 +08:00
Zman-1x1
dd59986a8c
fix termux server ID 2021-11-05 09:26:51 +05:30
marcusz
7f41b8e478
Merge pull request #51 from termux/dependabot/gradle/com.android.tools.build-gradle-7.0.3
Bump gradle from 7.0.2 to 7.0.3
2021-10-12 10:06:21 +08:00
dependabot[bot]
55f4220630
Bump gradle from 7.0.2 to 7.0.3
Bumps gradle from 7.0.2 to 7.0.3.

---
updated-dependencies:
- dependency-name: com.android.tools.build:gradle
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-10-12 00:28:33 +00:00
Twaik Yont
5a07a2fadb Should solve https://github.com/termux/termux-x11/issues/25. 2021-10-10 00:46:40 +03:00
Twaik Yont
f7f7c858fe
Update README.md 2021-10-08 17:37:50 +03:00
Twaik Yont
3589a91b3f Fix for https://github.com/termux/termux-x11/issues/43 2021-10-08 11:49:55 +03:00
WMCB-Tech
1cb26e4ee8 add discord readme badge pointing to Termux server 2021-10-08 09:02:12 +08:00
WMCB-Tech
1e12d82d1b use dpkg --print-architecture instead of uname -m (#43)
Termux 32-bit Installations on 64-bit OS can report architecture differently
use "dpkg --print-architecture" to report the correct current arch instead based on Termux repo architecture information
2021-10-05 16:25:32 +08:00
marcusz
bec4cdbbf4
fix typo found in README
posssible
2021-10-04 13:23:14 +08:00
Twaik Yont
f9a9ce3167
Let Termux:X11 run without sharedUserId="com.termux" (#31)
* Let Termux:X11 run without sharedUserId="com.termux"
Make Termux:X11 start user-defined commands in Termux ($PREFIX/libexec/termux-x11/termux-startx11)
Make debug_build.yml build companion package for termux and upload it as an artifact.
Update README.md
2021-10-03 13:33:10 +03:00
WMCB-Tech
db575f7887 Fix issues regarding enter key not working with external keyboards #34 2021-09-30 10:14:49 +08:00
dependabot[bot]
f1a0c3b4bb Bump constraintlayout from 2.1.0 to 2.1.1
Bumps [constraintlayout](https://github.com/androidx/constraintlayout) from 2.1.0 to 2.1.1.
- [Release notes](https://github.com/androidx/constraintlayout/releases)
- [Commits](https://github.com/androidx/constraintlayout/commits)

---
updated-dependencies:
- dependency-name: androidx.constraintlayout:constraintlayout
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-27 07:28:30 +05:30
dependabot[bot]
3decb822d1 Bump gradle from 7.0.1 to 7.0.2
Bumps gradle from 7.0.1 to 7.0.2.

---
updated-dependencies:
- dependency-name: com.android.tools.build:gradle
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-02 06:15:14 +05:30
marcusz
3754b3b5b5
Merge pull request #24 from termux/appname-change
change the application name back to Termux:X11 due to various reasons can't be named as Termux:Wayland
2021-08-29 19:32:22 +08:00
WMCB-Tech
d93c76092d revert app name to termux:x11 back 2021-08-29 19:08:56 +08:00
WMCB-Tech
9a54a6d9c9 Revert the app name from being Termux Wayland
Issue: https://github.com/termux/termux-x11/pull/18#issuecomment-907757298
2021-08-29 19:03:17 +08:00
WMCB-Tech
ab1c41a467 add img directory 2021-08-29 17:17:30 +08:00
WMCB-Tech
62ddbab369 README: image attachment should be in local repository tree 2021-08-29 17:16:25 +08:00
Yisus7u7
393f58f6e6 Add how to fix big fonts. 2021-08-29 06:52:12 +05:30
WMCB-Tech
64e9882a61 Update README 2021-08-28 17:50:13 +08:00
WMCB-Tech
38e9fe9c1c remove setup android sdk script 2021-08-27 19:04:46 +08:00
WMCB-Tech
d78d8778c9 wiki may be clarified once merging everything to main termux-x11 repo 2021-08-26 18:42:38 +05:30
Wisest_wizard
9e419571af Update preference messages and default values 2021-08-26 18:42:38 +05:30
Wisest_wizard
a7f4111b10 Remove fullscreen mode
Full Screen Mode is removed as it messes with visibility of Eks and also causes a few glitches
2021-08-26 18:42:38 +05:30