How would I go about writing code that uses android.hardware.automotive.vehicle#2.0 Library? - android-source

I'm trying to learn to write Hardware Abstraction Layer (HAL).
Here's the path I've taken so far, please correct me if I'm off in any step.
Downloaded AOSP and built it successfully (86%)
Located Vehicle Hal Support Library
Located android.hardware.automotive.vehicle C++ code.
Things I've attempted after that the steps below without succeeding to get those above classes recognized.
Import android.hardware.automotive.vehicle classes in Android Studio for a typical Android App that targets 29 Api Level.
Adding meta tag of android.car app
Copy/Pasting all source code under AOSP /packages/services/Car/
Partially contemplated adding android.hardware.automotive.vehicle#2.0.so Library and trying to access it through JNI (Not so sure about this one).
Please orient me, I see some repositories on github not doing anything special and somehow they're able to import the package in a java class like this.
import android.hardware.automotive.vehicle.V2_0.VehicleHwKeyInputAction;
import android.hardware.automotive.vehicle.V2_0.VehiclePropValue;
import android.hardware.automotive.vehicle.V2_0.VehicleProperty;
import android.hardware.automotive.vehicle.V2_0.VehiclePropertyAccess;
Here
how on earth do they get access to those classes?
Thanks

Vehicle HAL is not meant to be accessed directly from apps. Car Service does that for you.
You have couple options depending on what you're actually trying to accomplish:
Learn to write HAL services - it's like writing a driver for a given hardware (in this case, something that provides car data to Car Service).
Learn to write HAL clients - try modifying EmbeddedKitchenSink app first. Please note you need to build it with AOSP and not in AmdroidStudio since this is a system app (and regular apps doesn't have access to the HAL)
Learn Vehicle APIs - that's what you need car lib for. Details on how to use it: https://stackoverflow.com/a/63321234/14759774

Related

How do I actually install and use YouTube Android Player API?

I want to make a Flutter app that can play YouTube playlists using the YouTube Android Player API, found here: https://developers.google.com/youtube/android/player
The "Getting started" instructions say:
The following documents will help you to set up your development environment and use the YouTube Android Player API:
The download page provides a link to download the API client library
and JavaDocs.
The instructions for registering your application explain how to
register your app in the Google API Console and to obtain an Android
API key, which you will need to use the API.
The setup instructions explain how to set up an API project using
either Eclipse or IntelliJ.
The sample applications overview describes the sample applications
included in the API download.
The JavaDoc reference provides detailed definitions of the API's
interfaces, classes, methods, and enums.
I've followed every step in those points and links, but I still don't know how to use the provided package in my code! I now have a sample app running on my phone, and apparently using the package... which is cute... but it is in Java, which I don't speak, so it doesn't help me make my own app! Plain English instructions would have been more helpful...
I have tried:
import 'com.google.android.youtube.player'
and even:
import '<path>/YouTubeAndroidPlayerApi.jar'
but Dart Analysis tells me the URL doesn't exists. And when I try any of the classes that are supposed to be included in the package, I get that it's not defined.
I've tried right-clicking on the YouTubeAndroidPlayerApi.jar file and choosing "Add as library", but same result.
So what I normally do is to write something in my pubspec.yaml file, like:
dependencies:
provider: ^4.3.2+3
Then I would run pub get.
Then I would write import <package name> in my code, and now the classes will be ready to use.
What is the correspondence in this case? What am I supposed to do with this package so that I can use the classes in my code? I'm using Android Studio.
Most grateful for guidance!

One code base that supports Flutter for Web and Flutter iOS/Android?

Looks like Flutter for Web and Flutter for Mobile have to exist as separate projects due to the imports.
Example:
import 'package:flutter_web/material.dart
vs
import 'package:flutter/material.dart';
Is there anyway to build one flutter project with one code base that works for both web and mobile (ios/android)? If not, is this coming?
If so, can you provide an example app?
Would like to just make one code base for the web and mobile and not have to maintain separate projects/code repos.
The OP's question is a bit old and is no longer applicable at the time of posting(7/21/2020). Flutter now has consolidated web into the main flutter package, which prevents us from running into issues with imports like this. flutter_web is no longer a separate package.
However, you may have been able to accomplish this even at the time you posted your question with conditional imports. This answer provides an excellent method of doing this. The following are the essentials of that post:
The core idea is as follows.
Create an abstract class to define the methods you will need to use in general.
Create implementations specific to web and android dependencies which extends this abstract class.
Create a stub which exposes a method to return the instance of this abstract implementation. This is only to keep the dart analysis tool happy.
In the abstract class import this stub file along with the conditional imports specific for mobile and web. Then in its factory constructor return the instance of the specific implementation. This will be handled automatically by conditional import if written correctly.
This method allows for you to do these imports based on platform and applies to all packages that may not support every possible flutter platform(e.g. dart:html, dart:js, dart:js_util, dart:io).

What do you lose by ejecting a React app that was created using create-react-app?

I'm interested in using Hot Module Replacement with a newly created React app.
Facebook Incubator's create-react-app uses Webpack 2 which can be configured to support HMR, however in order to do so, one needs to "eject" the create-react-app project.
As the documentation points out, this is a "one way" operation and cannot be reversed.
If I'm to do this, I want to know what I might be giving up. I've been unable to locate any documentation that explains the potential drawbacks of ejecting.
The current configuration allows your project to get updates from create-react-app core team. Once you eject you no longer get this.
It's kind of like pulling in bootstrap css via CDN as opposed to downloading the source code and injecting it directly into your project.
If you want more control over your webpack, there are ways to configure/customize it without ejecting:
https://www.npmjs.com/package/custom-react-scripts

Unity3d protect code

We have a code in a unity3d game that we wish to protect from decompilation(will be published in ios,android,webgl and unity plugin). How should we protect it? Should we write that part of code as unmanaged plugin(c++)?
It's not possible to release software that can't be reverse-engineered.
This is POSIBLE. Some packages have standart unity packager format. So.. If you use dynamic assets or if you use CodeContainers you need to protect your code.
So what you shoud do:
If you use dynamic assets packages: Make dll's from code or make one controller class.
If you use CodeConainers (JS) make main C# controller. After this you can extends classes or simply call methods.
PS: If you want to secure not code assets, you need make binary encoding. And when you load level or prefab you just decode this asset and use.
You could use obfuscation techniques, which allows you to protect your package from reverse engineering, but just from those, who is not VERY (i am talking about high-level reverse engineers, who could decompile your code and deal with ASM or could decompile your iOS/Android project) interested, in any case for Unity, iOS
You can obfuscate the your source code using the Remiix Obfuscator plugin in unity asset store.
It's free and easy to use and support many platform of build on unity(android, ios).

Create an App within an App

I am being presented with a very interesting project. The task that I must complete is to figure out a way to allow a partner to be involved in an app without giving up their source code. The code will be included in the main bundle of the app so it is not dynamically stored. The partner has a fully functional app that is needed to be ran in a window within the main app at the appropriate time. I know having the partners create a web app would be ideal so it is treated like a webpage but I am more concerned with codes that must be written natively in iOS.
My question is what is the best way to go about solving this? In theory it is like an App within an App. Is there a way if they gave up their .app file I can include this in the bundle and then run it when I catch a certain event? Should I have the partners create their code in a framework and then import into the shell project? What is the best way to approach this problem?
If your 2nd-party doesn't want to provide you with the source code, why doesn't he compile it to object code then let you simply link it to your app?
By the way, at least on official (non-jailbroken) iDevices, apps can't 'embed' or 'open' one another in such a way - you can open an app programmatically if 1. it's a separate app 2. it has a registered special URL associated to its bundle.
Is there a way if they gave up their .app file I can include this in
the bundle and then run it when I catch a certain event?
No, you'll want to have them create a library instead. You can then include that library in your project.
Creating a library is as simple as:
Choose File->New...->Project... in Xcode.
Select the "Cocoa Touch Static Library" project template.
Add your code.
Build.
The result is a static library that you can add to your application(s). The library will contain the compiled code that you added, but doesn't include the source code. The library developer should provide whatever header files are necessary to use the code in the library.
An App within an App is possible however it requires a common data framework that allows one app to reference the same data without confusing the the source of and destination of the data.
Such a framework allows one app to interact with another app referencing the same data.