Compare commits

..

5 commits

Author SHA1 Message Date
7ca33edd26 Use ACTION_PROVISIONING_SUCCESSFUL instead of ACTION_PROFILE_PROVISIONING_COMPLETE
On Android 8.0+, the activity intent ACTION_PROVISIONING_SUCCESSFUL is
also sent out before the broadcast
ACTION_PROFILE_PROVISIONING_COMPLETE. We can make of use this to
directly bring up an activity for finalization, skipping over our
original notification-based switch-er-oo from the broadcast receiver.

This is also necessary on platform release T since now we cannot send
notifications by default. We cannot request for the permission either
since that will require a visible activity too. Using the activity
intent works around all of this and makes Shelter work again on T. (And
we won't have to deal with the Do-Not-Disturb nonsense anymore)
2022-08-26 21:02:13 -04:00
030b9837dc gradle: Bump target SDK to 33 (T) 2022-08-26 17:02:25 -04:00
a2677d9f9d gradle: Bring back jcenter just for time-duration-picker 2022-08-26 16:56:03 -04:00
95e5ae2fa8 chore: Upgrade dependencies
Not necessarily working yet.
2022-08-26 16:53:23 -04:00
593d8103f2 chore: Upgrade build tool dependencies
And move to mavenCentral instead of jcenter
2022-08-26 16:47:51 -04:00
7 changed files with 66 additions and 26 deletions

View file

@ -1,12 +1,21 @@
apply plugin: 'com.android.application'
repositories {
//noinspection JcenterRepositoryObsolete
jcenter {
content {
includeVersion "mobi.upod", "time-duration-picker", "1.1.3"
}
}
}
android {
compileSdkVersion 31
buildToolsVersion '30.0.3'
compileSdkVersion 33
buildToolsVersion '33.0.0'
defaultConfig {
applicationId "net.typeblog.shelter"
minSdkVersion 24
targetSdkVersion 31
targetSdkVersion 33
versionCode 20
versionName "1.7"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
@ -22,28 +31,20 @@ android {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
lintOptions {
// We have community-contributed translations. Do not let them block releases.
disable 'MissingTranslation'
disable 'ExtraTranslation'
// We don't need Google App Indexing
disable 'GoogleAppIndexingWarning'
// Some dependencies still pull in Fragment 1.2.x
// Let's just ignore the error for now
// We don't really hit the broken use-cases for now
disable 'InvalidFragmentVersionForActivityResult'
lint {
disable 'MissingTranslation', 'ExtraTranslation', 'GoogleAppIndexingWarning', 'InvalidFragmentVersionForActivityResult'
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.legacy:legacy-support-core-ui:1.0.0'
implementation 'androidx.fragment:fragment:1.3.6'
implementation 'androidx.appcompat:appcompat:1.4.0-rc01'
implementation 'androidx.preference:preference:1.1.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0'
implementation 'androidx.fragment:fragment:1.5.2'
implementation 'androidx.appcompat:appcompat:1.6.0-beta01'
implementation 'androidx.preference:preference:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.1.0'
implementation 'mobi.upod:time-duration-picker:1.1.3'
debugImplementation project(path: ':setup-wizard-lib', configuration: 'gingerbreadCompatDebugRuntimeElements')
releaseImplementation project(path: ':setup-wizard-lib', configuration: 'gingerbreadCompatReleaseRuntimeElements')

View file

@ -84,6 +84,20 @@
</intent-filter>
</activity>
<!-- An activity to listen to ACTION_PROVISIONING_SUCCESSFUL for finalization -->
<!-- This replaces the functionality of ShelterDeviceAdminReceiver on Oreo and above -->
<activity android:name=".ui.FinalizeActivity"
android:excludeFromRecents="true"
android:launchMode="singleTask"
android:theme="@style/Theme.AppCompat.Translucent.NoTitleBar"
android:permission="android.permission.BIND_DEVICE_ADMIN"
android:exported="true">
<intent-filter>
<action android:name="android.app.action.PROVISIONING_SUCCESSFUL" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<!-- Activity to forward ACTION_IMAGE_CAPTURE as ACTION_OPEN_DOCUMENT -->
<activity android:name=".ui.CameraProxyActivity"
android:excludeFromRecents="true"

View file

@ -6,6 +6,7 @@ import android.app.PendingIntent;
import android.app.admin.DeviceAdminReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import net.typeblog.shelter.R;
import net.typeblog.shelter.ui.DummyActivity;
@ -17,8 +18,13 @@ public class ShelterDeviceAdminReceiver extends DeviceAdminReceiver {
@Override
public void onProfileProvisioningComplete(Context context, Intent intent) {
super.onProfileProvisioningComplete(context, intent);
// I don't know why setting the policies in this receiver won't work very well
// Anyway, we delegate it to the DummyActivity
// After Oreo, we use the activity intent ACTION_PROVISIONING_SUCCESSFUL for finalization
// As it is an activity intent, it is way more reliable (and less hacky) than doing
// it in a BroadcastReceiver
// This is handled by FinalizeActivity, and thus we should ignore the event here
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) return;
// Complex logic in a BroadcastReceiver is not reliable
// Delegate finalization to the DummyActivity
Intent i = new Intent(context.getApplicationContext(), DummyActivity.class);
i.setAction(DummyActivity.FINALIZE_PROVISION);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

View file

@ -0,0 +1,19 @@
package net.typeblog.shelter.ui;
import android.content.Intent;
import android.os.Bundle;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
public class FinalizeActivity extends AppCompatActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent i = new Intent(getApplicationContext(), DummyActivity.class);
i.setAction(DummyActivity.FINALIZE_PROVISION);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
finish();
}
}

View file

@ -334,6 +334,7 @@ public class SetupWizardActivity extends AppCompatActivity {
public void onNavigateNext() {
super.onNavigateNext();
mActivity.switchToFragment(new PleaseWaitFragment(), false);
mActivity.setupProfile();
}
@Override
@ -357,7 +358,6 @@ public class SetupWizardActivity extends AppCompatActivity {
@Override
public void onAttach(@NonNull Context context) {
super.onAttach(context);
mActivity.setupProfile();
}
@Override

View file

@ -4,10 +4,10 @@ buildscript {
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.0.3'
classpath 'com.android.tools.build:gradle:7.2.2'
// NOTE: Do not place your application dependencies here; they belong
@ -18,7 +18,7 @@ buildscript {
allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}

View file

@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip