Skip to content

Commit 094625d

Browse files
committed
Done implementing app unlocking
1 parent a87a34e commit 094625d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+946
-3
lines changed

adduser.py

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import serial
2+
import anydbm
3+
import re
4+
import os
5+
6+
def connectToArduino():
7+
print 'Waiting for arduino to connect'
8+
while 1:
9+
# Find device
10+
dev = os.listdir('/dev/')
11+
pattern = re.compile('ttyACM.*')
12+
acm = [];
13+
for d in dev:
14+
if pattern.match(d):
15+
acm.append(d)
16+
17+
# Try to connect
18+
ser = None
19+
for d in acm:
20+
#try:
21+
ser = serial.Serial('/dev/'+d, 9600)
22+
# break
23+
#except serial.serialutil.SerialException:
24+
# pass
25+
26+
# Check if connected
27+
if ser is not None:
28+
break
29+
30+
# Wait for ready signal
31+
pattern = re.compile('READY')
32+
print 'Waiting for arduino to be ready'
33+
while 1:
34+
#try:
35+
res = ser.readline()
36+
if pattern.match(res):
37+
print 'Arduino is ready'
38+
break
39+
# except serial.serialutil.SerialException:
40+
# ser = connectToArduino()
41+
return ser
42+
43+
44+
ser = connectToArduino()
45+
46+
47+
# Open user acount
48+
db = anydbm.open('brukere', 'c')
49+
50+
adminMode = False;
51+
pattern = re.compile(u'ID: ([0-9A-F]*)')
52+
while 1:
53+
#try:
54+
res = ser.readline()
55+
res = pattern.findall(res)
56+
if (res !=[]):
57+
id = str(res[0])
58+
print 'Read id: '+id
59+
name = raw_input('Write in name of user: ')
60+
db[id] = name;
61+
db.sync()
62+
print db;
63+
64+
#except serial.serialutil.SerialException:
65+
# ser = connectToArduino()
66+
#except Exception, e:
67+
# print str(e)
68+
# ser = connectToArduino()
69+

doorlock/.classpath

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" path="src"/>
4+
<classpathentry kind="src" path="gen"/>
5+
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
6+
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
7+
<classpathentry kind="output" path="bin/classes"/>
8+
</classpath>

doorlock/.project

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>doorlock</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
<buildCommand>
19+
<name>org.eclipse.jdt.core.javabuilder</name>
20+
<arguments>
21+
</arguments>
22+
</buildCommand>
23+
<buildCommand>
24+
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
25+
<arguments>
26+
</arguments>
27+
</buildCommand>
28+
</buildSpec>
29+
<natures>
30+
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
31+
<nature>org.eclipse.jdt.core.javanature</nature>
32+
</natures>
33+
</projectDescription>

doorlock/AndroidManifest.out.xml

Whitespace-only changes.

doorlock/AndroidManifest.xml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="no.doorlock"
4+
android:versionCode="1"
5+
android:versionName="1.0" >
6+
7+
<uses-sdk android:minSdkVersion="7" />
8+
<uses-permission android:name="android.permission.INTERNET" />
9+
<application
10+
android:icon="@drawable/ic_launcher"
11+
android:label="@string/app_name" >
12+
<activity
13+
android:label="@string/app_name"
14+
android:name=".DoorlockActivity" >
15+
<intent-filter >
16+
<action android:name="android.intent.action.MAIN" />
17+
18+
<category android:name="android.intent.category.LAUNCHER" />
19+
</intent-filter>
20+
</activity>
21+
</application>
22+
23+
</manifest>

doorlock/bin/classes.dex

15.3 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
319 Bytes
Binary file not shown.
386 Bytes
Binary file not shown.
394 Bytes
Binary file not shown.
373 Bytes
Binary file not shown.
470 Bytes
Binary file not shown.
482 Bytes
Binary file not shown.

doorlock/bin/doorlock.apk

20.2 KB
Binary file not shown.
3.87 KB
Loading
1.5 KB
Loading
2.15 KB
Loading

doorlock/bin/resources.ap_

10.9 KB
Binary file not shown.

doorlock/gen/no/doorlock/R.java

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/* AUTO-GENERATED FILE. DO NOT MODIFY.
2+
*
3+
* This class was automatically generated by the
4+
* aapt tool from the resource data it found. It
5+
* should not be modified by hand.
6+
*/
7+
8+
package no.doorlock;
9+
10+
public final class R {
11+
public static final class attr {
12+
}
13+
public static final class drawable {
14+
public static final int ic_launcher=0x7f020000;
15+
}
16+
public static final class id {
17+
public static final int button1=0x7f050000;
18+
public static final int scanqr=0x7f050001;
19+
}
20+
public static final class layout {
21+
public static final int main=0x7f030000;
22+
}
23+
public static final class string {
24+
public static final int app_name=0x7f040001;
25+
public static final int hello=0x7f040000;
26+
public static final int scanqr=0x7f040003;
27+
public static final int togglelock=0x7f040002;
28+
}
29+
}

doorlock/proguard.cfg

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
-optimizationpasses 5
2+
-dontusemixedcaseclassnames
3+
-dontskipnonpubliclibraryclasses
4+
-dontpreverify
5+
-verbose
6+
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
7+
8+
-keep public class * extends android.app.Activity
9+
-keep public class * extends android.app.Application
10+
-keep public class * extends android.app.Service
11+
-keep public class * extends android.content.BroadcastReceiver
12+
-keep public class * extends android.content.ContentProvider
13+
-keep public class * extends android.app.backup.BackupAgentHelper
14+
-keep public class * extends android.preference.Preference
15+
-keep public class com.android.vending.licensing.ILicensingService
16+
17+
-keepclasseswithmembernames class * {
18+
native <methods>;
19+
}
20+
21+
-keepclasseswithmembers class * {
22+
public <init>(android.content.Context, android.util.AttributeSet);
23+
}
24+
25+
-keepclasseswithmembers class * {
26+
public <init>(android.content.Context, android.util.AttributeSet, int);
27+
}
28+
29+
-keepclassmembers class * extends android.app.Activity {
30+
public void *(android.view.View);
31+
}
32+
33+
-keepclassmembers enum * {
34+
public static **[] values();
35+
public static ** valueOf(java.lang.String);
36+
}
37+
38+
-keep class * implements android.os.Parcelable {
39+
public static final android.os.Parcelable$Creator *;
40+
}

doorlock/project.properties

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# This file is automatically generated by Android Tools.
2+
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3+
#
4+
# This file must be checked in Version Control Systems.
5+
#
6+
# To customize properties used by the Ant build system use,
7+
# "ant.properties", and override values to adapt the script to your
8+
# project structure.
9+
10+
# Project target.
11+
target=android-7
4.05 KB
Loading
1.68 KB
Loading
2.51 KB
Loading

doorlock/res/layout/main.xml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:layout_width="fill_parent"
4+
android:layout_height="fill_parent"
5+
android:orientation="vertical" >
6+
7+
<TextView
8+
android:layout_width="fill_parent"
9+
android:layout_height="wrap_content"
10+
android:text="@string/hello" />
11+
12+
<Button
13+
android:id="@+id/button1"
14+
android:layout_width="wrap_content"
15+
android:layout_height="wrap_content"
16+
android:text="@string/togglelock" />
17+
18+
<Button
19+
android:id="@+id/scanqr"
20+
android:layout_width="wrap_content"
21+
android:layout_height="wrap_content"
22+
android:text="@string/scanqr" />
23+
24+
</LinearLayout>

doorlock/res/values/strings.xml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
4+
<string name="hello">Hello World, DoorlockActivity!</string>
5+
<string name="app_name">Doorlock</string>
6+
<string name="togglelock">Toggle lock</string>
7+
<string name="scanqr">Scan QR</string>
8+
9+
</resources>

0 commit comments

Comments
 (0)