Reading and modifying Android code

masterminds

Member
Disciple
Mar 29, 2009
33
9
11
I have just stepped in the world of home automation and need your help, I have wifi enabled bulbs and an app to control them, now I want them to do more such as turn on at a specific time etc etc. Hence would like to know if it is possible to modify an existing android app. I have knowledge of only some basic programming, so need some specific steps as to how I can go about this , thank you.
 

6pack

Well-Known Member
ex-Mod
Sep 19, 2005
7,536
1,541
302
Short answer - nopes.

Long answer - Its written in Java and xml and is compiled with libraries etc. Plus to add new functions you need to full access to the entire code from the developer. Plus you need Android Studio and a VM to run and test the project. So nopes.
 
  • Like
Reactions: masterminds

masterminds

Member
Disciple
Mar 29, 2009
33
9
11
Thanks for the response, sorry if this question seems silly but there are sites which give you the source code once you upload the apk, Like I have the apps code files ( assets, com, lib, original, res, unknown folder and XML document and YML file) would that also not help ?
 

6pack

Well-Known Member
ex-Mod
Sep 19, 2005
7,536
1,541
302
Some sites only give the xml code which they extract from the app. It's not possible to reverse hack code that has been changed to machine language. The resource files are only the images or text. Changing them will only change some parts externally like icons, button names etc. It's not going to change the function associated with the button.
 
  • Like
Reactions: masterminds

drone

Banned
Disciple
Nov 13, 2016
69
21
17
kolkata
DIY Android Home Automation with free Smartphone Application



DIY SmartHome Application

Ever wanted to make your home automated? Wanted to control the lights, fan and other appliances from your smartphone? Or wanted a tutorial about connected devices and getting started with it? DIY Android Home Automation will show you how to make your home automated using an android smartphone. This requires you to have no experience of android programming at all, as a free application is included for you to develop. Using this android application you will be able to control your lights, air conditioning, door locks ,etc all from your smartphone. This system uses bluetooth to connect with your device and control the various appliances in your home. Have fun with this DIY hacking tutorial!

What are the stuff required to do this project?

Hardware :

  1. Arduino / Arduino Clone or make your own custom arduino board with this tutorial.
  2. A 5v TTL -UART bluetooth module like : JY-MCU BT_BOARD (Cheaper) or Bluesmirf Gold/Silver.
  3. Five 5V SPDT relays like : 5V relay.
  4. Prototype board or breadboard.
  5. Connecting wires.
Software :

  1. Arduino IDE : Arduino .
  2. Eclipse for android programming (optional, not required). For instructions on installing and setting up the environment : How to install android and eclipse. And tutorials to begin learning android programming even though you don’t require it for this project : Tutorial .
So how does it work?

The DIY Android Home Automation project comes with a free application called “DIY SmartHome” . This application controls the various appliances connected to your arduino and relays. When the toggle buttons on the application are pressed, corresponding bluetooth signals are sent from your android phone to the bluetooth module you have hooked up to your arduino. The arduino finds out which signal was sent and compares it to the predefined signals assigned for each appliance. When it identifies that signal, then the arduino activates the relay hooked up to its digital pin by passing 5V through it. Thus the relay is switched ON and the corresponding appliance connected to the relay is turned ON as well. To switch it OFF , arduino passes a 0V or logic low to its digital pin.


DIY Android Home Automation



Step 1 : Setting up the connections for the DIY Android Home Automation project

DIY Android Home Automation

The connection diagram for arduino is as shown. For setting up this system , wiring connections have to be made between the arduino and bluetooth module and also with the relays. Here, the bluetooth module’s Tx is connected to arduino Rx (digital pin 0) and the module’s Rx to arduino Tx (digital pin 1). 5V and GND of the module is connected to the arduino’s 5V and GND.


Relay pin out

The relay your using is SPDT, it has 5 pins on the under side. As shown above , here pins 1 and 3are the coil pins. 1 is connected to the arduino digital pin and 3 is connected to arduino GND. 2 is the common contact in the relay to which you have to connect the power for your appliance (AC 230V), and 4 is the pin to which you have to connect your appliance wire.

Step 2 : Connecting your appliance to the relay

5V SPDT Relays

In a normal SPDT relay, whose pin out is shown in the above step, pins 2 and 4 act identical to the two terminals of a switch. When digital HIGH voltage is applied from the arduino to the relay, switch turns ON, when the voltage is withdrawn it turns OFF. You can attach this system you made to a normal switchboard by extending the wires from behind the switches in the board to your relay. As seen in the connection diagram in the above step, you have to connect a power AC line to the common terminal of all the relays. Then, you have to extend the wires from behind the switchboard of the corresponding lights/lamps you wish to control. Each of these wires are connected to the “NO”(Normally Open) terminal of the relays (pin no 4 in step no 1’s relay pin out diagram). NOTE : If you wish to control door locks, you may use door lock solenoids , which can be purchased and connected to your system and turned ON/OFF using the same way. The picture below shows how you can attach the system to your switchboard (keep in mind, this is just to show you the arrangement, it is not the original system being described here):



Step 3 : (Optional) Creating your custom PCB for the DIY Android Home Automation project

DIY Android Home Automation Schematic

If you wish to create your own custom PCB, please use the above schematic. Here, you just have to insert an arduino bootloaded ATmega 168/328 chip in the socket to get it working. All the supporting circuitry for arduino is included.

Step 4 : Loading the arduino software

Arduino DIY Android Home Automation Code

If you are new to arduino, download the arduino IDE (Integrated Development Environment) from Arduino . The tutorials for beginners can be seen here : Arduino tutorial . The arduino code for the following project is here : DIY_SmartHome . The code is really simple, here it checks the incoming bluetooth signal via the bluetooth module and then compares (ASCII values) using an “if” statement with previously defined values. If it matches the value, relay is activated using “digitalWrite(pin,HIGH)” command , which passes 5V to the arduino digital pin.PLEASE NOTE : SINCE THE BLUETOOTH MODULE IS CONNECTED TO THE RX AND TX PINS OF THE ARDUINO, THE MODULE SHOULD BE REMOVED WHILE UPLOADING THE CODE FROM PC TO THE ARDUINO. THE MODULE SHOULD BE CONNECTED ONCE THE UPLOAD IS COMPLETE. Upload the code to your arduino board , then follow step 5.

Step 5 : Downloading the android application and setting up bluetooth

Discovering new bluetooth devices

To download the android application to your phone, copy this .apk file to your phone from the PC and then click on it from the phone to install it : DIY SmartHome. For those who wish to modify the application, I am attaching the project file here : DIY SmartHome project . Be sure to check “Allow installation of non-Market apps” in the Security tab under settings. Once you have installed the application, before opening it you need to pair and connect with your bluetooth module. For this, you need to power the arduino and bluetooth module and then turn ON the bluetooth of your phone and make it visible to other devices. After that, search for new devices in bluetooth, select your bluetooth module from the list, enter the pairing code when prompted , it is usually ’1234′ or ’0000′ .

Note the name of your device , in this case it is “HC-06″. After pairing with the system, go to the “DIY SmartHome” application and enter the name of your bluetooth module you noted earlier (case-sensitive) and click “OK”. After that the phone will get connected to your system , and on clicking the respective buttons, the appliances turn ON/OFF. Have fun with your new DIY Android Home Automation system!


DIY SmartHome Application



DIY Smart Home Application


SOURCE : https://diyhacking.com

Credit Goes to 0rigina Author Arvind Sanjeev
 

6pack

Well-Known Member
ex-Mod
Sep 19, 2005
7,536
1,541
302
@masterminds, look at above post where you can get source code for home automation app.
You can open it up in eclipse or Android studio.
 
  • Like
Reactions: masterminds