Skip to content

Commit

Permalink
Merge pull request #30 from SimpleAppProjects/develop
Browse files Browse the repository at this point in the history
v1.13.1
  • Loading branch information
thewizrd authored Sep 24, 2023
2 parents b4fba34 + b068509 commit 679ed40
Show file tree
Hide file tree
Showing 57 changed files with 1,920 additions and 481 deletions.
14 changes: 9 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@
buildscript {
ext {
compileSdkVersion = 34
minSdkVersion = 23
minSdkVersion = 24
targetSdkVersion = 33

kotlin_version = '1.9.0'
kotlinx_version = '1.7.3'

desugar_version = '2.0.3'

firebase_version = '32.2.3'
firebase_version = '32.3.1'

appcompat_version = '1.6.1'
constraintlayout_version = '2.1.4'
core_version = '1.10.1'
core_version = '1.12.0'
fragment_version = '1.6.1'
lifecycle_version = '2.6.1'
lifecycle_version = '2.6.2'
preference_version = '1.2.1'
recyclerview_version = '1.3.1'
coresplash_version = '1.0.0'
Expand All @@ -33,13 +33,17 @@ buildscript {
material_version = '1.9.0'

compose_compiler_version = '1.5.2'
compose_version = '1.5.0'
compose_version = '1.5.1'
wear_compose_version = '1.2.0'
horologist_version = '0.4.12'
accompanist_version = '0.30.1'

gson_version = '2.10.1'
timber_version = '5.0.1'

// Shizuku
shizuku_version = '13.1.5'
refine_version = '4.3.0'
}

repositories {
Expand Down
1 change: 1 addition & 0 deletions hidden-api/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
43 changes: 43 additions & 0 deletions hidden-api/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
plugins {
id 'com.android.library'
id 'org.jetbrains.kotlin.android'
}

android {
compileSdk rootProject.compileSdkVersion

defaultConfig {
minSdkVersion rootProject.minSdkVersion
targetSdkVersion rootProject.targetSdkVersion

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
}

buildTypes {
debug {
minifyEnabled false
}
release {
minifyEnabled true
}
}

compileOptions {
// Sets Java compatibility to Java 8
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}

kotlin {
jvmToolchain(17)
}

namespace 'com.thewizrd.wearsettings.hidden_api'
}

dependencies {
annotationProcessor 'dev.rikka.tools.refine:annotation-processor:4.3.0'
compileOnly 'dev.rikka.tools.refine:annotation:4.3.0'
implementation 'androidx.annotation:annotation:1.7.0'
}
Empty file added hidden-api/consumer-rules.pro
Empty file.
21 changes: 21 additions & 0 deletions hidden-api/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

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

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

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
2 changes: 2 additions & 0 deletions hidden-api/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest />
23 changes: 23 additions & 0 deletions hidden-api/src/main/java/android/net/wifi/IWifiManager.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package android.net.wifi;

import android.os.Binder;
import android.os.Build;
import android.os.IBinder;
import android.os.IInterface;

import androidx.annotation.DeprecatedSinceApi;
import androidx.annotation.RequiresApi;

public interface IWifiManager extends IInterface {
@DeprecatedSinceApi(api = Build.VERSION_CODES.N_MR1)
boolean setWifiEnabled(boolean enable);

@RequiresApi(api = Build.VERSION_CODES.N_MR1)
boolean setWifiEnabled(String packageName, boolean enable);

abstract class Stub extends Binder implements IWifiManager {
public static IWifiManager asInterface(IBinder obj) {
throw new RuntimeException("Stub!");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package com.android.internal.telephony;

import android.os.Binder;
import android.os.Build;
import android.os.IBinder;
import android.os.IInterface;

import androidx.annotation.DeprecatedSinceApi;
import androidx.annotation.RequiresApi;

public interface ITelephony extends IInterface {
@DeprecatedSinceApi(api = Build.VERSION_CODES.P)
void setDataEnabled(int subId, boolean enable);

@DeprecatedSinceApi(api = Build.VERSION_CODES.P)
boolean getDataEnabled(int subId);

@RequiresApi(api = Build.VERSION_CODES.P)
@DeprecatedSinceApi(api = Build.VERSION_CODES.S)
void setUserDataEnabled(int subId, boolean enable);

@RequiresApi(api = Build.VERSION_CODES.P)
@DeprecatedSinceApi(api = Build.VERSION_CODES.S)
boolean isUserDataEnabled(int subId);

@RequiresApi(api = Build.VERSION_CODES.S)
@DeprecatedSinceApi(api = Build.VERSION_CODES.TIRAMISU)
void setDataEnabledForReason(int subId, int reason, boolean enable);

@RequiresApi(api = Build.VERSION_CODES.S)
boolean isDataEnabledForReason(int subId, int reason);

@RequiresApi(api = Build.VERSION_CODES.TIRAMISU)
void setDataEnabledForReason(int subId, int reason, boolean enable, String callingPackage);

@DeprecatedSinceApi(api = Build.VERSION_CODES.TIRAMISU)
boolean enableDataConnectivity();

@DeprecatedSinceApi(api = Build.VERSION_CODES.TIRAMISU)
boolean disableDataConnectivity();

@RequiresApi(api = Build.VERSION_CODES.TIRAMISU)
boolean enableDataConnectivity(String callingPackage);

@RequiresApi(api = Build.VERSION_CODES.TIRAMISU)
boolean disableDataConnectivity(String callingPackage);

abstract class Stub extends Binder implements ITelephony {
public static ITelephony asInterface(IBinder obj) {
throw new RuntimeException("Stub!");
}
}
}
6 changes: 3 additions & 3 deletions mobile/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ android {
minSdkVersion rootProject.minSdkVersion
targetSdkVersion rootProject.targetSdkVersion
// NOTE: Version Code Format [TargetSDK, Version Name, Build Number, Variant Code (Android: 00, WearOS: 01)]
versionCode 331913000
versionName "1.13.0"
versionCode 331913100
versionName "1.13.1"

vectorDrawables.useSupportLibrary = true
}
Expand Down Expand Up @@ -89,7 +89,7 @@ dependencies {
implementation "androidx.work:work-runtime-ktx:$work_version"
implementation "androidx.core:core-splashscreen:$coresplash_version"

implementation 'com.google.android.gms:play-services-wearable:18.0.0'
implementation 'com.google.android.gms:play-services-wearable:18.1.0'

implementation platform("com.google.firebase:firebase-bom:$firebase_version")
implementation 'com.google.firebase:firebase-analytics'
Expand Down
26 changes: 24 additions & 2 deletions mobile/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,20 @@
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_CAMERA" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_PHONE_CALL" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission
android:name="android.permission.BLUETOOTH"
android:maxSdkVersion="30" />
<uses-permission
android:name="android.permission.BLUETOOTH_ADMIN"
android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.ACCESS_NOTIFICATION_POLICY" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<!-- For background activity starts -->
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />

<uses-permission
android:name="android.permission.WRITE_SETTINGS"
Expand Down Expand Up @@ -79,6 +85,22 @@
</intent-filter>
</activity>

<activity
android:name=".wearable.RemoteLaunchActivity"
android:theme="@android:style/Theme.NoDisplay"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<data
android:scheme="simplewear"
android:host="launch-activity" />
</intent-filter>
</activity>

<service
android:name=".wearable.WearableDataListenerService"
android:enabled="true"
Expand Down
57 changes: 27 additions & 30 deletions mobile/src/main/java/com/thewizrd/simplewear/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,19 @@ import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.content.pm.PackageManager
import android.database.ContentObserver
import android.location.LocationManager
import android.media.AudioManager
import android.net.*
import android.net.Uri
import android.net.wifi.WifiManager
import android.os.BatteryManager
import android.os.Build
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.provider.Settings
import android.telephony.TelephonyManager
import android.util.Log
import androidx.work.Configuration
import com.google.android.material.color.DynamicColors
Expand All @@ -33,6 +36,7 @@ import com.thewizrd.shared_resources.utils.JSONParser
import com.thewizrd.shared_resources.utils.Logger
import com.thewizrd.simplewear.media.MediaControllerService
import com.thewizrd.simplewear.services.CallControllerService
import com.thewizrd.simplewear.telephony.SubscriptionListener
import com.thewizrd.simplewear.wearable.WearableWorker
import kotlin.system.exitProcess

Expand Down Expand Up @@ -149,41 +153,34 @@ class App : Application(), ApplicationLib, ActivityLifecycleCallbacks, Configura
}
appContext.registerReceiver(mActionsReceiver, actionsFilter)

// Register listener system settings
val setting = Settings.Global.getUriFor("mobile_data")
mContentObserver = object : ContentObserver(Handler(Looper.getMainLooper())) {
override fun onChange(selfChange: Boolean, uri: Uri?) {
super.onChange(selfChange, uri)
if (uri.toString().contains("mobile_data")) {
WearableWorker.sendActionUpdate(appContext, Actions.MOBILEDATA)
runCatching {
if (appContext.packageManager.hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) {
// Register listener for mobile data setting (default sim)
val setting = Settings.Global.getUriFor("mobile_data")
mContentObserver = object : ContentObserver(Handler(Looper.getMainLooper())) {
override fun onChange(selfChange: Boolean, uri: Uri?) {
super.onChange(selfChange, uri)
if (uri.toString().contains("mobile_data")) {
WearableWorker.sendActionUpdate(appContext, Actions.MOBILEDATA)
}
}
}
}
}
contentResolver.registerContentObserver(setting, false, mContentObserver)
contentResolver.registerContentObserver(setting, false, mContentObserver)

// Register connectivity listener
runCatching {
val connMgr = appContext.getSystemService(ConnectivityManager::class.java)
connMgr.registerNetworkCallback(
NetworkRequest.Builder()
.addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR)
.build(),
object : ConnectivityManager.NetworkCallback() {
override fun onAvailable(network: Network) {
super.onAvailable(network)
WearableWorker.sendActionUpdate(appContext, Actions.MOBILEDATA)
if (appContext.packageManager.hasSystemFeature(PackageManager.FEATURE_TELEPHONY_SUBSCRIPTION)) {
val telephonyManager = appContext.getSystemService(TelephonyManager::class.java)

val modemCount = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
telephonyManager.supportedModemCount
} else {
telephonyManager.phoneCount
}

override fun onUnavailable() {
super.onUnavailable()
WearableWorker.sendActionUpdate(appContext, Actions.MOBILEDATA)
if (modemCount > 1) {
SubscriptionListener.registerListener(appContext)
}
}
)
}.onFailure {
// SecurityException: Package android does not belong to xxxxx
// https://issuetracker.google.com/issues/175055271
Logger.writeLine(Log.ERROR, it)
}
}

val oldHandler = Thread.getDefaultUncaughtExceptionHandler()
Expand Down
Loading

0 comments on commit 679ed40

Please sign in to comment.