init
|
@ -0,0 +1,14 @@
|
|||
*.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
|
||||
.cxx
|
|
@ -0,0 +1,116 @@
|
|||
<component name="ProjectCodeStyleConfiguration">
|
||||
<code_scheme name="Project" version="173">
|
||||
<codeStyleSettings language="XML">
|
||||
<indentOptions>
|
||||
<option name="CONTINUATION_INDENT_SIZE" value="4" />
|
||||
</indentOptions>
|
||||
<arrangement>
|
||||
<rules>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>xmlns:android</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>xmlns:.*</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
<order>BY_NAME</order>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*:id</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*:name</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>name</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>style</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
<order>BY_NAME</order>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
<order>ANDROID_ATTRIBUTE_ORDER</order>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>.*</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
<order>BY_NAME</order>
|
||||
</rule>
|
||||
</section>
|
||||
</rules>
|
||||
</arrangement>
|
||||
</codeStyleSettings>
|
||||
</code_scheme>
|
||||
</component>
|
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
<option value="$PROJECT_DIR$/app" />
|
||||
</set>
|
||||
</option>
|
||||
<option name="resolveModulePerSourceSet" value="false" />
|
||||
<option name="testRunner" value="PLATFORM" />
|
||||
</GradleProjectSettings>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
<option name="id" value="Android" />
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RunConfigurationProducerService">
|
||||
<option name="ignoredProducers">
|
||||
<set>
|
||||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
|
||||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
|
||||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
|
||||
</set>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,46 @@
|
|||
<p align="center">
|
||||
<img height="200" src="https://raw.githubusercontent.com/NandanDesai/res/master/privacy_breacher.png">
|
||||
</p>
|
||||
<h2 align="center">PrivacyBreacher</h2>
|
||||
|
||||
PrivacyBreacher is an Android app built as a proof of concept for a research article describing the privacy issues in Android. This app can access following information from your phone *without requesting any permissions*:
|
||||
|
||||
1. **Screen state of your phone (i.e., when your phone screen goes off/on)**
|
||||
2. **Monitor when you plug-in and remove your phone charger and wired headphones.**
|
||||
3. **Figure out at what time you switched on/off your phone (not directly implemented) .**
|
||||
4. **Access most of your device related information like your phone model, manufacturer etc.**
|
||||
5. **Keep track of your WiFi/Mobile data usage.**
|
||||
6. **Get a list of all the apps installed on your phone.**
|
||||
7. **Construct a 3D visualization of your body movements.**
|
||||
|
||||
This app supports Android Pie (Android 9, API 28) or later versions.
|
||||
|
||||
## Research Article
|
||||
|
||||
To get more information on how this app can access all that data, check out our article here!
|
||||
|
||||
## Screenshots
|
||||
|
||||
|
||||
<img height="500" src="https://raw.githubusercontent.com/NandanDesai/res/master/privacybreacher-1.jpeg"> <img height="500" src="https://raw.githubusercontent.com/NandanDesai/res/master/privacybreacher-2.jpeg"> <img height="500" src="https://raw.githubusercontent.com/NandanDesai/res/master/privacybreacher-3.jpeg"> <img height="500" src="https://raw.githubusercontent.com/NandanDesai/res/master/privacybreacher-5.jpeg">
|
||||
|
||||
## Download
|
||||
|
||||
Links will be provided soon!
|
||||
|
||||
## Contribute
|
||||
|
||||
We accept pull requests for this app. If you find any bugs or want to add new features or just want to improve the code structure, then pull requests are most welcome!
|
||||
|
||||
## License
|
||||
|
||||
MIT License
|
||||
|
||||
Copyright 2020 DataBurn
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
|
@ -0,0 +1 @@
|
|||
/build
|
|
@ -0,0 +1,28 @@
|
|||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion 29
|
||||
buildToolsVersion "29.0.2"
|
||||
defaultConfig {
|
||||
applicationId "io.nandandesai.privacybreacher"
|
||||
minSdkVersion 28
|
||||
targetSdkVersion 29
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
implementation 'androidx.appcompat:appcompat:1.0.2'
|
||||
implementation "androidx.lifecycle:lifecycle-livedata:2.0.0"
|
||||
implementation 'androidx.recyclerview:recyclerview:1.0.0'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
||||
}
|
|
@ -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
|
|
@ -0,0 +1 @@
|
|||
[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":1,"versionName":"1.0","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
|
|
@ -0,0 +1,27 @@
|
|||
package io.nandandesai.privacybreacher;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.test.ext.junit.runners.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.getInstrumentation().getTargetContext();
|
||||
|
||||
assertEquals("io.nandandesai.privacybreacher", appContext.getPackageName());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="io.nandandesai.privacybreacher">
|
||||
<!-- Tell the system this app requires OpenGL ES 2.0. -->
|
||||
<uses-feature
|
||||
android:glEsVersion="0x00020000"
|
||||
android:required="true" />
|
||||
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||
|
||||
<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">
|
||||
<activity android:name=".AboutActivity"></activity>
|
||||
<activity android:name=".PhoneInfoActivity" />
|
||||
<activity android:name=".PhoneMonitorActivity" />
|
||||
<activity android:name=".PhysicalMonitorActivity" />
|
||||
|
||||
<service
|
||||
android:name=".PrivacyBreacherService"
|
||||
android:enabled="true"
|
||||
android:exported="true" />
|
||||
|
||||
<receiver
|
||||
android:name=".EventReceiver"
|
||||
android:enabled="true"
|
||||
android:exported="true" />
|
||||
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:launchMode="singleTop">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
After Width: | Height: | Size: 91 KiB |
|
@ -0,0 +1,14 @@
|
|||
package io.nandandesai.privacybreacher;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
public class AboutActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_about);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
package io.nandandesai.privacybreacher;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class AppListRecyclerAdapter extends RecyclerView.Adapter<AppListRecyclerAdapter.ViewHolder> {
|
||||
|
||||
private ArrayList<App> apps;
|
||||
private Context context;
|
||||
|
||||
public AppListRecyclerAdapter(Context context, ArrayList<App> apps) {
|
||||
this.apps = apps;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int viewType) {
|
||||
View view = LayoutInflater.from(context).inflate(R.layout.app_list_item, viewGroup, false);
|
||||
return new ViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ViewHolder viewHolder, int position) {
|
||||
App app = apps.get(position);
|
||||
|
||||
viewHolder.appIcon.setImageDrawable(app.getIcon());
|
||||
viewHolder.appName.setText(app.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return apps.size();
|
||||
}
|
||||
|
||||
class ViewHolder extends RecyclerView.ViewHolder {
|
||||
ImageView appIcon;
|
||||
TextView appName;
|
||||
|
||||
ViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
this.appIcon = itemView.findViewById(R.id.appIconImage);
|
||||
this.appName = itemView.findViewById(R.id.appName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class App {
|
||||
private String name;
|
||||
private Drawable icon;
|
||||
|
||||
public App(String name, Drawable icon) {
|
||||
this.name = name;
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Drawable getIcon() {
|
||||
return icon;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
package io.nandandesai.privacybreacher;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.os.BatteryManager;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
|
||||
public class EventReceiver extends BroadcastReceiver {
|
||||
|
||||
private static final String TAG = "EventReceiver";
|
||||
|
||||
private ArrayList<String> eventList = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String action = intent.getAction();
|
||||
if (Intent.ACTION_SCREEN_ON.equals(action)) {
|
||||
Log.i(TAG, "onReceive: Screen is active.");
|
||||
eventList.add("\uD83D\uDD06 Phone screen turned ON at " + getFormattedDate(System.currentTimeMillis()));
|
||||
PrivacyBreacherService.eventDatabase.setValue(eventList);
|
||||
} else if (Intent.ACTION_SCREEN_OFF.equals(action)) {
|
||||
Log.i(TAG, "onReceive: Screen is inactive.");
|
||||
eventList.add("\uD83D\uDD05 Phone screen turned OFF at " + getFormattedDate(System.currentTimeMillis()));
|
||||
PrivacyBreacherService.eventDatabase.setValue(eventList);
|
||||
} else if (Intent.ACTION_SHUTDOWN.equals(action)) {
|
||||
Toast.makeText(context, "PrivacyBreacher just saw that you are switching OFF your phone!", Toast.LENGTH_LONG).show();
|
||||
} else if (Intent.ACTION_POWER_CONNECTED.equals(action)) {
|
||||
Log.i(TAG, "onReceive: Phone charger is connected");
|
||||
IntentFilter ifilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
|
||||
Intent batteryStatus = context.registerReceiver(null, ifilter);
|
||||
// How are we charging?
|
||||
int chargePlug = batteryStatus.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1);
|
||||
boolean usbCharge = chargePlug == BatteryManager.BATTERY_PLUGGED_USB;
|
||||
boolean acCharge = chargePlug == BatteryManager.BATTERY_PLUGGED_AC;
|
||||
|
||||
if (usbCharge) {
|
||||
eventList.add("⚡ You started charging your phone using USB cable connected to a laptop/PC at " + getFormattedDate(System.currentTimeMillis()));
|
||||
PrivacyBreacherService.eventDatabase.setValue(eventList);
|
||||
} else if (acCharge) {
|
||||
eventList.add("\uD83D\uDD0C You started charging your phone using a Power Bank or AC Charging adapter at " + getFormattedDate(System.currentTimeMillis()));
|
||||
PrivacyBreacherService.eventDatabase.setValue(eventList);
|
||||
}
|
||||
|
||||
Log.i(TAG, "usbCharge: " + usbCharge);
|
||||
Log.i(TAG, "acCharging: " + acCharge);
|
||||
} else if (Intent.ACTION_POWER_DISCONNECTED.equals(action)) {
|
||||
Log.i(TAG, "onReceive: Phone charger is disconnected.");
|
||||
eventList.add("\uD83D\uDD0B You disconnected your phone charger at " + getFormattedDate(System.currentTimeMillis()));
|
||||
PrivacyBreacherService.eventDatabase.setValue(eventList);
|
||||
} else if (Intent.ACTION_HEADSET_PLUG.equals(action)) {
|
||||
if (!isInitialStickyBroadcast()) {
|
||||
Log.i(TAG, "onReceive: Headphone action detected!");
|
||||
int state = intent.getIntExtra("state", -1);
|
||||
if (state == 1) {
|
||||
eventList.add("\uD83C\uDFA7 You plugged headphones at " + getFormattedDate(System.currentTimeMillis()));
|
||||
PrivacyBreacherService.eventDatabase.setValue(eventList);
|
||||
} else if (state == 0) {
|
||||
eventList.add("\uD83D\uDD0A You unplugged headphones at " + getFormattedDate(System.currentTimeMillis()));
|
||||
PrivacyBreacherService.eventDatabase.setValue(eventList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private String getFormattedDate(long unixTime) {
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("dd-M-yyyy hh:mm:ss aa", Locale.US);
|
||||
Date date = new Date(unixTime);
|
||||
return formatter.format(date);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,114 @@
|
|||
package io.nandandesai.privacybreacher;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.PopupMenu;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
private static final String TAG = "MainActivity";
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
if (!isMyServiceRunning(PrivacyBreacherService.class)) {
|
||||
//start the foreground service
|
||||
Intent serviceIntent = new Intent(this, PrivacyBreacherService.class);
|
||||
startService(serviceIntent);
|
||||
}
|
||||
|
||||
//on click listeners
|
||||
ImageButton optionsButton = findViewById(R.id.optionsButton);
|
||||
optionsButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
showPopup(v);
|
||||
}
|
||||
});
|
||||
|
||||
Button physicalMonitorButton = findViewById(R.id.physicalMonitorButton);
|
||||
physicalMonitorButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent intent = new Intent(MainActivity.this, PhysicalMonitorActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
Button phoneMonitorButton = findViewById(R.id.phoneMonitorButton);
|
||||
phoneMonitorButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent intent = new Intent(MainActivity.this, PhoneMonitorActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
Button phoneInfoButton = findViewById(R.id.phoneInfoButton);
|
||||
phoneInfoButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent intent = new Intent(MainActivity.this, PhoneInfoActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void showPopup(View v) {
|
||||
PopupMenu popup = new PopupMenu(this, v);
|
||||
MenuInflater inflater = popup.getMenuInflater();
|
||||
Menu menu = popup.getMenu();
|
||||
inflater.inflate(R.menu.home_menu, menu);
|
||||
MenuItem aboutMenu = menu.findItem(R.id.menu_about);
|
||||
aboutMenu.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
|
||||
Intent intent = new Intent(MainActivity.this, AboutActivity.class);
|
||||
startActivity(intent);
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
MenuItem exitMenu = menu.findItem(R.id.menu_exit);
|
||||
exitMenu.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
exitApp();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
popup.show();
|
||||
}
|
||||
|
||||
private boolean isMyServiceRunning(Class<?> serviceClass) {
|
||||
ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
|
||||
for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
|
||||
if (serviceClass.getName().equals(service.service.getClassName())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void exitApp() {
|
||||
Intent serviceIntent = new Intent(MainActivity.this, PrivacyBreacherService.class);
|
||||
MainActivity.this.stopService(serviceIntent);
|
||||
finish();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,189 @@
|
|||
package io.nandandesai.privacybreacher;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.recyclerview.widget.DividerItemDecoration;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.TrafficStats;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.SystemClock;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class PhoneInfoActivity extends AppCompatActivity {
|
||||
|
||||
private static final String TAG = "PhoneInfoActivity";
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_phone_info);
|
||||
new ActivityLoadTask(this).execute();
|
||||
}
|
||||
|
||||
private static String getFormattedDataMeasure(long bytes) {
|
||||
DecimalFormat decimalFormat = new DecimalFormat("#.#");
|
||||
String dataFormat = bytes + " B";
|
||||
float speed = 0;
|
||||
if (bytes >= 1024) {
|
||||
speed = bytes / 1024; //KB
|
||||
speed = Float.valueOf(decimalFormat.format(speed));
|
||||
if (speed >= 1024) {
|
||||
speed = speed / 1024; //MB
|
||||
speed = Float.valueOf(decimalFormat.format(speed));
|
||||
if (speed >= 1024) {
|
||||
speed = speed / 1024; //GB
|
||||
speed = Float.valueOf(decimalFormat.format(speed));
|
||||
dataFormat = speed + " GB";
|
||||
} else {
|
||||
dataFormat = speed + " MB";
|
||||
}
|
||||
} else {
|
||||
dataFormat = speed + " KB";
|
||||
}
|
||||
}
|
||||
|
||||
return dataFormat;
|
||||
}
|
||||
|
||||
private static class ActivityLoadTask extends AsyncTask<Void, Void, Void> {
|
||||
|
||||
private TextView productView;
|
||||
private TextView modelView;
|
||||
private TextView manufacturerView;
|
||||
private TextView manufacturedOn;
|
||||
private TextView brandView;
|
||||
private TextView deviceView;
|
||||
private TextView deviceUptimeView;
|
||||
private TextView mobileDataView;
|
||||
private TextView wifiDataView;
|
||||
|
||||
private RecyclerView appListRecyclerView;
|
||||
|
||||
private LinearLayout phoneInfoView;
|
||||
private ProgressBar progressBar;
|
||||
|
||||
//Build
|
||||
private String product;
|
||||
private String model;
|
||||
private String manufacturer;
|
||||
private String buildTime;
|
||||
private String brand;
|
||||
private String device;
|
||||
|
||||
//uptime
|
||||
private String uptimeString;
|
||||
|
||||
//data used
|
||||
private long mobileDataUsed;
|
||||
private long wifiDataUsed;
|
||||
|
||||
//apps installed
|
||||
private ArrayList<AppListRecyclerAdapter.App> apps = new ArrayList<>();
|
||||
|
||||
private AppCompatActivity activity;
|
||||
|
||||
ActivityLoadTask(AppCompatActivity activity) {
|
||||
this.activity = activity;
|
||||
productView = activity.findViewById(R.id.product);
|
||||
modelView = activity.findViewById(R.id.model);
|
||||
manufacturerView = activity.findViewById(R.id.manufacturer);
|
||||
manufacturedOn = activity.findViewById(R.id.manufacturedOn);
|
||||
brandView = activity.findViewById(R.id.brand);
|
||||
deviceView = activity.findViewById(R.id.device);
|
||||
deviceUptimeView = activity.findViewById(R.id.deviceUptime);
|
||||
mobileDataView = activity.findViewById(R.id.mobileDataUsed);
|
||||
wifiDataView = activity.findViewById(R.id.wifiDataUsed);
|
||||
|
||||
appListRecyclerView = activity.findViewById(R.id.appListRecyclerView);
|
||||
|
||||
phoneInfoView = activity.findViewById(R.id.phoneInfoView);
|
||||
progressBar = activity.findViewById(R.id.progressBar);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
phoneInfoView.setVisibility(View.INVISIBLE);
|
||||
progressBar.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... voids) {
|
||||
|
||||
//build info
|
||||
product = Build.PRODUCT;
|
||||
model = Build.MODEL;
|
||||
manufacturer = Build.MANUFACTURER;
|
||||
buildTime = new Date(Build.TIME).toString();
|
||||
brand = Build.BRAND;
|
||||
device = Build.DEVICE;
|
||||
|
||||
//SystemClock, get the uptime of the device since boot
|
||||
long uptime = SystemClock.uptimeMillis();
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("dd:HH:mm:ss", Locale.ENGLISH);
|
||||
Date date = new Date(uptime);
|
||||
uptimeString = formatter.format(date);
|
||||
|
||||
//Data used
|
||||
mobileDataUsed = TrafficStats.getMobileRxBytes() + TrafficStats.getTotalTxBytes();
|
||||
long totalDataUsed = TrafficStats.getTotalRxBytes() + TrafficStats.getTotalTxBytes();
|
||||
wifiDataUsed = totalDataUsed - mobileDataUsed;
|
||||
|
||||
//apps installed
|
||||
final PackageManager pm = activity.getPackageManager();
|
||||
List<ApplicationInfo> packages = pm.getInstalledApplications(PackageManager.GET_META_DATA);
|
||||
|
||||
for (ApplicationInfo packageInfo : packages) {
|
||||
String appName = pm.getApplicationLabel(packageInfo).toString();
|
||||
Drawable appIcon = pm.getApplicationIcon(packageInfo);
|
||||
apps.add(new AppListRecyclerAdapter.App(appName, appIcon));
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Void voids) {
|
||||
|
||||
productView.setText(product);
|
||||
modelView.setText(model);
|
||||
manufacturerView.setText(manufacturer);
|
||||
manufacturedOn.setText(buildTime);
|
||||
brandView.setText(brand);
|
||||
deviceView.setText(device);
|
||||
deviceUptimeView.setText(uptimeString + " in (dd:hh:mm:ss) format");
|
||||
mobileDataView.setText(getFormattedDataMeasure(mobileDataUsed));
|
||||
wifiDataView.setText(getFormattedDataMeasure(wifiDataUsed));
|
||||
|
||||
LinearLayoutManager layoutManager = new LinearLayoutManager(activity);
|
||||
appListRecyclerView.setLayoutManager(layoutManager);
|
||||
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(appListRecyclerView.getContext(), layoutManager.getOrientation());
|
||||
appListRecyclerView.addItemDecoration(dividerItemDecoration);
|
||||
|
||||
appListRecyclerView.setNestedScrollingEnabled(false);
|
||||
appListRecyclerView.setFocusable(false);
|
||||
|
||||
AppListRecyclerAdapter appListRecyclerAdapter = new AppListRecyclerAdapter(activity, apps);
|
||||
appListRecyclerView.setAdapter(appListRecyclerAdapter);
|
||||
|
||||
phoneInfoView.setVisibility(View.VISIBLE);
|
||||
progressBar.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package io.nandandesai.privacybreacher;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class PhoneLogRecyclerAdapter extends RecyclerView.Adapter<PhoneLogRecyclerAdapter.ViewHolder> {
|
||||
private static final String TAG = "PhoneLogRecyclerAdapter";
|
||||
private Context context;
|
||||
private ArrayList<String> logEntries;
|
||||
|
||||
PhoneLogRecyclerAdapter(Context context, ArrayList<String> logEntries) {
|
||||
this.context = context;
|
||||
this.logEntries = logEntries;
|
||||
}
|
||||
|
||||
void setLogEntries(ArrayList<String> logEntries) {
|
||||
this.logEntries = logEntries;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int viewType) {
|
||||
View view = LayoutInflater.from(context).inflate(R.layout.phone_monitor_log_item, viewGroup, false);
|
||||
ViewHolder viewHolder = new ViewHolder(view);
|
||||
return viewHolder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ViewHolder viewHolder, int position) {
|
||||
Log.i(TAG, "onBindViewHolder: Adding log entry to TextView: " + logEntries.get(position));
|
||||
viewHolder.phoneMonitorLogItem.setText(logEntries.get(position));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return logEntries.size();
|
||||
}
|
||||
|
||||
class ViewHolder extends RecyclerView.ViewHolder {
|
||||
TextView phoneMonitorLogItem;
|
||||
|
||||
ViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
phoneMonitorLogItem = itemView.findViewById(R.id.phoneMonitorLogItem);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
package io.nandandesai.privacybreacher;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class PhoneMonitorActivity extends AppCompatActivity {
|
||||
|
||||
private static final String TAG = "PhoneMonitorActivity";
|
||||
private PhoneLogRecyclerAdapter phoneLogRecyclerAdapter;
|
||||
private RecyclerView phoneLogRecyclerView;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_phone_monitor);
|
||||
|
||||
phoneLogRecyclerView = findViewById(R.id.phoneLogRecyclerView);
|
||||
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
|
||||
phoneLogRecyclerView.setLayoutManager(layoutManager);
|
||||
phoneLogRecyclerAdapter = new PhoneLogRecyclerAdapter(this, new ArrayList<String>());
|
||||
phoneLogRecyclerView.setAdapter(phoneLogRecyclerAdapter);
|
||||
|
||||
final TextView noLogText = findViewById(R.id.noLogText);
|
||||
final TextView headingText = findViewById(R.id.headingText);
|
||||
headingText.setVisibility(View.INVISIBLE);
|
||||
PrivacyBreacherService.eventDatabase.observe(this, new Observer<ArrayList<String>>() {
|
||||
@Override
|
||||
public void onChanged(ArrayList<String> logEntries) {
|
||||
Log.i(TAG, "onChanged: event change received in PhoneMonitorActivity");
|
||||
noLogText.setVisibility(View.INVISIBLE);
|
||||
headingText.setVisibility(View.VISIBLE);
|
||||
Log.i(TAG, "LogEntries: " + logEntries);
|
||||
phoneLogRecyclerAdapter.setLogEntries(logEntries);
|
||||
phoneLogRecyclerAdapter.notifyDataSetChanged();
|
||||
phoneLogRecyclerView.scrollToPosition(phoneLogRecyclerAdapter.getItemCount() - 1);
|
||||
}
|
||||
});
|
||||
|
||||
AlertDialog.Builder alertDialog = new AlertDialog.Builder(this, R.style.AlertDialogCustom);
|
||||
alertDialog.setTitle("Phone activity monitoring");
|
||||
alertDialog.setMessage("Apps installed on your phone can monitor when you turn ON/OFF your screen without requesting any permissions. This way, they can know how many hours you used your phone today, from what time to what time you used your phone," +
|
||||
" how many times you charge your phone and are you charging with your Power Bank or AC Charging socket etc. This loophole can help bad guys build a pretty good spyware for your phone!");
|
||||
alertDialog.setCancelable(false);
|
||||
alertDialog.setPositiveButton("OK", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
dialogInterface.dismiss();
|
||||
}
|
||||
});
|
||||
alertDialog.show();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
package io.nandandesai.privacybreacher;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.pm.ConfigurationInfo;
|
||||
import android.opengl.GLSurfaceView;
|
||||
import android.os.Bundle;
|
||||
|
||||
public class PhysicalMonitorActivity extends AppCompatActivity {
|
||||
|
||||
/**
|
||||
* Hold a reference to our GLSurfaceView
|
||||
*/
|
||||
private GLSurfaceView mGLSurfaceView;
|
||||
private SensorFusion mSensorFusion;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
AlertDialog.Builder alertDialog = new AlertDialog.Builder(this, R.style.AlertDialogCustom);
|
||||
alertDialog.setTitle("Physical activity monitoring");
|
||||
alertDialog.setMessage("Apps installed on your phone can monitor the angle at which you are holding your phone, the direction in which you are holding your phone, speed at which you are moving your phone etc. using Gyroscope, Accelerometer and Magnetometer sensors without your permission." +
|
||||
"This can give them a 3D visualization of your hand & body movements. This is a huge privacy loophole.\n\nGo ahead and see how this app visualizes your movements without any permissions. Start moving your phone!");
|
||||
alertDialog.setCancelable(false);
|
||||
alertDialog.setPositiveButton("OK", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
dialogInterface.dismiss();
|
||||
}
|
||||
});
|
||||
alertDialog.show();
|
||||
|
||||
mSensorFusion = new SensorFusion(this);
|
||||
mGLSurfaceView = new GLSurfaceView(this);
|
||||
|
||||
// Check if the system supports OpenGL ES 2.0.
|
||||
final ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
|
||||
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
|
||||
final boolean supportsEs2 = configurationInfo.reqGlEsVersion >= 0x20000;
|
||||
|
||||
if (supportsEs2) {
|
||||
// Request an OpenGL ES 2.0 compatible context.
|
||||
mGLSurfaceView.setEGLContextClientVersion(2);
|
||||
|
||||
// Set the renderer to our demo renderer, defined below.
|
||||
mGLSurfaceView.setRenderer(new Renderer(mSensorFusion));
|
||||
|
||||
|
||||
//mGLSurfaceView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
|
||||
} else {
|
||||
// This is where you could create an OpenGL ES 1.x compatible
|
||||
// renderer if you wanted to support both ES 1 and ES 2.
|
||||
return;
|
||||
}
|
||||
|
||||
setContentView(mGLSurfaceView);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
// The activity must call the GL surface view's onResume() on activity onResume().
|
||||
super.onResume();
|
||||
mGLSurfaceView.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
// The activity must call the GL surface view's onPause() on activity onPause().
|
||||
super.onPause();
|
||||
mGLSurfaceView.onPause();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
package io.nandandesai.privacybreacher;
|
||||
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.app.Service;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.os.IBinder;
|
||||
|
||||
import androidx.core.app.NotificationCompat;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class PrivacyBreacherService extends Service {
|
||||
|
||||
private static final String TAG = "PrivacyBreacherService";
|
||||
|
||||
public static MutableLiveData<ArrayList<String>> eventDatabase = new MutableLiveData<>();
|
||||
|
||||
private EventReceiver eventReceiver;
|
||||
|
||||
public PrivacyBreacherService() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
startForeground(R.string.app_name, getNotification(this));
|
||||
|
||||
IntentFilter intentFilter = new IntentFilter(Intent.ACTION_SCREEN_ON);
|
||||
intentFilter.addAction(Intent.ACTION_SCREEN_OFF);
|
||||
intentFilter.addAction(Intent.ACTION_SHUTDOWN);
|
||||
intentFilter.addAction(Intent.ACTION_POWER_CONNECTED);
|
||||
intentFilter.addAction(Intent.ACTION_POWER_DISCONNECTED);
|
||||
intentFilter.addAction(Intent.ACTION_HEADSET_PLUG);
|
||||
eventReceiver = new EventReceiver();
|
||||
registerReceiver(eventReceiver, intentFilter);
|
||||
|
||||
return START_STICKY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
unregisterReceiver(eventReceiver);
|
||||
eventDatabase = null; //garbage collect that object
|
||||
}
|
||||
|
||||
public Notification getNotification(Context context) {
|
||||
|
||||
Intent mainActivityIntent = new Intent(context, MainActivity.class);
|
||||
PendingIntent pendingNotificationIntent = PendingIntent.getActivity(context, 0, mainActivityIntent, 0);
|
||||
|
||||
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
final String NOTIF_CHANNEL_ID = "privacybreacher";
|
||||
final String NOTIF_CHANNEL_NAME = "PrivacyBreacher";
|
||||
NotificationChannel channel = new NotificationChannel(NOTIF_CHANNEL_ID, NOTIF_CHANNEL_NAME, NotificationManager.IMPORTANCE_HIGH);
|
||||
notificationManager.createNotificationChannel(channel);
|
||||
|
||||
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context, NOTIF_CHANNEL_ID)
|
||||
.setContentTitle("PrivacyBreacher is running!")
|
||||
.setContentText("PrivacyBreacher is monitoring your activities.")
|
||||
.setPriority(2)
|
||||
.setDefaults(Notification.FLAG_FOREGROUND_SERVICE)
|
||||
.setSmallIcon(R.drawable.ic_stat_name)
|
||||
.setShowWhen(false)
|
||||
.setOngoing(true)
|
||||
.setContentIntent(pendingNotificationIntent);
|
||||
return notificationBuilder.build();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,460 @@
|
|||
package io.nandandesai.privacybreacher;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.FloatBuffer;
|
||||
|
||||
import javax.microedition.khronos.egl.EGLConfig;
|
||||
import javax.microedition.khronos.opengles.GL10;
|
||||
|
||||
import android.opengl.GLES20;
|
||||
import android.opengl.GLSurfaceView;
|
||||
import android.opengl.Matrix;
|
||||
import android.util.Log;
|
||||
|
||||
/**
|
||||
* This class implements our custom renderer. Note that the GL10 parameter passed in is unused for OpenGL ES 2.0
|
||||
* renderers -- the static class GLES20 is used instead.
|
||||
*/
|
||||
public class Renderer implements GLSurfaceView.Renderer {
|
||||
/**
|
||||
* Used for debug logs.
|
||||
*/
|
||||
private static final String TAG = "Renderer";
|
||||
|
||||
/**
|
||||
* Store the model matrix. This matrix is used to move models from object space (where each model can be thought
|
||||
* of being located at the center of the universe) to world space.
|
||||
*/
|
||||
private float[] mModelMatrix = new float[16];
|
||||
|
||||
/**
|
||||
* Store the view matrix. This can be thought of as our camera. This matrix transforms world space to eye space;
|
||||
* it positions things relative to our eye.
|
||||
*/
|
||||
private float[] mViewMatrix = new float[16];
|
||||
|
||||
/**
|
||||
* Store the projection matrix. This is used to project the scene onto a 2D viewport.
|
||||
*/
|
||||
private float[] mProjectionMatrix = new float[16];
|
||||
|
||||
/**
|
||||
* Allocate storage for the final combined matrix. This will be passed into the shader program.
|
||||
*/
|
||||
private float[] mMVPMatrix = new float[16];
|
||||
|
||||
/**
|
||||
* Store our model data in a float buffer.
|
||||
*/
|
||||
private final FloatBuffer mCubePositions;
|
||||
private final FloatBuffer mCubeColors;
|
||||
|
||||
/**
|
||||
* This will be used to pass in the transformation matrix.
|
||||
*/
|
||||
private int mMVPMatrixHandle;
|
||||
|
||||
/**
|
||||
* This will be used to pass in the modelview matrix.
|
||||
*/
|
||||
private int mMVMatrixHandle;
|
||||
|
||||
/**
|
||||
* This will be used to pass in model position information.
|
||||
*/
|
||||
private int mPositionHandle;
|
||||
|
||||
/**
|
||||
* This will be used to pass in model color information.
|
||||
*/
|
||||
private int mColorHandle;
|
||||
|
||||
/**
|
||||
* How many bytes per float.
|
||||
*/
|
||||
private final int mBytesPerFloat = 4;
|
||||
|
||||
/**
|
||||
* Size of the position data in elements.
|
||||
*/
|
||||
private final int mPositionDataSize = 3;
|
||||
|
||||
/**
|
||||
* Size of the color data in elements.
|
||||
*/
|
||||
private final int mColorDataSize = 4;
|
||||
|
||||
/**
|
||||
* This is a handle to our per-vertex cube shading program.
|
||||
*/
|
||||
private int mPerVertexProgramHandle;
|
||||
|
||||
private SensorFusion mSensorFusion;
|
||||
|
||||
/**
|
||||
* Initialize the model data.
|
||||
*/
|
||||
public Renderer(SensorFusion sensorFusion) {
|
||||
mSensorFusion = sensorFusion;
|
||||
|
||||
// Define points for a cube.
|
||||
|
||||
// X, Y, Z
|
||||
final float[] cubePositionData =
|
||||
{
|
||||
// In OpenGL counter-clockwise winding is default. This means that when we look at a triangle,
|
||||
// if the points are counter-clockwise we are looking at the "front". If not we are looking at
|
||||
// the back. OpenGL has an optimization where all back-facing triangles are culled, since they
|
||||
// usually represent the backside of an object and aren't visible anyways.
|
||||
|
||||
// Front face
|
||||
-1.0f, 1.0f, 1.0f,
|
||||
-1.0f, -1.0f, 1.0f,
|
||||
1.0f, 1.0f, 1.0f,
|
||||
-1.0f, -1.0f, 1.0f,
|
||||
1.0f, -1.0f, 1.0f,
|
||||
1.0f, 1.0f, 1.0f,
|
||||
|
||||
// Right face
|
||||
1.0f, 1.0f, 1.0f,
|
||||
1.0f, -1.0f, 1.0f,
|
||||
1.0f, 1.0f, -1.0f,
|
||||
1.0f, -1.0f, 1.0f,
|
||||
1.0f, -1.0f, -1.0f,
|
||||
1.0f, 1.0f, -1.0f,
|
||||
|
||||
// Back face
|
||||
1.0f, 1.0f, -1.0f,
|
||||
1.0f, -1.0f, -1.0f,
|
||||
-1.0f, 1.0f, -1.0f,
|
||||
1.0f, -1.0f, -1.0f,
|
||||
-1.0f, -1.0f, -1.0f,
|
||||
-1.0f, 1.0f, -1.0f,
|
||||
|
||||
// Left face
|
||||
-1.0f, 1.0f, -1.0f,
|
||||
-1.0f, -1.0f, -1.0f,
|
||||
-1.0f, 1.0f, 1.0f,
|
||||
-1.0f, -1.0f, -1.0f,
|
||||
-1.0f, -1.0f, 1.0f,
|
||||
-1.0f, 1.0f, 1.0f,
|
||||
|
||||
// Top face
|
||||
-1.0f, 1.0f, -1.0f,
|
||||
-1.0f, 1.0f, 1.0f,
|
||||
1.0f, 1.0f, -1.0f,
|
||||
-1.0f, 1.0f, 1.0f,
|
||||
1.0f, 1.0f, 1.0f,
|
||||
1.0f, 1.0f, -1.0f,
|
||||
|
||||
// Bottom face
|
||||
1.0f, -1.0f, -1.0f,
|
||||
1.0f, -1.0f, 1.0f,
|
||||
-1.0f, -1.0f, -1.0f,
|
||||
1.0f, -1.0f, 1.0f,
|
||||
-1.0f, -1.0f, 1.0f,
|
||||
-1.0f, -1.0f, -1.0f,
|
||||
};
|
||||
|
||||
// R, G, B, A
|
||||
final float[] cubeColorData =
|
||||
{
|
||||
// Front face (red)
|
||||
1.0f, 0.0f, 0.0f, 1.0f,
|
||||
1.0f, 0.0f, 0.0f, 1.0f,
|
||||
1.0f, 0.0f, 0.0f, 1.0f,
|
||||
1.0f, 0.0f, 0.0f, 1.0f,
|
||||
1.0f, 0.0f, 0.0f, 1.0f,
|
||||
1.0f, 0.0f, 0.0f, 1.0f,
|
||||
|
||||
// Right face (green)
|
||||
0.0f, 1.0f, 0.0f, 1.0f,
|
||||
0.0f, 1.0f, 0.0f, 1.0f,
|
||||
0.0f, 1.0f, 0.0f, 1.0f,
|
||||
0.0f, 1.0f, 0.0f, 1.0f,
|
||||
0.0f, 1.0f, 0.0f, 1.0f,
|
||||
0.0f, 1.0f, 0.0f, 1.0f,
|
||||
|
||||
// Back face (blue)
|
||||
0.0f, 0.0f, 1.0f, 1.0f,
|
||||
0.0f, 0.0f, 1.0f, 1.0f,
|
||||
0.0f, 0.0f, 1.0f, 1.0f,
|
||||
0.0f, 0.0f, 1.0f, 1.0f,
|
||||
0.0f, 0.0f, 1.0f, 1.0f,
|
||||
0.0f, 0.0f, 1.0f, 1.0f,
|
||||
|
||||
// Left face (yellow)
|
||||
1.0f, 1.0f, 0.0f, 1.0f,
|
||||
1.0f, 1.0f, 0.0f, 1.0f,
|
||||
1.0f, 1.0f, 0.0f, 1.0f,
|
||||
1.0f, 1.0f, 0.0f, 1.0f,
|
||||
1.0f, 1.0f, 0.0f, 1.0f,
|
||||
1.0f, 1.0f, 0.0f, 1.0f,
|
||||
|
||||
// Top face (cyan)
|
||||
0.0f, 1.0f, 1.0f, 1.0f,
|
||||
0.0f, 1.0f, 1.0f, 1.0f,
|
||||
0.0f, 1.0f, 1.0f, 1.0f,
|
||||
0.0f, 1.0f, 1.0f, 1.0f,
|
||||
0.0f, 1.0f, 1.0f, 1.0f,
|
||||
0.0f, 1.0f, 1.0f, 1.0f,
|
||||
|
||||
// Bottom face (magenta)
|
||||
1.0f, 0.0f, 1.0f, 1.0f,
|
||||
1.0f, 0.0f, 1.0f, 1.0f,
|
||||
1.0f, 0.0f, 1.0f, 1.0f,
|
||||
1.0f, 0.0f, 1.0f, 1.0f,
|
||||
1.0f, 0.0f, 1.0f, 1.0f,
|
||||
1.0f, 0.0f, 1.0f, 1.0f
|
||||
};
|
||||
|
||||
// Initialize the buffers.
|
||||
mCubePositions = ByteBuffer.allocateDirect(cubePositionData.length * mBytesPerFloat)
|
||||
.order(ByteOrder.nativeOrder()).asFloatBuffer();
|
||||
mCubePositions.put(cubePositionData).position(0);
|
||||
|
||||
mCubeColors = ByteBuffer.allocateDirect(cubeColorData.length * mBytesPerFloat)
|
||||
.order(ByteOrder.nativeOrder()).asFloatBuffer();
|
||||
mCubeColors.put(cubeColorData).position(0);
|
||||
}
|
||||
|
||||
private String getVertexShader() {
|
||||
final String vertexShader =
|
||||
"uniform mat4 u_MVPMatrix; \n" // A constant representing the combined model/view/projection matrix.
|
||||
+ "uniform mat4 u_MVMatrix; \n" // A constant representing the combined model/view matrix.
|
||||
|
||||
+ "attribute vec4 a_Position; \n" // Per-vertex position information we will pass in.
|
||||
+ "attribute vec4 a_Color; \n" // Per-vertex color information we will pass in.
|
||||
|
||||
+ "varying vec4 v_Color; \n" // This will be passed into the fragment shader.
|
||||
|
||||
+ "void main() \n" // The entry point for our vertex shader.
|
||||
+ "{ \n"
|
||||
// Transform the vertex into eye space.
|
||||
+ " vec3 modelViewVertex = vec3(u_MVMatrix * a_Position); \n"
|
||||
// Multiply the color by the illumination level. It will be interpolated across the triangle.
|
||||
+ " v_Color = a_Color; \n"
|
||||
// gl_Position is a special variable used to store the final position.
|
||||
// Multiply the vertex by the matrix to get the final point in normalized screen coordinates.
|
||||
+ " gl_Position = u_MVPMatrix * a_Position; \n"
|
||||
+ "} \n";
|
||||
|
||||
return vertexShader;
|
||||
}
|
||||
|
||||
private String getFragmentShader() {
|
||||
final String fragmentShader =
|
||||
"precision mediump float; \n" // Set the default precision to medium. We don't need as high of a
|
||||
// precision in the fragment shader.
|
||||
+ "varying vec4 v_Color; \n" // This is the color from the vertex shader interpolated across the
|
||||
// triangle per fragment.
|
||||
+ "void main() \n" // The entry point for our fragment shader.
|
||||
+ "{ \n"
|
||||
+ " gl_FragColor = v_Color; \n" // Pass the color directly through the pipeline.
|
||||
+ "} \n";
|
||||
|
||||
return fragmentShader;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSurfaceCreated(GL10 glUnused, EGLConfig config) {
|
||||
// Set the background clear color to black.
|
||||
GLES20.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
|
||||
// Use culling to remove back faces.
|
||||
GLES20.glEnable(GLES20.GL_CULL_FACE);
|
||||
|
||||
// Enable depth testing
|
||||
GLES20.glEnable(GLES20.GL_DEPTH_TEST);
|
||||
|
||||
// Position the eye in front of the origin.
|
||||
final float eyeX = 0.0f;
|
||||
final float eyeY = 0.0f;
|
||||
final float eyeZ = -0.5f;
|
||||
|
||||
// We are looking toward the distance
|
||||
final float lookX = 0.0f;
|
||||
final float lookY = 0.0f;
|
||||
final float lookZ = -5.0f;
|
||||
|
||||
// Set our up vector. This is where our head would be pointing were we holding the camera.
|
||||
final float upX = 0.0f;
|
||||
final float upY = 1.0f;
|
||||
final float upZ = 0.0f;
|
||||
|
||||
// Set the view matrix. This matrix can be said to represent the camera position.
|
||||
// NOTE: In OpenGL 1, a ModelView matrix is used, which is a combination of a model and
|
||||
// view matrix. In OpenGL 2, we can keep track of these matrices separately if we choose.
|
||||
Matrix.setLookAtM(mViewMatrix, 0, eyeX, eyeY, eyeZ, lookX, lookY, lookZ, upX, upY, upZ);
|
||||
|
||||
final String vertexShader = getVertexShader();
|
||||
final String fragmentShader = getFragmentShader();
|
||||
|
||||
final int vertexShaderHandle = compileShader(GLES20.GL_VERTEX_SHADER, vertexShader);
|
||||
final int fragmentShaderHandle = compileShader(GLES20.GL_FRAGMENT_SHADER, fragmentShader);
|
||||
|
||||
mPerVertexProgramHandle = createAndLinkProgram(vertexShaderHandle, fragmentShaderHandle,
|
||||
new String[]{"a_Position", "a_Color"});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSurfaceChanged(GL10 glUnused, int width, int height) {
|
||||
// Set the OpenGL viewport to the same size as the surface.
|
||||
GLES20.glViewport(0, 0, width, height);
|
||||
|
||||
// Create a new perspective projection matrix. The height will stay the same
|
||||
// while the width will vary as per aspect ratio.
|
||||
final float ratio = (float) width / height;
|
||||
final float left = -ratio;
|
||||
final float right = ratio;
|
||||
final float bottom = -1.0f;
|
||||
final float top = 1.0f;
|
||||
final float near = 1.0f;
|
||||
final float far = 10.0f;
|
||||
|
||||
Matrix.frustumM(mProjectionMatrix, 0, left, right, bottom, top, near, far);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDrawFrame(GL10 glUnused) {
|
||||
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
// Set our per-vertex lighting program.
|
||||
GLES20.glUseProgram(mPerVertexProgramHandle);
|
||||
|
||||
// Set program handles for cube drawing.
|
||||
mMVPMatrixHandle = GLES20.glGetUniformLocation(mPerVertexProgramHandle, "u_MVPMatrix");
|
||||
mMVMatrixHandle = GLES20.glGetUniformLocation(mPerVertexProgramHandle, "u_MVMatrix");
|
||||
mPositionHandle = GLES20.glGetAttribLocation(mPerVertexProgramHandle, "a_Position");
|
||||
mColorHandle = GLES20.glGetAttribLocation(mPerVertexProgramHandle, "a_Color");
|
||||
|
||||
// Draw some cubes.
|
||||
Matrix.setIdentityM(mModelMatrix, 0);
|
||||
Matrix.translateM(mModelMatrix, 0, 0.0f, 0.0f, -5.0f);
|
||||
Matrix.rotateM(mModelMatrix, 0, (float) Math.toDegrees(-mSensorFusion.fusedOrientation[1]), 1.0f, 0.0f, 0.0f); // pitch
|
||||
Matrix.rotateM(mModelMatrix, 0, (float) Math.toDegrees(mSensorFusion.fusedOrientation[2]), 0.0f, 1.0f, 0.0f); // roll
|
||||
Matrix.rotateM(mModelMatrix, 0, (float) Math.toDegrees(mSensorFusion.fusedOrientation[0]), 0.0f, 0.0f, 1.0f); // yaw
|
||||
drawCube();
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws a cube.
|
||||
*/
|
||||
private void drawCube() {
|
||||
// Pass in the position information
|
||||
mCubePositions.position(0);
|
||||
GLES20.glVertexAttribPointer(mPositionHandle, mPositionDataSize, GLES20.GL_FLOAT, false,
|
||||
0, mCubePositions);
|
||||
|
||||
GLES20.glEnableVertexAttribArray(mPositionHandle);
|
||||
|
||||
// Pass in the color information
|
||||
mCubeColors.position(0);
|
||||
GLES20.glVertexAttribPointer(mColorHandle, mColorDataSize, GLES20.GL_FLOAT, false,
|
||||
0, mCubeColors);
|
||||
|
||||
GLES20.glEnableVertexAttribArray(mColorHandle);
|
||||
|
||||
// This multiplies the view matrix by the model matrix, and stores the result in the MVP matrix
|
||||
// (which currently contains model * view).
|
||||
Matrix.multiplyMM(mMVPMatrix, 0, mViewMatrix, 0, mModelMatrix, 0);
|
||||
|
||||
// Pass in the modelview matrix.
|
||||
GLES20.glUniformMatrix4fv(mMVMatrixHandle, 1, false, mMVPMatrix, 0);
|
||||
|
||||
// This multiplies the modelview matrix by the projection matrix, and stores the result in the MVP matrix
|
||||
// (which now contains model * view * projection).
|
||||
Matrix.multiplyMM(mMVPMatrix, 0, mProjectionMatrix, 0, mMVPMatrix, 0);
|
||||
|
||||
// Pass in the combined matrix.
|
||||
GLES20.glUniformMatrix4fv(mMVPMatrixHandle, 1, false, mMVPMatrix, 0);
|
||||
|
||||
// Draw the cube.
|
||||
GLES20.glDrawArrays(GLES20.GL_TRIANGLES, 0, 36);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to compile a shader.
|
||||
*
|
||||
* @param shaderType The shader type.
|
||||
* @param shaderSource The shader source code.
|
||||
* @return An OpenGL handle to the shader.
|
||||
*/
|
||||
private int compileShader(final int shaderType, final String shaderSource) {
|
||||
int shaderHandle = GLES20.glCreateShader(shaderType);
|
||||
|
||||
if (shaderHandle != 0) {
|
||||
// Pass in the shader source.
|
||||
GLES20.glShaderSource(shaderHandle, shaderSource);
|
||||
|
||||
// Compile the shader.
|
||||
GLES20.glCompileShader(shaderHandle);
|
||||
|
||||
// Get the compilation status.
|
||||
final int[] compileStatus = new int[1];
|
||||
GLES20.glGetShaderiv(shaderHandle, GLES20.GL_COMPILE_STATUS, compileStatus, 0);
|
||||
|
||||
// If the compilation failed, delete the shader.
|
||||
if (compileStatus[0] == 0) {
|
||||
Log.e(TAG, "Error compiling shader: " + GLES20.glGetShaderInfoLog(shaderHandle));
|
||||
GLES20.glDeleteShader(shaderHandle);
|
||||
shaderHandle = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (shaderHandle == 0) {
|
||||
throw new RuntimeException("Error creating shader.");
|
||||
}
|
||||
|
||||
return shaderHandle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to compile and link a program.
|
||||
*
|
||||
* @param vertexShaderHandle An OpenGL handle to an already-compiled vertex shader.
|
||||
* @param fragmentShaderHandle An OpenGL handle to an already-compiled fragment shader.
|
||||
* @param attributes Attributes that need to be bound to the program.
|
||||
* @return An OpenGL handle to the program.
|
||||
*/
|
||||
private int createAndLinkProgram(final int vertexShaderHandle, final int fragmentShaderHandle, final String[] attributes) {
|
||||
int programHandle = GLES20.glCreateProgram();
|
||||
|
||||
if (programHandle != 0) {
|
||||
// Bind the vertex shader to the program.
|
||||
GLES20.glAttachShader(programHandle, vertexShaderHandle);
|
||||
|
||||
// Bind the fragment shader to the program.
|
||||
GLES20.glAttachShader(programHandle, fragmentShaderHandle);
|
||||
|
||||
// Bind attributes
|
||||
if (attributes != null) {
|
||||
final int size = attributes.length;
|
||||
for (int i = 0; i < size; i++) {
|
||||
GLES20.glBindAttribLocation(programHandle, i, attributes[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// Link the two shaders together into a program.
|
||||
GLES20.glLinkProgram(programHandle);
|
||||
|
||||
// Get the link status.
|
||||
final int[] linkStatus = new int[1];
|
||||
GLES20.glGetProgramiv(programHandle, GLES20.GL_LINK_STATUS, linkStatus, 0);
|
||||
|
||||
// If the link failed, delete the program.
|
||||
if (linkStatus[0] == 0) {
|
||||
Log.e(TAG, "Error compiling program: " + GLES20.glGetProgramInfoLog(programHandle));
|
||||
GLES20.glDeleteProgram(programHandle);
|
||||
programHandle = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (programHandle == 0) {
|
||||
throw new RuntimeException("Error creating program.");
|
||||
}
|
||||
|
||||
return programHandle;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,344 @@
|
|||
package io.nandandesai.privacybreacher;
|
||||
|
||||
/************************************************************************************
|
||||
* Copyright (c) 2012 Paul Lawitzki
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
|
||||
* OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
************************************************************************************/
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
import android.hardware.Sensor;
|
||||
import android.hardware.SensorEvent;
|
||||
import android.hardware.SensorEventListener;
|
||||
import android.hardware.SensorManager;
|
||||
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
public class SensorFusion implements SensorEventListener {
|
||||
|
||||
private SensorManager mSensorManager = null;
|
||||
|
||||
// angular speeds from gyro
|
||||
private float[] gyro = new float[3];
|
||||
|
||||
// rotation matrix from gyro data
|
||||
private float[] gyroMatrix = new float[9];
|
||||
|
||||
// orientation angles from gyro matrix
|
||||
private float[] gyroOrientation = new float[3];
|
||||
|
||||
// magnetic field vector
|
||||
private float[] magnet = new float[3];
|
||||
|
||||
// accelerometer vector
|
||||
private float[] accel = new float[3];
|
||||
|
||||
// orientation angles from accel and magnet
|
||||
private float[] accMagOrientation = new float[3];
|
||||
|
||||
// final orientation angles from sensor fusion
|
||||
float[] fusedOrientation = new float[3];
|
||||
|
||||
// accelerometer and magnetometer based rotation matrix
|
||||
private float[] rotationMatrix = new float[9];
|
||||
|
||||
private static final float EPSILON = 0.000000001f;
|
||||
private static final float NS2S = 1.0f / 1000000000.0f;
|
||||
private long timestamp;
|
||||
private boolean initState = true;
|
||||
|
||||
private static final int TIME_CONSTANT = 30;
|
||||
private static final float FILTER_COEFFICIENT = 0.98f;
|
||||
private Timer fuseTimer = new Timer();
|
||||
|
||||
private Context mContext;
|
||||
|
||||
SensorFusion(Context context) {
|
||||
mContext = context;
|
||||
|
||||
gyroOrientation[0] = 0.0f;
|
||||
gyroOrientation[1] = 0.0f;
|
||||
gyroOrientation[2] = 0.0f;
|
||||
|
||||
// initialise gyroMatrix with identity matrix
|
||||
gyroMatrix[0] = 1.0f;
|
||||
gyroMatrix[1] = 0.0f;
|
||||
gyroMatrix[2] = 0.0f;
|
||||
gyroMatrix[3] = 0.0f;
|
||||
gyroMatrix[4] = 1.0f;
|
||||
gyroMatrix[5] = 0.0f;
|
||||
gyroMatrix[6] = 0.0f;
|
||||
gyroMatrix[7] = 0.0f;
|
||||
gyroMatrix[8] = 1.0f;
|
||||
|
||||
// get sensorManager and initialise sensor listeners
|
||||
mSensorManager = (SensorManager) mContext.getSystemService(Context.SENSOR_SERVICE);
|
||||
initListeners();
|
||||
|
||||
// wait for one second until gyroscope and magnetometer/accelerometer
|
||||
// data is initialised then scedule the complementary filter task
|
||||
fuseTimer.scheduleAtFixedRate(new calculateFusedOrientationTask(),
|
||||
1000, TIME_CONSTANT);
|
||||
|
||||
}
|
||||
|
||||
// This function registers sensor listeners for the accelerometer, magnetometer and gyroscope.
|
||||
private void initListeners() {
|
||||
mSensorManager.registerListener(this,
|
||||
mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER),
|
||||
SensorManager.SENSOR_DELAY_FASTEST);
|
||||
|
||||
mSensorManager.registerListener(this,
|
||||
mSensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE),
|
||||
SensorManager.SENSOR_DELAY_FASTEST);
|
||||
|
||||
mSensorManager.registerListener(this,
|
||||
mSensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD),
|
||||
SensorManager.SENSOR_DELAY_FASTEST);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAccuracyChanged(Sensor sensor, int accuracy) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSensorChanged(SensorEvent event) {
|
||||
switch (event.sensor.getType()) {
|
||||
case Sensor.TYPE_ACCELEROMETER:
|
||||
// copy new accelerometer data into accel array and calculate orientation
|
||||
System.arraycopy(event.values, 0, accel, 0, 3);
|
||||
calculateAccMagOrientation();
|
||||
break;
|
||||
|
||||
case Sensor.TYPE_GYROSCOPE:
|
||||
// process gyro data
|
||||
gyroFunction(event);
|
||||
break;
|
||||
|
||||
case Sensor.TYPE_MAGNETIC_FIELD:
|
||||
// copy new magnetometer data into magnet array
|
||||
System.arraycopy(event.values, 0, magnet, 0, 3);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// calculates orientation angles from accelerometer and magnetometer output
|
||||
private void calculateAccMagOrientation() {
|
||||
if (SensorManager.getRotationMatrix(rotationMatrix, null, accel, magnet)) {
|
||||
SensorManager.getOrientation(rotationMatrix, accMagOrientation);
|
||||
}
|
||||
}
|
||||
|
||||
// This function is borrowed from the Android reference
|
||||
// at http://developer.android.com/reference/android/hardware/SensorEvent.html#values
|
||||
// It calculates a rotation vector from the gyroscope angular speed values.
|
||||
private void getRotationVectorFromGyro(float[] gyroValues,
|
||||
float[] deltaRotationVector,
|
||||
float timeFactor) {
|
||||
float[] normValues = new float[3];
|
||||
|
||||
// Calculate the angular speed of the sample
|
||||
float omegaMagnitude =
|
||||
(float) Math.sqrt(gyroValues[0] * gyroValues[0] +
|
||||
gyroValues[1] * gyroValues[1] +
|
||||
gyroValues[2] * gyroValues[2]);
|
||||
|
||||
// Normalize the rotation vector if it's big enough to get the axis
|
||||
if (omegaMagnitude > EPSILON) {
|
||||
normValues[0] = gyroValues[0] / omegaMagnitude;
|
||||
normValues[1] = gyroValues[1] / omegaMagnitude;
|
||||
normValues[2] = gyroValues[2] / omegaMagnitude;
|
||||
}
|
||||
|
||||
// Integrate around this axis with the angular speed by the timestep
|
||||
// in order to get a delta rotation from this sample over the timestep
|
||||
// We will convert this axis-angle representation of the delta rotation
|
||||
// into a quaternion before turning it into the rotation matrix.
|
||||
float thetaOverTwo = omegaMagnitude * timeFactor;
|
||||
float sinThetaOverTwo = (float) Math.sin(thetaOverTwo);
|
||||
float cosThetaOverTwo = (float) Math.cos(thetaOverTwo);
|
||||
deltaRotationVector[0] = sinThetaOverTwo * normValues[0];
|
||||
deltaRotationVector[1] = sinThetaOverTwo * normValues[1];
|
||||
deltaRotationVector[2] = sinThetaOverTwo * normValues[2];
|
||||
deltaRotationVector[3] = cosThetaOverTwo;
|
||||
}
|
||||
|
||||
// This function performs the integration of the gyroscope data.
|
||||
// It writes the gyroscope based orientation into gyroOrientation.
|
||||
private void gyroFunction(SensorEvent event) {
|
||||
// don't start until first accelerometer/magnetometer orientation has been acquired
|
||||
if (accMagOrientation == null)
|
||||
return;
|
||||
|
||||
// initialisation of the gyroscope based rotation matrix
|
||||
if (initState) {
|
||||
float[] initMatrix = new float[9];
|
||||
initMatrix = getRotationMatrixFromOrientation(accMagOrientation);
|
||||
float[] test = new float[3];
|
||||
SensorManager.getOrientation(initMatrix, test);
|
||||
gyroMatrix = matrixMultiplication(gyroMatrix, initMatrix);
|
||||
initState = false;
|
||||
}
|
||||
|
||||
// copy the new gyro values into the gyro array
|
||||
// convert the raw gyro data into a rotation vector
|
||||
float[] deltaVector = new float[4];
|
||||
if (timestamp != 0) {
|
||||
final float dT = (event.timestamp - timestamp) * NS2S;
|
||||
System.arraycopy(event.values, 0, gyro, 0, 3);
|
||||
getRotationVectorFromGyro(gyro, deltaVector, dT / 2.0f);
|
||||
}
|
||||
|
||||
// measurement done, save current time for next interval
|
||||
timestamp = event.timestamp;
|
||||
|
||||
// convert rotation vector into rotation matrix
|
||||
float[] deltaMatrix = new float[9];
|
||||
SensorManager.getRotationMatrixFromVector(deltaMatrix, deltaVector);
|
||||
|
||||
// apply the new rotation interval on the gyroscope based rotation matrix
|
||||
gyroMatrix = matrixMultiplication(gyroMatrix, deltaMatrix);
|
||||
|
||||
// get the gyroscope based orientation from the rotation matrix
|
||||
SensorManager.getOrientation(gyroMatrix, gyroOrientation);
|
||||
}
|
||||
|
||||
private float[] getRotationMatrixFromOrientation(float[] o) {
|
||||
float[] xM = new float[9];
|
||||
float[] yM = new float[9];
|
||||
float[] zM = new float[9];
|
||||
|
||||
float sinX = (float) Math.sin(o[1]);
|
||||
float cosX = (float) Math.cos(o[1]);
|
||||
float sinY = (float) Math.sin(o[2]);
|
||||
float cosY = (float) Math.cos(o[2]);
|
||||
float sinZ = (float) Math.sin(o[0]);
|
||||
float cosZ = (float) Math.cos(o[0]);
|
||||
|
||||
// rotation about x-axis (pitch)
|
||||
xM[0] = 1.0f;
|
||||
xM[1] = 0.0f;
|
||||
xM[2] = 0.0f;
|
||||
xM[3] = 0.0f;
|
||||
xM[4] = cosX;
|
||||
xM[5] = sinX;
|
||||
xM[6] = 0.0f;
|
||||
xM[7] = -sinX;
|
||||
xM[8] = cosX;
|
||||
|
||||
// rotation about y-axis (roll)
|
||||
yM[0] = cosY;
|
||||
yM[1] = 0.0f;
|
||||
yM[2] = sinY;
|
||||
yM[3] = 0.0f;
|
||||
yM[4] = 1.0f;
|
||||
yM[5] = 0.0f;
|
||||
yM[6] = -sinY;
|
||||
yM[7] = 0.0f;
|
||||
yM[8] = cosY;
|
||||
|
||||
// rotation about z-axis (azimuth)
|
||||
zM[0] = cosZ;
|
||||
zM[1] = sinZ;
|
||||
zM[2] = 0.0f;
|
||||
zM[3] = -sinZ;
|
||||
zM[4] = cosZ;
|
||||
zM[5] = 0.0f;
|
||||
zM[6] = 0.0f;
|
||||
zM[7] = 0.0f;
|
||||
zM[8] = 1.0f;
|
||||
|
||||
// rotation order is y, x, z (roll, pitch, azimuth)
|
||||
float[] resultMatrix = matrixMultiplication(xM, yM);
|
||||
resultMatrix = matrixMultiplication(zM, resultMatrix);
|
||||
return resultMatrix;
|
||||
}
|
||||
|
||||
private float[] matrixMultiplication(float[] A, float[] B) {
|
||||
float[] result = new float[9];
|
||||
|
||||
result[0] = A[0] * B[0] + A[1] * B[3] + A[2] * B[6];
|
||||
result[1] = A[0] * B[1] + A[1] * B[4] + A[2] * B[7];
|
||||
result[2] = A[0] * B[2] + A[1] * B[5] + A[2] * B[8];
|
||||
|
||||
result[3] = A[3] * B[0] + A[4] * B[3] + A[5] * B[6];
|
||||
result[4] = A[3] * B[1] + A[4] * B[4] + A[5] * B[7];
|
||||
result[5] = A[3] * B[2] + A[4] * B[5] + A[5] * B[8];
|
||||
|
||||
result[6] = A[6] * B[0] + A[7] * B[3] + A[8] * B[6];
|
||||
result[7] = A[6] * B[1] + A[7] * B[4] + A[8] * B[7];
|
||||
result[8] = A[6] * B[2] + A[7] * B[5] + A[8] * B[8];
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
class calculateFusedOrientationTask extends TimerTask {
|
||||
public void run() {
|
||||
float oneMinusCoeff = 1.0f - FILTER_COEFFICIENT;
|
||||
|
||||
/*
|
||||
* Fix for 179<EFBFBD> <--> -179<EFBFBD> transition problem:
|
||||
* Check whether one of the two orientation angles (gyro or accMag) is negative while the other one is positive.
|
||||
* If so, add 360<EFBFBD> (2 * math.PI) to the negative value, perform the sensor fusion, and remove the 360<EFBFBD> from the result
|
||||
* if it is greater than 180<EFBFBD>. This stabilizes the output in positive-to-negative-transition cases.
|
||||
*/
|
||||
|
||||
// azimuth
|
||||
if (gyroOrientation[0] < -0.5 * Math.PI && accMagOrientation[0] > 0.0) {
|
||||
fusedOrientation[0] = (float) (FILTER_COEFFICIENT * (gyroOrientation[0] + 2.0 * Math.PI) + oneMinusCoeff * accMagOrientation[0]);
|
||||
fusedOrientation[0] -= (fusedOrientation[0] > Math.PI) ? 2.0 * Math.PI : 0;
|
||||
} else if (accMagOrientation[0] < -0.5 * Math.PI && gyroOrientation[0] > 0.0) {
|
||||
fusedOrientation[0] = (float) (FILTER_COEFFICIENT * gyroOrientation[0] + oneMinusCoeff * (accMagOrientation[0] + 2.0 * Math.PI));
|
||||
fusedOrientation[0] -= (fusedOrientation[0] > Math.PI) ? 2.0 * Math.PI : 0;
|
||||
} else {
|
||||
fusedOrientation[0] = FILTER_COEFFICIENT * gyroOrientation[0] + oneMinusCoeff * accMagOrientation[0];
|
||||
}
|
||||
|
||||
// pitch
|
||||
if (gyroOrientation[1] < -0.5 * Math.PI && accMagOrientation[1] > 0.0) {
|
||||
fusedOrientation[1] = (float) (FILTER_COEFFICIENT * (gyroOrientation[1] + 2.0 * Math.PI) + oneMinusCoeff * accMagOrientation[1]);
|
||||
fusedOrientation[1] -= (fusedOrientation[1] > Math.PI) ? 2.0 * Math.PI : 0;
|
||||
} else if (accMagOrientation[1] < -0.5 * Math.PI && gyroOrientation[1] > 0.0) {
|
||||
fusedOrientation[1] = (float) (FILTER_COEFFICIENT * gyroOrientation[1] + oneMinusCoeff * (accMagOrientation[1] + 2.0 * Math.PI));
|
||||
fusedOrientation[1] -= (fusedOrientation[1] > Math.PI) ? 2.0 * Math.PI : 0;
|
||||
} else {
|
||||
fusedOrientation[1] = FILTER_COEFFICIENT * gyroOrientation[1] + oneMinusCoeff * accMagOrientation[1];
|
||||
}
|
||||
|
||||
// roll
|
||||
if (gyroOrientation[2] < -0.5 * Math.PI && accMagOrientation[2] > 0.0) {
|
||||
fusedOrientation[2] = (float) (FILTER_COEFFICIENT * (gyroOrientation[2] + 2.0 * Math.PI) + oneMinusCoeff * accMagOrientation[2]);
|
||||
fusedOrientation[2] -= (fusedOrientation[2] > Math.PI) ? 2.0 * Math.PI : 0;
|
||||
} else if (accMagOrientation[2] < -0.5 * Math.PI && gyroOrientation[2] > 0.0) {
|
||||
fusedOrientation[2] = (float) (FILTER_COEFFICIENT * gyroOrientation[2] + oneMinusCoeff * (accMagOrientation[2] + 2.0 * Math.PI));
|
||||
fusedOrientation[2] -= (fusedOrientation[2] > Math.PI) ? 2.0 * Math.PI : 0;
|
||||
} else {
|
||||
fusedOrientation[2] = FILTER_COEFFICIENT * gyroOrientation[2] + oneMinusCoeff * accMagOrientation[2];
|
||||
}
|
||||
|
||||
// overwrite gyro matrix and orientation with fused orientation
|
||||
// to comensate gyro drift
|
||||
gyroMatrix = getRotationMatrixFromOrientation(fusedOrientation);
|
||||
System.arraycopy(fusedOrientation, 0, gyroOrientation, 0, 3);
|
||||
}
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 452 B |
After Width: | Height: | Size: 306 B |
|
@ -0,0 +1,34 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:aapt="http://schemas.android.com/aapt"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path
|
||||
android:fillType="evenOdd"
|
||||
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
|
||||
android:strokeWidth="1"
|
||||
android:strokeColor="#00000000">
|
||||
<aapt:attr name="android:fillColor">
|
||||
<gradient
|
||||
android:endX="78.5885"
|
||||
android:endY="90.9159"
|
||||
android:startX="48.7653"
|
||||
android:startY="61.0927"
|
||||
android:type="linear">
|
||||
<item
|
||||
android:color="#44000000"
|
||||
android:offset="0.0" />
|
||||
<item
|
||||
android:color="#00000000"
|
||||
android:offset="1.0" />
|
||||
</gradient>
|
||||
</aapt:attr>
|
||||
</path>
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:fillType="nonZero"
|
||||
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
|
||||
android:strokeWidth="1"
|
||||
android:strokeColor="#00000000" />
|
||||
</vector>
|
After Width: | Height: | Size: 614 B |
After Width: | Height: | Size: 984 B |
After Width: | Height: | Size: 1.4 KiB |
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle" >
|
||||
|
||||
<solid android:color="@color/white" />
|
||||
|
||||
<padding android:left="5dp"
|
||||
android:right="5dp"/>
|
||||
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="@color/colorPrimary" />
|
||||
<corners
|
||||
android:radius="12dp"/>
|
||||
|
||||
|
||||
</shape>
|
After Width: | Height: | Size: 42 KiB |
|
@ -0,0 +1,170 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path
|
||||
android:fillColor="#008577"
|
||||
android:pathData="M0,0h108v108h-108z" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M9,0L9,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,0L19,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M29,0L29,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M39,0L39,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M49,0L49,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M59,0L59,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M69,0L69,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M79,0L79,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M89,0L89,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M99,0L99,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,9L108,9"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,19L108,19"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,29L108,29"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,39L108,39"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,49L108,49"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,59L108,59"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,69L108,69"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,79L108,79"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,89L108,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,99L108,99"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,29L89,29"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,39L89,39"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,49L89,49"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,59L89,59"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,69L89,69"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,79L89,79"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M29,19L29,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M39,19L39,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M49,19L49,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M59,19L59,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M69,19L69,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M79,19L79,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
</vector>
|
After Width: | Height: | Size: 63 KiB |
|
@ -0,0 +1,174 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
tools:context=".AboutActivity">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:isScrollContainer="true">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/aboutContent"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="10dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/databurnLogo"
|
||||
android:layout_width="82dp"
|
||||
android:layout_height="102dp"
|
||||
android:layout_centerInParent="true"
|
||||
android:src="@drawable/databurn_logo"></ImageView>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/databurnLogo"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:paddingTop="25dp"
|
||||
android:text="DataBurn"
|
||||
android:textColor="@color/colorPrimaryDark"
|
||||
android:textStyle="bold" />
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="20dp"
|
||||
android:paddingTop="10dp"
|
||||
android:paddingRight="20dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:text="This app was originally developed by Nandan Desai. It is a proof-of-concept for a research work done on privacy issues in Android operating system. This app is released as Open Source Software. Please visit DataBurn\'s Github repository to see the source code and it's related license."
|
||||
android:textColor="@color/colorPrimaryDark" />
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="20dp"
|
||||
android:paddingTop="10dp"
|
||||
android:paddingRight="20dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:text="This app requests only 1 permission and that is FOREGROUND_SERVICE. It is used to start a foreground service of this app and you can notice that in the notifications. It is for illustration only and that permission is granted by Android implicitly when you install this app. This app doesn't store or send any information it collects. You can verify that yourself by auditing the source code of this app from Github. More details on our official website."
|
||||
android:textColor="@color/colorPrimaryDark" />
|
||||
</RelativeLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingStart="40dp"
|
||||
android:paddingTop="20dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Website"
|
||||
android:textColor="@color/colorPrimaryDark"
|
||||
android:textSize="18sp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:autoLink="web"
|
||||
android:text="https://databurn.in" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingStart="40dp"
|
||||
android:paddingTop="20dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Blog"
|
||||
android:textColor="@color/colorPrimaryDark"
|
||||
android:textSize="18sp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:autoLink="web"
|
||||
android:text="https://blog.databurn.in" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingStart="40dp"
|
||||
android:paddingTop="20dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Github"
|
||||
android:textColor="@color/colorPrimaryDark"
|
||||
android:textSize="18sp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:autoLink="web"
|
||||
android:text="https://github.com/databurn-in" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingStart="40dp"
|
||||
android:paddingTop="20dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Developer's Github"
|
||||
android:textColor="@color/colorPrimaryDark"
|
||||
android:textSize="18sp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:autoLink="web"
|
||||
android:text="https://github.com/NandanDesai" />
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:padding="10dp"
|
||||
android:layout_marginTop="30dp"
|
||||
android:layout_below="@id/aboutContent"
|
||||
android:text="This is a DataBurn project" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</ScrollView>
|
|
@ -0,0 +1,95 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/white"
|
||||
android:orientation="vertical"
|
||||
tools:context=".MainActivity">
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/optionsButton"
|
||||
style="@style/actionOverflowButtonStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:orientation="vertical">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="10dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/logo"
|
||||
android:layout_width="92dp"
|
||||
android:layout_height="112dp"
|
||||
android:layout_centerInParent="true"
|
||||
android:src="@drawable/privacy_breacher"></ImageView>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/logo"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:text="PrivacyBreacher"
|
||||
android:textColor="@color/colorPrimaryDark" />
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="10dp">
|
||||
|
||||
<Button
|
||||
android:id="@+id/physicalMonitorButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:background="@drawable/active_button"
|
||||
android:text="Physical Activity Monitor" />
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="10dp">
|
||||
|
||||
<Button
|
||||
android:id="@+id/phoneMonitorButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:background="@drawable/active_button"
|
||||
android:text="Phone Activity Monitor" />
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="10dp">
|
||||
|
||||
<Button
|
||||
android:id="@+id/phoneInfoButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:background="@drawable/active_button"
|
||||
android:text="Phone Information" />
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:padding="10dp"
|
||||
android:text="This is a DataBurn project" />
|
||||
</RelativeLayout>
|
|
@ -0,0 +1,289 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:padding="20dp"
|
||||
tools:context=".PhoneInfoActivity">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/phoneInfoView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:fontFamily="sans-serif-light"
|
||||
android:text="Here is all your phone information this app can see without permissions."
|
||||
android:textColor="@color/colorPrimaryDark"
|
||||
android:textSize="20sp" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingStart="40dp"
|
||||
android:paddingTop="20dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Product"
|
||||
android:textColor="@color/colorPrimary"
|
||||
android:textSize="24sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/product"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingStart="40dp"
|
||||
android:paddingTop="20dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Model"
|
||||
android:textColor="@color/colorPrimary"
|
||||
android:textSize="24sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/model"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingStart="40dp"
|
||||
android:paddingTop="20dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Manufacturer"
|
||||
android:textColor="@color/colorPrimary"
|
||||
android:textSize="24sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/manufacturer"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingStart="40dp"
|
||||
android:paddingTop="20dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Manufactured On"
|
||||
android:textColor="@color/colorPrimary"
|
||||
android:textSize="24sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/manufacturedOn"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingStart="40dp"
|
||||
android:paddingTop="20dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Brand"
|
||||
android:textColor="@color/colorPrimary"
|
||||
android:textSize="24sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/brand"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingStart="40dp"
|
||||
android:paddingTop="20dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Device"
|
||||
android:textColor="@color/colorPrimary"
|
||||
android:textSize="24sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/device"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingStart="40dp"
|
||||
android:paddingTop="20dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Device Uptime"
|
||||
android:textColor="@color/colorPrimary"
|
||||
android:textSize="24sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/deviceUptime"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingStart="40dp"
|
||||
android:paddingTop="20dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Mobile data used "
|
||||
android:textColor="@color/colorPrimary"
|
||||
android:textSize="24sp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="(since boot)"
|
||||
android:textColor="@color/colorPrimary" />
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/mobileDataUsed"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingStart="40dp"
|
||||
android:paddingTop="20dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Wifi data used "
|
||||
android:textColor="@color/colorPrimary"
|
||||
android:textSize="24sp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="(since boot)"
|
||||
android:textColor="@color/colorPrimary" />
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/wifiDataUsed"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:fontFamily="sans-serif-light"
|
||||
android:paddingTop="20dp"
|
||||
android:text="Here is a list of all apps installed on your phone. No permission is needed for this."
|
||||
android:textColor="@color/colorPrimaryDark"
|
||||
android:textSize="20sp" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/appListRecyclerView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="20dp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progressBar"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:indeterminate="true"
|
||||
android:indeterminateTint="@color/colorPrimary"
|
||||
android:indeterminateTintMode="src_atop" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</ScrollView>
|
|
@ -0,0 +1,42 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".PhoneMonitorActivity">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="20dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/headingText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:text="You can view the activity logs like when you have turned ON/OFF your screen, when you are charging, how you are charging etc." />
|
||||
</RelativeLayout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/phoneLogRecyclerView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="20dp" />
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/noLogText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:padding="20dp"
|
||||
android:text="No logs found😟. Minimize this app and start using your phone to see the logs." />
|
||||
|
||||
</RelativeLayout>
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".PhysicalMonitorActivity">
|
||||
|
||||
</RelativeLayout>
|
|
@ -0,0 +1,34 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/app_list_item"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:paddingTop="2dp"
|
||||
android:paddingBottom="2dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/appIconImage"
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="50dp"
|
||||
android:layout_marginTop="3dp"
|
||||
android:padding="5dp"
|
||||
android:src="@mipmap/ic_launcher" />
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_toEndOf="@id/appIconImage">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/appName"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="App Name"
|
||||
android:textSize="16sp" />
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
</RelativeLayout>
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/phoneMonitorLogItem"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</RelativeLayout>
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<item
|
||||
android:id="@+id/menu_about"
|
||||
android:orderInCategory="1"
|
||||
android:title="About"
|
||||
app:showAsAction="never" />
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_exit"
|
||||
android:orderInCategory="2"
|
||||
android:title="Exit"
|
||||
app:showAsAction="never" />
|
||||
</menu>
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@color/ic_launcher_background"/>
|
||||
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
|
||||
</adaptive-icon>
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@color/ic_launcher_background"/>
|
||||
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
|
||||
</adaptive-icon>
|
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 8.8 KiB |
After Width: | Height: | Size: 5.9 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 4.7 KiB |
After Width: | Height: | Size: 3.3 KiB |
After Width: | Height: | Size: 6.0 KiB |
After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 8.9 KiB |
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 16 KiB |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 48 KiB |
After Width: | Height: | Size: 25 KiB |
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="colorPrimary">#ff9800</color>
|
||||
<color name="colorPrimaryDark">#000000</color>
|
||||
<color name="colorAccent">#ff9800</color>
|
||||
<color name="white">#ffffff</color>
|
||||
</resources>
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="ic_launcher_background">#000000</color>
|
||||
</resources>
|
|
@ -0,0 +1,3 @@
|
|||
<resources>
|
||||
<string name="app_name">PrivacyBreacher</string>
|
||||
</resources>
|
|
@ -0,0 +1,19 @@
|
|||
<resources>
|
||||
|
||||
<!-- Base application theme. -->
|
||||
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
|
||||
<!-- Customize your theme here. -->
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
</style>
|
||||
|
||||
<style name="AlertDialogCustom" parent="Theme.AppCompat.Light.Dialog.Alert">
|
||||
<item name="android:textColor">@color/colorPrimaryDark</item>
|
||||
</style>
|
||||
|
||||
<style name="actionOverflowButtonStyle" parent="@style/Widget.AppCompat.ActionButton.Overflow">
|
||||
<item name="android:tint">@color/colorPrimaryDark</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
|
@ -0,0 +1,17 @@
|
|||
package io.nandandesai.privacybreacher;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Example local unit test, which will execute on the development machine (host).
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
public class ExampleUnitTest {
|
||||
@Test
|
||||
public void addition_isCorrect() {
|
||||
assertEquals(4, 2 + 2);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.5.0'
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
task clean(type: Delete) {
|
||||
delete rootProject.buildDir
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
# Project-wide Gradle settings.
|
||||
# IDE (e.g. Android Studio) users:
|
||||
# Gradle settings configured through the IDE *will override*
|
||||
# any settings specified in this file.
|
||||
# For more details on how to configure your build environment visit
|
||||
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||
# Specifies the JVM arguments used for the daemon process.
|
||||
# The setting is particularly useful for tweaking memory settings.
|
||||
org.gradle.jvmargs=-Xmx1536m
|
||||
# When configured, Gradle will run in incubating parallel mode.
|
||||
# This option should only be used with decoupled projects. More details, visit
|
||||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||
# org.gradle.parallel=true
|
||||
# AndroidX package structure to make it clearer which packages are bundled with the
|
||||
# Android operating system, and which are packaged with your app's APK
|
||||
# https://developer.android.com/topic/libraries/support-library/androidx-rn
|
||||
android.useAndroidX=true
|
||||
# Automatically convert third-party libraries to use AndroidX
|
||||
android.enableJetifier=true
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
#Tue Mar 24 13:10:58 IST 2020
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
|
|
@ -0,0 +1,172 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS=""
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
NONSTOP* )
|
||||
nonstop=true
|
||||
;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=$((i+1))
|
||||
done
|
||||
case $i in
|
||||
(0) set -- ;;
|
||||
(1) set -- "$args0" ;;
|
||||
(2) set -- "$args0" "$args1" ;;
|
||||
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Escape application args
|
||||
save () {
|
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
APP_ARGS=$(save "$@")
|
||||
|
||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||
|
||||
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
|
||||
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
|
||||
cd "$(dirname "$0")"
|
||||
fi
|
||||
|
||||
exec "$JAVACMD" "$@"
|
|
@ -0,0 +1,84 @@
|
|||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS=
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windows variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
|
@ -0,0 +1,2 @@
|
|||
include ':app'
|
||||
rootProject.name='PrivacyBreacher'
|