I am building an operating system for children; the app is a launcher. From this app, children are allowed to use 3rd party apps, except requirements are that the ads should be blocked because some ads are inappropriate for our 3-5 year old targeted audience. Without actually owning these 3rd party apps, I have not thought of too many options for accomplishing this. The only thing I could think of is to turn off network connection while using these apps. Without a network connection, these 3rd party apps will not be able to display their ads. However, I see a huge drawback to this solution. Many (dare I say most) apps are meant to work with an active network connection, and without one these apps do not function.
Can you think of a better way of doing this? Is there a library that exists that I do not know of, or method for doing this that you can enlighten me on?
Thank you in advance.
I have found possible solution to this for other developers building operating systems for children. Adblockplusandroid is pretty useful, there is no root required.
https://github.com/adblockplus/adblockplusandroid
Additionally, there are some ways of changing/setting Proxy using Wificonfiguration like
WifiConfiguration config = new WifiConfiguration(configuration);
config.ipAssignment = WifiConfiguration.IpAssignment.UNASSIGNED;
config.proxySettings = WifiConfiguration.ProxySettings.STATIC;
config.linkProperties.clear();
config.linkProperties.setHttpProxy(new ProxyProperties("127.0.0.1", port, ""));
127.0.0.1 targets ads.
Related
I am making a faucet like app, so the app completely relies on ads, is there a way to detect if a user is using an Ad-Blocker? I thought of trying to ping google ads server to see if it can ping the server or not, Will that work? If not what method do you suggest? Thanks!
Quoting Ivan's answer from here
I am aware of one way that ad blocking works (on any computer really), they edit the hosts file to point to localhost for all known ad servers. For android this is located in the "etc/hosts" file.
For example, I use admob ads and a host file that I have taken from custom rom lists the folowing admob entries:
127.0.0.1 analytics.admob.com
127.0.0.1 mmv.admob.com
127.0.0.1 mm.admob.com
127.0.0.1 admob.com
127.0.0.1 a.admob.com
127.0.0.1 jp.admob.com
127.0.0.1 c.admob.com
127.0.0.1 p.admob.com
127.0.0.1 mm1.vip.sc1.admob.com
127.0.0.1 media.admob.com
127.0.0.1 e.admob.com
Now anytime a process tries to resolve the above addresses they are routed to the address listed to the left of them (localhost) in this case.
What I do in my apps is check this host file and look for any admob entries, if I find any I notify the user that I've detected ad blocking and tell them to remove admob entries from there and do't allow them use of the app.
After all what good does it do me if they're not seeing ads? No point in letting them use the app for free.
Here is a code snippet of how I achieve that:
BufferedReader in = null;
try
{
in = new BufferedReader(new InputStreamReader(
new FileInputStream("/etc/hosts")));
String line;
while ((line = in.readLine()) != null)
{
if (line.contains("admob"))
{
result = false;
break;
}
}
}
I vow that all ad supported apps should check this file. You do not need to be root in order to access it, but writing to it might be a different story.
Also, not sure if there is any other files that act the same on a linux based OS, but at any rate we can always check all of those files.
Any suggestions on improving this are welcome.
Also the app called "Ad Free android" needs root access, meaning that it most likely changes the hosts file in order to achieve its goal.
Preventing Adblockers is not an ideal solution. You will end up losing players, losing visibility on the store (fewer players = less visibility). Plus, no solution will prevent all adblocker, not even close. It could even create frustration and bad rating from these people. So you will end up losing more than anything.
Another solution is to create an advertisement (fake advertisement) yourself advertising your other apps (or partner with another developer to share your own ads). So if you detect that you have no ads to display (regardless of the reason), you can display your personal "fake ad". So if the player used an adblocker or simply put his phone in airplane mode to prevent ads to appear, you will still show an advertisement to them.
That way, there is no gain from the player trying to remove the ads and there is a gain on your side by promoting your other apps.
We need to build a server that can communicate with some embedded devices running a variant of Android. We need to be able to send commands to the device, and receive a response. A simple command might be asking the device for it's status. We won't have HTTP, so we need to have the client/device establish a connection with the server.
We were considering using MQTT as it has a lot of nice properties (QoS, lightweight, built for IoT), but it doesn't natively support a request response workflow.
We have considered building RPC on top of MQTT, but before we do I just wanted peoples thoughts on the matter. Would Websockets, WAMP, ZeroMQ be a better approach?
Edit:
Q1: Do we even need RPC?
Q2: Is there an approach to building systems where I always send async type messages and still provide a good user experience?
Q3: Any examples?
Looking for implementation examples and hands on experience of building an IoT communication system beyond a toy example with a single device.
"one-size-fits-all" may sound as a "smart" slogan for T-shirts but causes nightmare for ex-post attempts to fix poorly designed architectures once real-world implementations scale
"right-sizing" and "Minimum-Viable-Product" strategies for just-enough designs have much better chance to survive IoT scales and to keep costs-of-adaptation acceptable ( take just the scales of the recent VW global device firmware update, expected to have about -2.5% to -3.0% GDP adverse impacts on Germany and automotive supply chains in Hungary and former Czechoslovakia regions - Yes, costs matter in IoT domain more than just the trivial count$.)
A smart-fit tool for IoT domain-specific architecture is a must
A first thing that ought to be born in mind is the fact, that IoT domain is by several orders of magnitude different from scales of the classical legacy computing architectures. Minimised local-resources ( by design, also mentioned above ), massive scales/counts with uncontrolled concurrency, immense synchronisation complications for true parallelism ( if such system design is needed ), ref.: a PARALLEL v/s CONCURRENT SEQUENTIAL Disambiguation Link.
Thus a proper selection of tools is needed in context with this given state.
While AMQP and other power-MQ tools are great for broker-based ( if well designed, the central MQ-broker need not be a single-point of failure & remains "just" a performance bottleneck ) the overheads for architectures with IoT-devices are to be carefully validated, whether feasible.
Broker-less ZeroCopy, ZeroSharing, ZeroBlocking, ZeroLatency(...almost)
While AMQP has opened doors for the broker-less powers of well known ZeroMQ, the same happened another step further when Martin Sustrik redefined the rules and came with nanomsg.
nanomsg, besides its portability and light-weight-ness or a just enough right-weight-ness sets itself a good candidate ready for IoT models of co-operation, giving your project much more than the asked REQ/REP where needed -- more advanced behaviours, alike SURVEY one asks, all vote
BUSdecentralised routing
or PIPE a directed, one-way pipe are particularly attractive in distributed process compositions in massive sensoric networks and a lovely example.
Answers for added questions:
A1: Yes, if design architecture requires, RPC might be using the same uniform signalling framework ( not reinventing wheel or adding just-another-distributed layer just for Remote Proceducer Call
A2: Yes, ZeroMQ and similar broker-less almost Zero-Latency nanomsg framework from Martin Sustrik are a good fit for inter-process messaging/signalling services. Your top-level design decides, whether these powers get harnessed anywhere near to their (awfully magnific) full potential or wasted into underperforming usage-patterns. To have an idea of their limits, FOREX event-streams execute spurious blasts of event with less than microsecond resolution time-stamping.
There you really need a framework, that is robust ( to handle such blasts ), fast ( not to add unnecessary delays ), elastically linear-scaleable ( with inner abilities to handle load-balancing on demand in many-folds ). After hands-on experience I can confirm that my own team's creativity is the very limiting factor for user-experience, not the ZeroMQ / nanomsg smart-frameworks.
A3: Yes, for a few years already using ZeroMQ ( DLL/LIB-adaptations are currently in progress for a nanomsg port ) for remote (load-balanced) central logging ( soft-realtime minimum latency-motivated, off-loading of distributed agents' capabilities ). Unless your system span grows into space ( where round-trip latencies are easily in minutes-hours ) this modus operandi is both smart & close to "just-enough"-design ideals.
Based on your requirement of a light weight request/response protocol for IoT, CoAP (http://coap.technology/), an IETF standard, might be useful. It's light weight, and you can build RESTful services on top of it.
The other thing worth to consider is the "data model" and "service interfaces" for your server. Choosing a standard-based communication protocol, such as HTTP, MQTT, CoAP, is important, but it might be equally important to choose standard-based interoperable sensor data model and interfaces, so that your application can be interoperable and don't need to worry it becomes obsolete soon. Open Geospatial Consortium (OGC) SensorThings API (http://ogc-iot.github.io/ogc-iot-api/) might be an option to consider. It is an open standard, and it's data model is based on ISO 19156 Observation and Measurement.
I could suggest to use AMQP if one of your requirements is request/response pattern.
The AMQP protocol supports this pattern natively with a "correlation" mechanism between the request end the response.
In your environment you could try to use the Apache Qpid Proton in C of eventually all the available language bindings like Java (for you Android based system).
For those already using MQTT communications and want to have request/response over their service you can try replyer (https://github.com/netbeast/replyer), which is a strategy over MQTT packet structure and protocol, rather than a new one.
I'd advice not to create your own protocol, but use LoraWAN protocol, which already contains those join/accept (the same as request/response) protocols.
Here's spec of LoraWAN protocol - page 47 describes join/accept.
Basically, rpc and message passing are functionally equivalent as I believe was formally proved by Prof Needham in Cambridge back in the 70's. As you say, MQTT has some nice transport properties designed to help with small footprint, intermittently connected devices.
The point about RPC is that is enables a synchronous, single thread style of programming. However, if you are using Android, it's kind of unlikely that you will really be prepared for a UI to synchronously wait for an RPC to complete. Therefore, my personal opinion is that I find it easier to use a straight messaging system, such as MQTT, and track the state of the transaction however you want, (state machine, state variable, whatever).
As far as non-toy examples of MQTT based UI, you could checkout our platform http://www.thingstud.io. With MQTT multiple devices are a non-issue, as the UI is not even aware if it is talking to one device or many.
Mike
Can't speak to the other protocols but MQTT does have some features that you may want to look into:
If you are just trying to figure out whether a device is connected or not, you can use a feature called 'last will' to send a pre-determined message on timeout or disconnect. Using that and Quality-of-service levels you should be able to keep track of the device state enough to know whether your messages are being received or not, and then monitor the publishing channels from the devices to process the responses.
If you need just request/response protocol you can go for CoAP (http://coap.technology/), it is like HTTP and has HTTP verb support.
MQTT comes under pub - sub model. Ideal speaking you need a third machine which runs MQTT broker.
I have found the following code to establish a new vpn programmatically but I do not know how to use it to create my app
VpnService service = context.getSystemService(VPN_SERVICE);
VpnProfile profile = VpnProfile.create(L2TP_PROFILE);
profile.setName(myServerName);
profile.setServerName(myServerAddress);
profile.setRouteList("192.168.1.0/255.255.255.0,192.168.10.0/255.255.255.0");
service.connect(profile, "myUserName", "myPassword");
service.setNotificationIntent(myIntent);
can anyone please help me with a sample code?
Is it even possible to to achieve dis?
Note: this answer is dated and may now be inaccurate.
Take a look at this question: How to configure VPN programmatically?
While yours isn't necessarily a duplicate, the answer is likely the same, in that you're going to need to expose the hidden API (if it's available) or worse, be dependent on the device being rooted.
Understandably, programmatically creating a VPN connection poses an inherent security risk for the end user, and shouldn't be implemented without consideration.
I'm working on a project that requires my app to be able to send DTMF tones on the voice's uplink frequency during an active call.
My 2 conditions are:
We don't use a customized Android platform
We don't need to root the phone
I've spent several days doing my homework and am aware that in-call DTMF sending is not supported by the current SDK/standard APIs. However, by using the relevant classes in com.android.internal.telephony I am hoping to mimic how the native Phone app does this. I followed this site on how to use internal APIs for standard 3rd party apps.
I've also set myself up with the Android OS dev environment and am able to run the Phone app in debug mode on an emulator to figure its inner workings.
I tried various ways on a stock standard emulator but the errors I got were:
After trying to install a renamed app based on Phone.apk's source using the sharedUserId of android.uid.phone, I got:
Installation error: INSTALL_FAILED_SHARED_USER_INCOMPATIBLE
No doubt due to the fact I don't have the system cert to sign it.
After trying to write a custom app based on the relevant DTMF tone sending code from Phone.apk's source, I get the following error at setting up the PhoneFactory;
java.lang.SecurityException: Permission Denial: not allowed to send broadcast android.provider.Telephony.SPN_STRINGS_UPDATED.
No doubt due to the fact my app doesn't have the right permissions, although AndroidManifest.xml is setup with the same permissions as Phone.apk.
I'm at a loss as to what else I could try. Does anyone have any suggestions?
Thanks in advance,
Simon.
You've taken an interesting approach, and I commend your efforts. Unfortunately, there are some reserved internal privileges (evidently, such as SPN_STRINGS_UPDATED) that you aren't allowed to use as an app developer, which more or less breaks this approach. You could try removing the area of code causing this, but I'm fairly certain you will run into a blocking problem.
Hence, I'm afraid this is not possible at the moment. There's an open feature request on Android for sending DTMF tones over an existing phone call, but it has been dormant there for almost two years.
I understand that this doesn't resolve your problem, but take note that you can send DTMF tones directly after dialing a number:
Intent i = new Intent("android.intent.action.CALL",
Uri.parse("tel://" + number + "," + dtmfTones));
Simply put, you won't be able to do it without customizing at least the Phone app, which has to run as a system user in order to access the modem. In order to do this, you have to root your phone.
To meet your requirements the only possible solution is to enhance the android platform. We did just that, and already sent in our patches to the AOSP project:
https://android-review.googlesource.com/32820
https://android-review.googlesource.com/32821
We are currently waiting for the Google developers to review and accept our contribution. If you are interested, please let Google know on the various AOSP lists (android-contrib, android-platform). It will hopefully expedite the review.
Best Regards,
Gergely
You can't send DTMF tones during an active call, but you can send them when you "program" them when you initiate the call.
see the following post: https://stackoverflow.com/a/12986066/475472
I'm trying (wondering if it's even possible) to write an app, that would change the network selection mode automatically, based on some criteria. E.g. change the network operator from Vodafone to T-Mobile (assuming that the SIM card registration will succeed, but I'm not worried about it atm)
Unfortunately, I can't seem to find any way in the API to do it. Anyone has any idea?
I assume, since it's not in the public APIs, there might still be a way to do it, if the phone is rooted. Is that true? If so, where should I look?
Thanks in advance
Sorry but you can't.
You can have a look into the TelephonyManager .
You can know the current operator: getSimOperator(Name) / getNetworkOperator(Name).
You can also check this thread saying "I learn that for the sake of security there aren't any public APIs to manage this so the only option is to send the user to the system PreferenceScreen within my app."
How about using android.telephony.CarrierConfigManager? I read about it on https://developer.android.com/reference/android/telephony/CarrierConfigManager.html and it seems to allow you to change alot of carrier-specific parameters, although the app must be signed with the certificate that has a matching signature to one on the SIM, so it can usually only be implemented by the carrier issuing the SIM. See also https://source.android.com/devices/tech/config/carrier.
I havent found an actual method to actively switch carrier, but if anywhere, I'd expect it to be there.