Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
guilhermedom committed Jun 16, 2022
1 parent 20285f4 commit 0836913
Show file tree
Hide file tree
Showing 48 changed files with 2,694 additions and 0 deletions.
13 changes: 13 additions & 0 deletions _gitignore.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
1 change: 1 addition & 0 deletions app/_gitignore.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
31 changes: 31 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 28
defaultConfig {
applicationId "com.guilhermed.offloadingfibonaccibench"
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.mcxiaoke.volley:library:1.0.19'
implementation 'com.cloudbees:endpoints:0.8'
implementation 'eu.hgross:blaubot-android:2+'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
21 changes: 21 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.guilhermed.offloadingfibonaccibench;

import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.*;

/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();

assertEquals("com.guilhermed.offloadingfibonacci", appContext.getPackageName());
}
}
42 changes: 42 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.guilhermed.offloadingfibonaccibench">

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_SECONDARY_STORAGE" />
<uses-permission android:name="android.permission.WRITE_SECONDARY_STORAGE" />
<uses-permission android:name="android.permission.STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.VIBRATE" />

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:largeHeap="true"
android:usesCleartextTraffic="true">
<uses-library android:name="org.apache.http.legacy" android:required="false"/>

<service
android:name=".Midd"
android:enabled="true"
android:exported="true"></service>

<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
17 changes: 17 additions & 0 deletions app/src/main/java/AMOk/Actuator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package AMOk;

import Offload.Dataset;

public class Actuator {
private KnowledgeBase kBase;
private Dataset dataset;

public Actuator() {
kBase = KnowledgeBase.getInstance();
dataset = Dataset.getInstance();
}

public void act(){
dataset.setShouldOffload(kBase.getShouldOffload());
}
}
39 changes: 39 additions & 0 deletions app/src/main/java/AMOk/Analyser.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package AMOk;

import android.util.Log;

import Offload.Dataset;

public class Analyser {

public void analyse(){
KnowledgeBase kBase = KnowledgeBase.getInstance();

final String toastText = "fileSizeValue[0,1]: "+ Math.min((double)KnowledgeBase.getInstance().getFileSize()/(double)30,(double)1)
+ "\nMemoValue[0,1]: "+ (double)KnowledgeBase.getInstance().getHeapUsed()/(double)KnowledgeBase.getInstance().getHeapSize()
+ "\nBattery[0,1]:" + (double)KnowledgeBase.getInstance().getBatteryPct();
Log.d("Analyser data:",toastText);

/** Specialist defined parameters due to application requests*/
double batteryWeight = 0.5;
double memoWeight = 0.3;
double sizeWeight = 0.2;


double memo = memoWeight*((double)kBase.getHeapUsed()/(double)kBase.getHeapSize());

/** Using 30KB as size reference*/
double size = sizeWeight* Math.min((double)kBase.getFileSize()/(double)30,(double)1);

double battery;

if(kBase.isCharging())
battery = batteryWeight;
else
battery = batteryWeight*(double)kBase.getBatteryPct();

double coef = size + battery + memo;

kBase.setCoefficient(coef);
}
}
9 changes: 9 additions & 0 deletions app/src/main/java/AMOk/Executor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package AMOk;

public class Executor {

public void execute(){
Actuator mActuator = new Actuator();
mActuator.act();
}
}
22 changes: 22 additions & 0 deletions app/src/main/java/AMOk/FrameworkMain.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package AMOk;

public class FrameworkMain {
private Monitor mMonitor;
private Analyser mAnalyser;
private Planner mPlanner;
private Executor mExecutor;

public FrameworkMain(){
mMonitor = new Monitor();
mAnalyser = new Analyser();
mPlanner = new Planner();
mExecutor = new Executor();
}

public void run(){
mMonitor.monitor();
mAnalyser.analyse();
mPlanner.plan();
mExecutor.execute();
}
}
Loading

0 comments on commit 0836913

Please sign in to comment.