这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@Grimler91
Copy link
Member

This removes all hardcoded /data/data/com.termux/files paths.

@Grimler91
Copy link
Member Author

@agnostic-apollo could you briefly list what other improvements that should/could be done with termux-shared? I suppose all logging should be moved over to termux-shared's logger functions for example

@agnostic-apollo
Copy link
Member

agnostic-apollo commented Nov 28, 2021

Ah, so you finally got around to this ;)

  1. Replace both com.termux.sharedfiles.READ with ${TERMUX_PACKAGE_NAME}.sharedfiles.READ in AndroidManifest.xml. Make sure to validate correct expansion in built apk, you can drag and drop apk into android studio to check.
  2. Remove all com.termux.api prefixes and use dot notation in AndroidManifest.xml.
  3. I have implemented consistent base theming in termux-app locally, which is/will be used by all components Activity/Dialogs and plugins, which will automatically change on dark mode changes. The use-black-ui bool property has been deprecated and automatically replaced with night-mode string property to be consistent with android conventions. So DialogActivity would either need to use the base theme or use new property for which a helper function is provided. Dialogs itself may be replaced too, since implemented too.
  4. Just like termux-widget and other plugins, termux-api needs to add a launcher activity to be exempted from OEM killers and also to reduce bug reports of users not having uninstalled all termux apps and trying to change install sources. Check Sometimes the widget stops to work termux-widget#56. The ".activities.TermuxWidgetActivity" theme has changed too locally and also requires toolbar and night mode calls. I guess I can this one myself when I push termux-app changes.
  5. You need to use Logger throughout. The TermuxApiReceiver.onReceive() must have following.
TermuxApiApplication.setLogLevel(context, false);
Logger.logDebug(LOG_TAG, "Intent Received:\n" + IntentUtils.getIntentString(intent));
  1. Each class must have its own LOG_TAG. Classes that have services or receivers instead of direct function runs like StorageActivity must have log entries when command is received/started or onActivityResult with logVerbose. This is important since android or more specifically OEM restrictions may not start them, and we should know if that happens. If we see TermuxApiReceiver log statement but not the command received one, we would know something unexpected happened and can investigate further.
  2. The TermuxApiApplication class must be defined in com.termux.api package and added to AndroidManifest.xml.
<application
        android:name=".TermuxApiApplication"
package com.termux.api;

import android.app.Application;
import android.content.Context;

import com.termux.shared.logger.Logger;
import com.termux.shared.termux.TermuxConstants;
import com.termux.shared.termux.crash.TermuxCrashUtils;
import com.termux.shared.termux.settings.preferences.TermuxApiAppSharedPreferences;


public class TermuxApiApplication extends Application {

    public void onCreate() {
        super.onCreate();

        // Set crash handler for the app
        TermuxCrashUtils.setCrashHandler(this);

        // Set log config for the app
        setLogConfig(getApplicationContext(), true);

        Logger.logDebug("Starting Application");
    }

    public static void setLogConfig(Context context, boolean commitToFile) {
        Logger.setDefaultLogTag(TermuxConstants.TERMUX_API_APP_NAME);

        // Load the log level from shared preferences and set it to the {@link Logger.CURRENT_LOG_LEVEL}
        TermuxApiAppSharedPreferences preferences = TermuxApiAppSharedPreferences.build(context);
        if (preferences == null) return;
        preferences.setLogLevel(null, preferences.getLogLevel(true), commitToFile);
    }

}
  1. Remove termux-emulator JNI libs.
  2. Need to move to semantic versioning. Check termux/termux-widget@af8b7c139. I forgot to add sha256sum when uploading APKs, so workflow needs to be updated, will try doing it soon.
  3. Update .gitignore.
  4. Add LICENSE.md. We should also explicitly include all used license files under licenses directory for all plugins. Also important if all maintainers get "hit by a bus" and nobody left to update urls. ;) https://www.gnu.org/licenses/gpl-faq.en.html#WhyMustIInclude
  5. Enable minifyEnabled
  6. The termux-shared import comments must exist for easier local development, check app/build.gradle and build.gradle. https://github.com/termux/termux-app/wiki/Termux-Libraries#forking-and-local-development
  7. Use -all version of gradle instead of -bin.
  8. Note that termux-shared library has been hugely refactored now locally, and all termux specific stuff moved to com.termux.shared.termux, so import statements and some other stuff will break when version is bumped. Also applies to other plugins that have been moved to termux-shared. Although, now only termux-boot will remain, which will get deprecated if/when systemd is implemented, so no point in working too much on it.

This should hopefully be enough for now, I'll let you know if I think of other stuff. Good luck. Do let me know if any further help or clarification is required.

Grimler91 and others added 11 commits December 23, 2021 06:50
This allows us to remove all hardcoded /data/data/com.termux paths,
and makes future maintenance easier.
As part of adaption for the termux-shared library.
But still keep shrinkResources and obfuscation disabled for testing
reproducible builds and maintaining stacktraces of crashes.
To have them easily accessible in only one place.
The versionName will now follow semantic version "2.0.0" spec in the
format major.minor.patch(-prerelease)(+buildmetadata).  This will make
versioning the prerelease and github debug builds versions easier and
follow as spec.  The @termux devs should make sure that when bumping
versionName in build.gradle file and when creating a tag for new
releases on github that they include the patch number as well, like
v0.1.0 instead of just v0.1.  The build.gradle file and
attach_debug_apks_to_release workflow will now validate the version as
well and the build/attachment will fail if versionName does not follow
the spec.  https://semver.org/spec/v2.0.0.html

APKs released on github for debug build workflows and releases are now
referred as Github releases as per termux/termux-app@7b10a35f and
termux/termux-app@94e01d68, so APK filenames have been modified to
include github in the filename.  The APKs are still debuggable, so
that tag remains too.

For github workflows the apk filename format will be
termux-api_<current_version>+<last_commit_hash>-github-debug_<arch>.apk,
like termux-api_v0.1.0+xxxxxxxx-github-debug_arm64-v8a.apk and for
github releases it will be
termux-api_<release_version>-github-debug_<arch>.apk, like
termux-api_v0.1-github-debug_arm64-v8a.apk.  The last_commit_hash will
be the first 8 characters of the commit hash.  The
<last_commit_hash>-github-debug will act as buildmetadata and will not
affect versioning precedence.

For github workflows triggered by push and pull_request triggers,
<current_version>+<last_commit_hash> will be used as new versionName,
like v0.1.0+xxxxxxxx.  This will make tracking which build a user is
using easier and help in resolving issues as well.

The app/build.gradle now also supports following TERMUX_API_ scoped
environmental variables and RELEASE_TAG variable will not be used
anymore since it may conflict with possibly other variables used by
users.

- TERMUX_API_APP_VERSION_NAME will be used as versionName if its set.
- TERMUX_API_APK_VERSION_TAG will be used as termux-api_<TERMUX_API_APK_VERSION_TAG>.apk if its set.
androidx.biometric:biometric:1.2.0-alpha04 is available as well, but
it requires compileSdkVersion 31, which we cannot use.
@Grimler91
Copy link
Member Author

Merging this now to make testing of the other PRs easier, will come back and look at the rest of the points later

@Grimler91 Grimler91 merged commit 5ca50e0 into master Dec 23, 2021
@Grimler91 Grimler91 deleted the use-termux-shared branch December 23, 2021 05:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants