Skip to content

Commit

Permalink
Add android.permission.QUERY_ALL_PACKAGES (Android v11)
Browse files Browse the repository at this point in the history
+ small fixes
  • Loading branch information
Kaljurand committed Jul 21, 2020
1 parent 2897e4c commit 715908d
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 15 deletions.
11 changes: 7 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ android {
applicationId 'ee.ioc.phon.android.speak'
minSdkVersion 16
targetSdkVersion 30
versionCode 1733
versionName '1.7.33'
versionCode 1734
versionName '1.7.34'
vectorDrawables.useSupportLibrary = true
// Keep only en and et resources
resConfigs "en", "et"
Expand Down Expand Up @@ -85,6 +85,7 @@ if (project.hasProperty('storePassword') &&
android.signingConfigs.release.storePassword = storePassword
android.signingConfigs.release.keyPassword = keyPassword
} else {
println "WARNING: The release will not be signed"
android.buildTypes.release.signingConfig = null
}

Expand All @@ -97,11 +98,13 @@ task deploy {

def version = android.defaultConfig.versionName

def name = 'K6nele'

def outputs = 'build/outputs/'
def apk1 = outputs + 'apk/release/app-release.apk'
def apk2 = "${deploy_dir}K6nele-${version}.apk"
def apk2 = "${deploy_dir}${name}-${version}.apk"
def mapping1 = outputs + 'mapping/release/mapping.txt'
def mapping2 = "${deploy_dir}K6nele-mapping-${version}.txt"
def mapping2 = "${deploy_dir}${name}-mapping-${version}.txt"

exec {
commandLine 'cp', '--verbose', apk1, apk2
Expand Down
7 changes: 3 additions & 4 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,13 @@
<uses-permission android:name="android.permission.ACCESS_NOTIFICATION_POLICY" />

<!-- TODO: try to avoid having to request this permission.
We query packages for 2 reasons:
Android v11. We query packages for 3 reasons:
1) finding speech recognizer providers (this query is declared below in the queries-section)
2) listing apps (with icon and launch intent) that have previously launched Kõnele
It is unclear if the latter use-case can be declared via the queries-section.
3) launching intents (e.g. setting the alarm or opening maps) via rewrites
It is unclear if use-cases 2 and 3 could be instead declared via the queries-section.
-->
<!--
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
-->

<!-- Custom permission required by GetPutPreferenceActivity to be able to read/write the Kõnele settings. -->
<!--
Expand Down
15 changes: 11 additions & 4 deletions app/src/main/java/ee/ioc/phon/android/speak/model/RecService.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ServiceInfo;
import android.graphics.drawable.Drawable;
import android.util.Pair;
Expand All @@ -22,17 +23,23 @@ public class RecService {
private final ComponentName mComponentName;

public RecService(Context context, String id) {
String mDesc1 = "";
// Can return <null, "">
Pair<ComponentName, String> pair = RecognitionServiceManager.unflattenFromString(id);
mComponentName = pair.first;

mLabel = RecognitionServiceManager.getServiceLabel(context, mComponentName);
ServiceInfo si = RecognitionServiceManager.getServiceInfo(context, mComponentName);
int resId = si.descriptionRes;
if (resId == 0) {
mDesc = "";
} else {
mDesc = context.getString(si.descriptionRes);
if (resId != 0) {
try {
PackageManager manager = context.getPackageManager();
mDesc1 = manager.getResourcesForApplication(mComponentName.getPackageName()).getString(resId);
} catch (PackageManager.NameNotFoundException e) {
// Should not happen
}
}
mDesc = mDesc1;
try {
mSettingsActivity = RecognitionServiceManager.getSettingsActivity(context, si);
Log.i(mSettingsActivity);
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/ee/ioc/phon/android/speak/utils/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public static String idToValue(Context context, Uri contentUri, String columnId,
* is Theme.Translucent.NoTitleBar then the dialog is unstyled (maybe an Android bug?)
*/
public static AlertDialog getLaunchIntentDialog(final AppCompatActivity activity, String msg, final Intent intent) {
return new AlertDialog.Builder(activity, android.R.style.Theme_DeviceDefault_Dialog)
return new AlertDialog.Builder(activity, R.style.Theme_K6nele_Dialog)
.setPositiveButton(activity.getString(R.string.buttonGoToSettings), (dialog, id) -> {
activity.startActivity(intent);
activity.finish();
Expand All @@ -127,7 +127,7 @@ public static AlertDialog getYesNoDialog(Context context, String confirmationMes
}

public static AlertDialog getYesNoDialog(Context context, String confirmationMessage, final Executable ex1, final Executable ex2) {
AlertDialog.Builder builder = new AlertDialog.Builder(context, android.R.style.Theme_DeviceDefault_Dialog);
AlertDialog.Builder builder = new AlertDialog.Builder(context, R.style.Theme_K6nele_Dialog);
builder
.setMessage(confirmationMessage)
.setCancelable(false)
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.0'
classpath 'com.android.tools.build:gradle:4.0.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand Down

0 comments on commit 715908d

Please sign in to comment.