Pre-install some apps so they can be uninstalled without root by user - android-source

Can I (As an AOSP builder) pre install some apps so after burning on device, they can easily be uninstalled (like regular downloaded apps)?
I am already familiar with system apps and priv-apps but as they lie in system partition they can not be removed! (only disabled in settings menu)
P.S. I know huawei for example uses /system/delapp to install such apps. But I seek for a general way or for AMLogic platform specifically which I am working on!

You can do that by configuring your build to produce a userdata.img file with your app(s) included, which you can then flash with fastboot flash userdata.
The Android.mk file for these apps that go in userdata.img roughly looks like the following:
include $(CLEAR_VARS)
LOCAL_MODULE := myapp1
LOCAL_SRC_FILES := $(LOCAL_MODULE).apk
LOCAL_MODULE_CLASS := APPS
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA)/app
LOCAL_CERTIFICATE := PRESIGNED
include $(BUILD_PREBUILT)
And add the apps to product packages in device.mk:
PRODUCT_PACKAGES += myapp1 myapp2 ...
You should be able to find plenty of examples on GitHub, e.g., https://github.com/search?l=Makefile&q=TARGET_OUT_DATA+BUILD_PREBUILT&type=Code
Since you are building the image from scratch, you can put your apps in a custom directory under and package a script to install them on boot time if they are not already installed. You can invoke that script by editing the init.rc file as follows:
on property:dev.bootcomplete=1
exec - system system -- /system/bin/sh /path/to/installer/script.sh
The installer script can be as simple as:
for apkfile in /path/to/custom/apps/*.apk; do
/system/bin/pm install "$apkfile"
done

Related

Where does `pub get` download pubspec dependencies to?

In javascript, we have NPM and the node_modules folder in every project. I was not able to find a similar concept for Dart/ Flutter, except the build folder in my app, which contains a folder of a few dependencies I have in pubspec.yaml. It doesn't have any of the source code though, and I think it's actually built from something else. I've also looked in /usr/local/flutter/packages which is where my flutter is installed, but it only shows flutter_driver, flutter_goldens, and more seemingly unrelated folders.
I guess if wanted to read the source code, I really need to find the repo and read from that, or is there a location for dependencies I haven't looked?
I even found projectDir/.dart_tool/pub, which didn't have any of my packages.
From the documentation:
Dependencies downloaded over the internet, such as those from Git and
the pub.dev site, are stored in a system-wide cache. This means that
if multiple packages use the same version of the same dependency, it
only needs to be downloaded and stored locally once.
By default, the system package cache is located in the .pub-cache
subdirectory of your home directory (on Mac and Linux), or in
%APPDATA%\Pub\Cache (on Windows; the location might vary depending on
the Windows version). You can configure the location of the cache by
setting the PUB_CACHE environment variable before running pub.
So for Mac and Linux for example, this would be ~/.pub-cache/hosted/pub.dartlang.org by default.
In Android Studio
I could directly view the source code of the package under `
[External Libraries/Dart Packages/Your Packages]
`
You can get pubspec downloaded from your flutter sdk location .
/flutter/.pub-cache/hosted/pub.dartlang.org/
You can also clone package git .
If you are running Windows as your OS, you can find the packages under the folder that you installed your Flutter SDK to when setting up Android Studio.
In my case - using Windows 10 - the path is as follows, where C:\ is my primary harddrive and flutter\ the folder containing the Flutter SDK...
C:\flutter\.pub-cache\hosted\pub.dartlang.org\english_words-4.0.0
The above path for instance points to the "english words package", containing the most ~5000 used English words and some utility functions, which are mentioned and used in the Flutter tutorial on their official page for writing and running your first Flutter app.
https://pub.dev/packages/english_words
If you have installed flutter using snap then the location might be
/home/user/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org
I had forgotten that I've been command + clicking into these libraries all the time in VSCode.
However, it looks like packages are not stored in the app folder. Packages that we use in our projects are downloaded to $FLUTTER_PATH/.pub-cache, so if I'm looking for camera picker plugin, its in
/usr/local/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker-0.6.5+2/lib/image_picker.dart
If you are using VScode you can find these dependencies under the dependencies window:

How to embed third party framework on ionic capacitor custom plugin?

I am developing an Ionic Capacitor plugin which imports 2 iOs .framework files and a .bundle that refers to one of this .framework files. The thing is that no matter how I link/embed and point/copy this files on the plugin project, xcode claims, on the app project, that it cant find the module in the swift file.
I already tried to add the files to the project, used the "Embedded binaries" option, linked libraries, allow non-modular includes (on build options menu), add the files to the headers (on build phases), and so on....
The line that xcode point the error is:
import OneFramework
And xcode claims:
No such module 'OneFramework'
I was expecting that when I add the plugin to my app project via npm, and later running a "$ rm -rf ios && ionic capacitor run ios" to run the app, xcode find all the modules of the plugin that I am trying to do.
I found the solution. To achieve this the first thing to know is that when you do npx #capacitor/cli plugin:generate what the CLI do for you is the generation of a cocoa pod. The root of this pod is the generated folder itself.
With that in mind, the next thing to do is to learn how to make pods, but i'll sumarize the principal aspects that led me to the success.
-First of all you open the *.xcworkspace. Followed by that, click on the "Add Files to Pod..." option and add your files. Please ensure that the "Copy files if needed" option is marked. Please refer to the picture below.
-Now its nice to create a folder for your .framework and another for the .bundle (if there are any) files. Do this by right clicking the Pods project and select the option "New group". Select a name like that is different from the pattern of xcode, it is nice to know that this folders are created by you.
-If you done this right, the frameworks you recently added to the project will appear on the pods project like this:
-Now, for your swift implementation find your files, drag your .frameworks that are on the pods project for the "Frameworks, Libraries and Embedded content" of the plugin project. The result will be something like this:
-Ok, files included and linked. Now we should let our cocoa pod know about this and declare this files. The file "YourAwesomePlugin.podspec" (located at the root of the plugin project) is the main entrance of the pod. In this file you will declare which files (.frameworks, .bundle, etc) belong to your pod and consequently will belong to your plugin when you npm install it. To declare this you'll need three directives:
s.vendored_frameworks = 'ios/Pods/YourFrameworkFolder/**'
s.resource = 'ios/Pods/YourResourceFolder/YourBundle.bundle'
s.xcconfig = {'ENABLE_BITCODE' => 'NO'} #This is mandatory on my case, but you need to evaluate if this options applies to your plugin.
-Now we hit play on the plugin project. To test on your app if the plugin is ok, you need to add the path of the root of the plugin project on the podfile of the pods project of the APP project. Like this:
-To install it you can go on Yourproject/ios/App and run pod install.
Please note that:
To declare the existence of your recently created plugin you you need to do some declarations as well, but this part is easy and already documented on capacitor/plugin docs.
The installation method via pod install that I suggested is for testing. It would be nice if you pack your plugin using npm and npm install it like all other plugins.
I dont have much knowledge on cocoapods like I wish, but this works and I think that is a clean solution. If not, please let me know.
If this answer is useful for you, please thumbs it up, it is a week of research and trying that I am sharing, along the time to write it all down.

How to install android build support for unity manually (unity hub)?

I used Unity Hub downloaded latest Unity Editor, it works fine for editor,document and language packs, but can not download android build support. Just told me download failed many many times in the past two days.
So I downloaded UnitySetup-Android-Support-for-Editor-2018.2.16f1.pkg from webpage. This package install reported failed at the end of every try.This package size(348.9M) is not same as the one showed(365.8M) in UnityHub download list.
There is a 2017 version Unity Editor installed by download **.pkg, but the support installer never ask me about Editor's location.
Is there some way to install android build support manually?
Thanks for any tips.
This worked for me. To anyone facing this problem. I apologize for my long explanation and my english.
You can verify if *.pkg file is complete by comparing the checksum (I use dolphin)
Execute this command to manually install your UnitySetup-Android-Support-for-Editor-*.pkg
:~> ./UnitySetup-2019.1.0f2 -u --use-component-list
unity-2019.1.0f2-linux.ini --install-location $HOME/2019.1.6f1/ -d
$HOME
Note that the unity version must be compatible, otherwise you will have the error unable to initialize the Unity engine in you android device. I use:
UnitySetup-Android-Support-for-Editor-2019.1.6f1
Unity-2019.1.6f1
As much as possible use unity hub to install the android add-on, I use unity hub 2.0.1
Step by step explanation of the installation manually of *.pkg
The problem :(
I will put them in context.
I use opensuse tumbleweed. My problem was that I did not have android build support.
No Android module loaded image, and when I press open download page, the browser shows me a message:
<Error> <Code>AccessDenied</Code> <Message>Access denied.</Message> <Details> Anonymous caller does not have storage.objects.get access to publishing-unity-binaries-prd/6e9a27477296/Unknown/UnitySetup-Android-Support-for-Editor-2018.3.0f2. </Details> </Error>
and I can not do anything else.
The SOLUTION :)
0.- Previous requirements
I already had my previous installation this file:
UnitySetup-2019.1.0f2
1.- Download UnitySetup-Android-Support-for-Editor-2019.1.x.pkg
To achieve this look for UnitySetup-Android-Support-for-Editor- in the file https://public-cdn.cloud.unity3d.com/hub/prod/releases-linux.json
This is a fragment of release-linux.json file
...
{
"id": "android",
"name": "Android Build Support",
"description": "Allows building your Unity projects for the Android platform",
"downloadUrl": "h ttps://download.unity3d.com/download_unity/f2970305fe1c/MacEditorTargetInstaller/UnitySetup-Android-Support-for-Editor-2019.1.6f1.pkg",
"category": "Platforms",
"installedSize": 1958542000,
"downloadSize": 664332318,
"visible": true,
"selected": false,
"destination": "{UNITY_PATH}/Editor/Data/PlaybackEngines/AndroidPlayer",
"checksum": "d00addecefb7babcb9cd6a8085672908"
}
...
What interests us about this file is the url to download https://download.unity3d.com/download_unity/f2970305fe1c/MacEditorTargetInstaller/UnitySetup-Android-Support-for-Editor-2019.1.6f1.pkg and the checksum.
2.- Component list file
Download the file from the list of components from here or create a file like unity-2019.1.0f2-linux.ini:
[Android]
title=Android Build Support
description=Allows building your Unity projects for the Android platform
url=MacEditorTargetInstaller/UnitySetup-Android-Support-for-Editor-2019.1.6f1.pkg
md5=d00addecefb7babcb9cd6a8085672908
install=true
mandatory=false
size=365578263
installedsize=1259081000
requires_unity=false
for [Android] install=true, the url and md5 which is the checksum from the previous step (or again I get md5 with dolphin to verify)
3.- Installation
Have the following files in the same directory that in my case are in $HOME
UnitySetup-2019.1.0f2
UnitySetup-Android-Support-for-Editor-2019.1.6f1.pkg
unity-2019.1.0f2-linux.ini
Finally, execute the following command line. (Note that my current unity installation is in $HOME/2019.1.6f1/).
:~> ./UnitySetup-2019.1.0f2 -u --use-component-list unity-2019.1.0f2-linux.ini --install-location $HOME/Unity-2019.1.6f1/ -d $HOME
Thanks
Source
https://forum.unity.com/threads/installing-android-build-support-and-other-build-support-post-installation.515436/
https://forum.unity.com/threads/how-to-install-editor-packages.554977/
Download the Android Sdk Manager under Command line tools only.
And download the SDK you need, then link it to Unity.
I usually download AndroidStudio and it comes with a GUI manager.
Here is some more info about how to update sdk tools.
You link it here: Edit/Preferences/External Tools
According to this:
Possible causes could be:
A corrupt package (download again manually from the list of individual
packages)
Filesystem corruption (repair disk from single-user mode, reboot and
try again)
The user account somehow not being in the sudoers group (deeper
technical problem - check Apple's forums)
Package file stored on a drive formatted weirdly, so execute
permissions aren't set correctly (pre-/post-installation script won't
run; move to boot drive)
Add Unity modules on Linux manually:
Download pkg:
Head to this page, select your specific unity version from the dropdown at the right.
For those modules that arent listed in linux section, download the pkg from the mac section.
Extract the pkg. you can use any of these:
Files
Archive Manager
7z x -o* UnitySetup-XXXXXX-Support-for-Editor-2022.1.16f1.pkg
bsdtar -xf UnitySetup-XXXXXX-Support-for-Editor-2022.1.16f1.pkg TargetSupport.pkg.tmp/Payload
Move the extracted "Payload" file to one of these directories:
For Android Build Support:
{UNITY_PATH}/Editor/Data/PlaybackEngines/AndroidPlayer
For Windows Build Support (Mono) & Widows Dedicated Server Build Support:
{UNITY_PATH}/Editor/Data/PlaybackEngines/WindowsStandaloneSupport
For Mac Build Support (Mono) & Mac Dedicated Server Build Support:
{UNITY_PATH}/Editor/Data/PlaybackEngines/MacStandaloneSupport
4. Now decompress and extract Payload:
zcat Payload | cpio -iu && rm Payload
or if it's named Payload~ just extract it:
cpio -iu < Payload~ && rm Payload~

Help using iOSPorts to connect to an LDAP server

I am building an iPhone application which connects to an LDAP server (no encryption). I am trying to use iOSPorts but I am having trouble following the documentation, I think it was written for Xcode 3, while I've only ever used Xcode 4.
All that is required is to do simple search queries of the server and returning the results.
Some of the trouble I am having:
For example in step 3 my iOSPorts/include folder is empty and only contains the .gitignore file.
For step 4 which files do I need to add just the ports folder containing database, devel, iOSPorts and security?
For step 6 the direct dependencies panel, is this the target dependencies of build phases , which libraries need to be selected?
I think step 7 is for Xcode 3 too,
Any help with this would be much appreciated!
I am building an iPhone application which connects to an LDAP server (no encryption). I am trying to use iOSPorts but I am having trouble following the documentation, I think it was written for Xcode 3, while I've only ever used Xcode 4.
The original instructions were created for Xcode 3 since Xcode 4 was still in early beta when I published the first release of iOS Ports. The instructions have been updated within the last month for use with Xcode 4. I try to use the name used by "Xcode 4 User Guide" when describing the steps, so I recommend reading the first few chapters of this document from Apple.
For example in step 3 my iOSPorts/include folder is empty and only contains the .gitignore file.
Initially the include directory will be empty. The individual ports will copy the header files to the include directory. This is to prevent the end developer from needing to add a path to OpenSSL, Cyrus SASL, and OpenLDAP in order to compile an app for OpenLDAP.
Any help with this would be much appreciated!
So here is a quick run down of how iOS Ports works.
Each port of an Open Source package has an Xcode project file. That Xcode project file lists other Xcode project files and Makefiles as dependencies. Here is the high level steps used by an iOS Ports Xcode project file to compile the port:
Execute the port's MakeFile
Makefile: Download the source archive from the Internet (fails if Internet is unavailable)
Makefile: Verifies the integrity of the source archive using md5sum.
Makefile: Unpacks the source archive.
Makefile: Applies any required patches to the source code.
Makefile: Copies headers to the iOS Ports include directory.
Build any libraries from other ports listed in the build settings' Target Dependencies (for instance, libldap.a in OpenLDAP requires libsasl2.a from Cyrus SASL).
Compiles requested library.
The README has more information on how to add the project files to your project and link against the libraries. There also a few example programs in the examples directory.
If you do continue to have problems, please let me know. I try my best to keep on top of requests for help regarding iOS Ports and my other projects.
I haven't gone through all the process, but I am pretty sure for step 3, you have to 'make' the project first. There is a Makefile in the top folder of the project.

How to setup a DotNetNuke Development Environment with Source Control?

My team is developing a new DotNetNuke web application and would like to know what is recommended to setup a development environment with source control and automated builds? We would like to keep the DNN source code separate from our custom modules and extensions source code.
The DotNetNuke Compiled Module template for Visual Studio wants us to store the source code in the DesktopModules directory of the DNN source code and output to the DNN source code bin directory. Is this the recommended structure? I would rather keep the files in different locations, but then it becomes more difficult to run and debug locally as it would require an install of the module for each change. Also, how should an automated build deploy any changes?
How have others set this up? Is there a recommended best practice?
For my source control, I develop modules in their own project. This contains the module code, test code, data provider code (if applicable) and anything else. This is checked into source control like any other project. Note that the module project contains no links to a specific DNN website, and DNN references are made in the project to a common "bin" directory that references your target build. For example, in my projects folder, I have \bin460 , \bin480, \bin510, \bin520 etc. Each of these folders holds a set of binaries for a specific DNN version. That way you can build against a particular version but test against any version you like.
The problem with source-controlling a module in place in a dnn install is
- sometimes not all of the module code is easily isolated under a single parent directory
- doesn't lend well to a PA module approach
- not easy to shift the project to a different DNN Version for development or testing
- easy to inadvertently source control parts of the DNN solution, particularly with integrated VS source control solutions.
This approach compiles quickly because you're not trying to compile the entire project. For test deployment I have a build script that copies the various parts of the module into a target website. This can be done via the compile (link the build script) or just run after you've had a successful compile in a cmd window. My build script has a 'target' environment switch, so that I can say 'dnn520' to deploy the build to my test dnn520 install. Note that you need to manually create the module configuration first before this will work, but this is a one-time effort, and you can use the export feature to create your .dnn module manifest.
To build your module package, invest the time in a comprehensive script which will take the various parts from your source directory, and zip them into an install package. Keep all of the parts in your source control folder, and copy them into a temp directory, then run a command-line zip utility (I use an ancient version of pkzip) to pack it into an installable file.
The benefits of this approach is :
- separation of module code from installed code
- simple way of keeping only the module code in source control (don't have to exclude all the website code)
- ability to quickly test out modules in different dnn versions
- packaging script allows you to quickly and easily build a new version of a module for install testing/deployment
The drawbacks are
- can't use the magic green 'go' button in VS (have to manually attach debugger)
- more setup time than developing in-place
We typically stick to keeping the module code in a folder under DesktopModules and building to the website's bin directory.
In source control, we just map the individual modules, rather than the entire website. Depending on what we're working on, a module may be an entire project in source control, or we may have multiple related modules in the same project, living next to each other.
Automatically deploying changes is somewhat difficult in DNN. It's highly recommended to have a build script that packages your module into an installable form. You can then copy installable packages into the website's Install/Module folder, and get the URL /Install/Install.aspx?mode=InstallResources, which will install any packages in that folder.
In response to bduke's answer. You should, and don't want to build projects in the DesktopModules folder.
That's where all of the source code for the site out of the box goes.
That's where you modules will be "installed" and thus if someone "updates" or re-installs one, then it will be overwritten
It can make upgrading your Application far more difficult. Many developers don't understand that the idea of not touching the original source code files to modify their behavior. BECAUSE it will just be overwritten when you perform an upgrade.
If you want to build modules, create a solution folder called Modules and place your seperate project modules there.
If you want to debug them, make the target debug output point to the web\bin folder.
If you want to install/deploy them. Build it in release mode and install them through the Module/Extension filter.