[automerger skipped] Merge spl-2020-12-05 skipped: 62d023df13
Change-Id: I90a38018139625d47a5fc982ca365a7306ea47d3
diff --git a/Android.bp b/Android.bp
index cffb421..ce65ffd 100644
--- a/Android.bp
+++ b/Android.bp
@@ -3,7 +3,10 @@
android_app {
name: "Stk",
libs: ["telephony-common"],
- static_libs: ["com.google.android.material_material"],
+ static_libs: [
+ "com.google.android.material_material",
+ "androidx.legacy_legacy-support-core-utils",
+ ],
srcs: ["**/*.java"],
platform_apis: true,
certificate: "platform",
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 063e042..81ba3d8 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -26,6 +26,7 @@
<uses-permission android:name="android.permission.REAL_GET_TASKS"/>
<uses-permission android:name="android.permission.RECEIVE_STK_COMMANDS" />
<uses-permission android:name="android.permission.SET_ACTIVITY_WATCHER" />
+ <uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
<uses-permission android:name="android.permission.START_ACTIVITIES_FROM_BACKGROUND" />
<uses-permission android:name="android.permission.USER_ACTIVITY" />
<uses-permission android:name="android.permission.VIBRATE" />
@@ -109,7 +110,8 @@
android:taskAffinity="android.task.stk.StkLauncherActivity">
</activity>
- <receiver android:name="com.android.stk.StkCmdReceiver">
+ <receiver android:name="com.android.stk.StkCmdReceiver"
+ android:exported="true">
<intent-filter>
<action android:name= "com.android.internal.stk.command" />
<action android:name= "com.android.internal.stk.session_end" />
@@ -118,7 +120,8 @@
</intent-filter>
</receiver>
- <receiver android:name="com.android.stk.BootCompletedReceiver">
+ <receiver android:name="com.android.stk.BootCompletedReceiver"
+ android:exported="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.USER_INITIALIZE" />
diff --git a/MODULE_LICENSE_APACHE2 b/MODULE_LICENSE_APACHE2
deleted file mode 100644
index e69de29..0000000
--- a/MODULE_LICENSE_APACHE2
+++ /dev/null
diff --git a/src/com/android/stk/StkAppService.java b/src/com/android/stk/StkAppService.java
index 9606a78..4552ea1 100644
--- a/src/com/android/stk/StkAppService.java
+++ b/src/com/android/stk/StkAppService.java
@@ -24,7 +24,7 @@
import android.app.ActivityManager;
import android.app.ActivityManager.RunningTaskInfo;
import android.app.AlertDialog;
-import android.app.HomeVisibilityObserver;
+import android.app.HomeVisibilityListener;
import android.app.KeyguardManager;
import android.app.Notification;
import android.app.NotificationChannel;
@@ -171,7 +171,7 @@
private AppInterface[] mStkService = null;
private StkContext[] mStkContext = null;
private int mSimCount = 0;
- private HomeVisibilityObserver mHomeVisibilityObserver = null;
+ private HomeVisibilityListener mHomeVisibilityListener = null;
private BroadcastReceiver mLocaleChangeReceiver = null;
private TonePlayer mTonePlayer = null;
private Vibrator mVibrator = null;
@@ -1860,8 +1860,8 @@
}
private synchronized void registerHomeVisibilityObserver() {
- if (mHomeVisibilityObserver == null) {
- mHomeVisibilityObserver = new HomeVisibilityObserver() {
+ if (mHomeVisibilityListener == null) {
+ mHomeVisibilityListener = new HomeVisibilityListener() {
@Override
public void onHomeVisibilityChanged(boolean isHomeActivityVisible) {
if (isHomeActivityVisible) {
@@ -1872,7 +1872,7 @@
}
};
ActivityManager am = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
- am.registerHomeVisibilityObserver(mHomeVisibilityObserver);
+ am.addHomeVisibilityListener(Runnable::run, mHomeVisibilityListener);
CatLog.d(LOG_TAG, "Started to observe the foreground activity");
}
}
@@ -1904,11 +1904,11 @@
}
private synchronized void unregisterHomeVisibilityObserver() {
- if (mHomeVisibilityObserver != null) {
+ if (mHomeVisibilityListener != null) {
ActivityManager am = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
- am.unregisterHomeVisibilityObserver(mHomeVisibilityObserver);
+ am.removeHomeVisibilityListener(mHomeVisibilityListener);
CatLog.d(LOG_TAG, "Stopped to observe the foreground activity");
- mHomeVisibilityObserver = null;
+ mHomeVisibilityListener = null;
}
}
@@ -2336,6 +2336,10 @@
}
}
+ boolean isNoTonePlaying() {
+ return mTonePlayer == null ? true : false;
+ }
+
private void launchOpenChannelDialog(final int slotId) {
TextMessage msg = mStkContext[slotId].mCurrentCmd.geTextMessage();
if (msg == null) {
diff --git a/src/com/android/stk/ToneDialog.java b/src/com/android/stk/ToneDialog.java
index 5ce50bf..4f67b06 100644
--- a/src/com/android/stk/ToneDialog.java
+++ b/src/com/android/stk/ToneDialog.java
@@ -118,6 +118,12 @@
mAlertDialog = alertDialogBuilder.create();
mAlertDialog.show();
+
+ StkAppService appService = StkAppService.getInstance();
+ // Finish the activity if the specified duration is too short and timed-out already.
+ if (appService != null && (appService.isNoTonePlaying())) {
+ finish();
+ }
}
@Override