Skip to content

Commit d3ff644

Browse files
committed
Added stage now profiles
0 parents  commit d3ff644

Some content is hidden

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

43 files changed

+913
-0
lines changed

.gitignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/caches
5+
/.idea/libraries
6+
/.idea/modules.xml
7+
/.idea/workspace.xml
8+
/.idea/navEditor.xml
9+
/.idea/assetWizardSettings.xml
10+
.DS_Store
11+
/build
12+
/captures
13+
.externalNativeBuild
14+
.cxx
15+
local.properties
16+
.idea/

AppOverLockScreenTest/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
plugins {
2+
alias(libs.plugins.android.application)
3+
}
4+
5+
android {
6+
namespace = "com.zebra.appoverlockscreentest"
7+
compileSdk = 36
8+
9+
defaultConfig {
10+
applicationId = "com.zebra.appoverlockscreentest"
11+
minSdk = 32
12+
targetSdk = 36
13+
versionCode = 1
14+
versionName = "1.0"
15+
16+
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
17+
}
18+
19+
buildTypes {
20+
release {
21+
isMinifyEnabled = false
22+
proguardFiles(
23+
getDefaultProguardFile("proguard-android-optimize.txt"),
24+
"proguard-rules.pro"
25+
)
26+
}
27+
}
28+
compileOptions {
29+
sourceCompatibility = JavaVersion.VERSION_11
30+
targetCompatibility = JavaVersion.VERSION_11
31+
}
32+
}
33+
34+
dependencies {
35+
36+
implementation(libs.appcompat)
37+
implementation(libs.material)
38+
implementation(libs.activity)
39+
implementation(libs.constraintlayout)
40+
testImplementation(libs.junit)
41+
androidTestImplementation(libs.ext.junit)
42+
androidTestImplementation(libs.espresso.core)
43+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.zebra.appoverlockscreentest;
2+
3+
import android.content.Context;
4+
5+
import androidx.test.platform.app.InstrumentationRegistry;
6+
import androidx.test.ext.junit.runners.AndroidJUnit4;
7+
8+
import org.junit.Test;
9+
import org.junit.runner.RunWith;
10+
11+
import static org.junit.Assert.*;
12+
13+
/**
14+
* Instrumented test, which will execute on an Android device.
15+
*
16+
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
17+
*/
18+
@RunWith(AndroidJUnit4.class)
19+
public class ExampleInstrumentedTest {
20+
@Test
21+
public void useAppContext() {
22+
// Context of the app under test.
23+
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
24+
assertEquals("com.zebra.appoverlockscreentest", appContext.getPackageName());
25+
}
26+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools">
4+
5+
<application
6+
android:allowBackup="true"
7+
android:dataExtractionRules="@xml/data_extraction_rules"
8+
android:fullBackupContent="@xml/backup_rules"
9+
android:icon="@mipmap/ic_launcher"
10+
android:label="@string/app_name"
11+
android:roundIcon="@mipmap/ic_launcher_round"
12+
android:supportsRtl="true"
13+
android:theme="@style/Theme.AppOverLockScreenTest">
14+
<activity
15+
android:name=".MainActivity"
16+
android:exported="true">
17+
<intent-filter>
18+
<action android:name="android.intent.action.MAIN" />
19+
20+
<category android:name="android.intent.category.LAUNCHER" />
21+
</intent-filter>
22+
</activity>
23+
24+
<service
25+
android:name=".KeyPressAccessibilityService"
26+
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE"
27+
android:exported="true">
28+
<intent-filter>
29+
<action android:name="android.accessibilityservice.AccessibilityService" />
30+
</intent-filter>
31+
<meta-data
32+
android:name="android.accessibilityservice"
33+
android:resource="@xml/accessibility_service_config" />
34+
</service>
35+
</application>
36+
37+
</manifest>
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package com.zebra.appoverlockscreentest;
2+
3+
import android.accessibilityservice.AccessibilityService;
4+
import android.content.Intent;
5+
import android.util.Log;
6+
import android.view.KeyEvent;
7+
import android.view.accessibility.AccessibilityEvent;
8+
9+
public class KeyPressAccessibilityService extends AccessibilityService {
10+
11+
private static final String TAG = "KeyPressAccessibility";
12+
private static final int TARGET_KEY_CODE = 102;
13+
14+
@Override
15+
public void onAccessibilityEvent(AccessibilityEvent event) {
16+
// This method is called for accessibility events, but key events are handled in onKeyEvent
17+
}
18+
19+
@Override
20+
public void onInterrupt() {
21+
Log.d(TAG, "Service interrupted");
22+
}
23+
24+
@Override
25+
protected boolean onKeyEvent(KeyEvent event) {
26+
if (event.getAction() == KeyEvent.ACTION_DOWN) {
27+
int keyCode = event.getKeyCode();
28+
Log.d(TAG, "Key pressed: " + KeyEvent.keyCodeToString(keyCode) + " (keyCode: " + keyCode + ")");
29+
30+
if (keyCode == TARGET_KEY_CODE) {
31+
Log.d(TAG, "Target key code " + TARGET_KEY_CODE + " detected! Opening MainActivity");
32+
openMainActivity();
33+
return true;
34+
}
35+
}
36+
return super.onKeyEvent(event);
37+
}
38+
39+
private void openMainActivity() {
40+
Intent intent = new Intent(this, MainActivity.class);
41+
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
42+
startActivity(intent);
43+
}
44+
45+
@Override
46+
public void onServiceConnected() {
47+
super.onServiceConnected();
48+
Log.d(TAG, "KeyPressAccessibilityService connected");
49+
}
50+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package com.zebra.appoverlockscreentest;
2+
3+
import android.os.Build;
4+
import android.os.Bundle;
5+
import android.util.Log;
6+
import android.view.KeyEvent;
7+
import android.view.WindowManager;
8+
9+
import androidx.activity.EdgeToEdge;
10+
import androidx.appcompat.app.AppCompatActivity;
11+
import androidx.core.graphics.Insets;
12+
import androidx.core.view.ViewCompat;
13+
import androidx.core.view.WindowInsetsCompat;
14+
15+
public class MainActivity extends AppCompatActivity {
16+
17+
private static final String TAG = "MainActivity";
18+
19+
@Override
20+
protected void onCreate(Bundle savedInstanceState) {
21+
super.onCreate(savedInstanceState);
22+
23+
// Set flags to show the activity over the lock screen and turn the screen on
24+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
25+
// Android 8.1 (API 27) and higher use dedicated methods
26+
27+
// This method replaces the deprecated FLAG_SHOW_WHEN_LOCKED window flag
28+
setShowWhenLocked(true);
29+
30+
// This method replaces the deprecated FLAG_TURN_SCREEN_ON window flag
31+
setTurnScreenOn(true);
32+
} else {
33+
// Fallback for older APIs (though Zebra devices usually run newer enterprise OS)
34+
getWindow().addFlags(
35+
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
36+
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
37+
);
38+
}
39+
40+
EdgeToEdge.enable(this);
41+
setContentView(R.layout.activity_main);
42+
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
43+
Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
44+
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
45+
return insets;
46+
});
47+
}
48+
49+
@Override
50+
public boolean onKeyDown(int keyCode, KeyEvent event) {
51+
Log.d(TAG, "Key pressed: " + KeyEvent.keyCodeToString(keyCode) + " (keyCode: " + keyCode + ")");
52+
return super.onKeyDown(keyCode, event);
53+
}
54+
}

0 commit comments

Comments
 (0)