diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/stk/StkAppInstaller.java | 1 | ||||
-rw-r--r-- | src/com/android/stk/StkAppService.java | 129 |
2 files changed, 54 insertions, 76 deletions
diff --git a/src/com/android/stk/StkAppInstaller.java b/src/com/android/stk/StkAppInstaller.java index 50bc96e..4e386ee 100644 --- a/src/com/android/stk/StkAppInstaller.java +++ b/src/com/android/stk/StkAppInstaller.java @@ -18,7 +18,6 @@ package com.android.stk; import com.android.internal.telephony.cat.CatLog; import com.android.internal.telephony.PhoneConstants; -import com.android.internal.telephony.TelephonyProperties; import android.content.ComponentName; import android.content.Context; diff --git a/src/com/android/stk/StkAppService.java b/src/com/android/stk/StkAppService.java index 4a254ed..87e4607 100644 --- a/src/com/android/stk/StkAppService.java +++ b/src/com/android/stk/StkAppService.java @@ -16,26 +16,28 @@ package com.android.stk; +import static com.android.internal.telephony.cat.CatCmdMessage.SetupEventListConstants.IDLE_SCREEN_AVAILABLE_EVENT; +import static com.android.internal.telephony.cat.CatCmdMessage.SetupEventListConstants.LANGUAGE_SELECTION_EVENT; +import static com.android.internal.telephony.cat.CatCmdMessage.SetupEventListConstants.USER_ACTIVITY_EVENT; + +import android.app.Activity; import android.app.ActivityManager; import android.app.ActivityManager.RunningTaskInfo; import android.app.AlertDialog; +import android.app.HomeVisibilityObserver; import android.app.KeyguardManager; import android.app.Notification; import android.app.NotificationChannel; import android.app.NotificationManager; import android.app.PendingIntent; import android.app.Service; -import android.app.Activity; -import android.app.ActivityManagerNative; -import android.app.IProcessObserver; import android.content.BroadcastReceiver; -import android.content.ComponentName; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; +import android.content.IntentFilter; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; -import android.content.res.Configuration; import android.content.res.Resources; import android.content.res.Resources.NotFoundException; import android.graphics.Bitmap; @@ -50,58 +52,47 @@ import android.os.Parcel; import android.os.PersistableBundle; import android.os.PowerManager; import android.os.RemoteException; -import android.os.ServiceManager; import android.os.SystemProperties; import android.os.Vibrator; import android.provider.Settings; import android.telephony.CarrierConfigManager; import android.telephony.SubscriptionInfo; import android.telephony.SubscriptionManager; +import android.telephony.TelephonyFrameworkInitializer; import android.telephony.TelephonyManager; import android.text.TextUtils; import android.view.Gravity; -import android.view.IWindowManager; import android.view.LayoutInflater; import android.view.View; import android.view.WindowManager; -import android.view.WindowManagerPolicyConstants; import android.widget.ImageView; import android.widget.TextView; import android.widget.Toast; -import android.content.IntentFilter; import androidx.localbroadcastmanager.content.LocalBroadcastManager; +import com.android.internal.telephony.GsmAlphabet; +import com.android.internal.telephony.ITelephony; import com.android.internal.telephony.PhoneConfigurationManager; +import com.android.internal.telephony.PhoneConstants; +import com.android.internal.telephony.TelephonyIntents; import com.android.internal.telephony.cat.AppInterface; -import com.android.internal.telephony.cat.Input; -import com.android.internal.telephony.cat.LaunchBrowserMode; -import com.android.internal.telephony.cat.Menu; -import com.android.internal.telephony.cat.Item; -import com.android.internal.telephony.cat.ResultCode; import com.android.internal.telephony.cat.CatCmdMessage; import com.android.internal.telephony.cat.CatCmdMessage.BrowserSettings; import com.android.internal.telephony.cat.CatCmdMessage.SetupEventListSettings; import com.android.internal.telephony.cat.CatLog; import com.android.internal.telephony.cat.CatResponseMessage; +import com.android.internal.telephony.cat.CatService; +import com.android.internal.telephony.cat.Input; +import com.android.internal.telephony.cat.Item; +import com.android.internal.telephony.cat.Menu; +import com.android.internal.telephony.cat.ResultCode; import com.android.internal.telephony.cat.TextMessage; import com.android.internal.telephony.cat.ToneSettings; import com.android.internal.telephony.uicc.IccRefreshResponse; -import com.android.internal.telephony.PhoneConstants; -import com.android.internal.telephony.GsmAlphabet; -import com.android.internal.telephony.cat.CatService; -import java.util.Iterator; import java.util.LinkedList; import java.util.List; -import java.util.regex.Pattern; - -import static com.android.internal.telephony.cat.CatCmdMessage. - SetupEventListConstants.IDLE_SCREEN_AVAILABLE_EVENT; -import static com.android.internal.telephony.cat.CatCmdMessage. - SetupEventListConstants.LANGUAGE_SELECTION_EVENT; -import static com.android.internal.telephony.cat.CatCmdMessage. - SetupEventListConstants.USER_ACTIVITY_EVENT; /** * SIM toolkit application level service. Interacts with Telephopny messages, @@ -180,7 +171,7 @@ public class StkAppService extends Service implements Runnable { private AppInterface[] mStkService = null; private StkContext[] mStkContext = null; private int mSimCount = 0; - private IProcessObserver.Stub mProcessObserver = null; + private HomeVisibilityObserver mHomeVisibilityObserver = null; private BroadcastReceiver mLocaleChangeReceiver = null; private TonePlayer mTonePlayer = null; private Vibrator mVibrator = null; @@ -411,7 +402,7 @@ public class StkAppService extends Service implements Runnable { public void onDestroy() { CatLog.d(LOG_TAG, "onDestroy()"); unregisterUserActivityReceiver(); - unregisterProcessObserver(); + unregisterHomeVisibilityObserver(); unregisterLocaleChangeReceiver(); unregisterHomeKeyEventReceiver(); sInstance = null; @@ -1173,7 +1164,7 @@ public class StkAppService extends Service implements Runnable { CatLog.d(LOG_TAG, "set up idle mode"); launchIdleText(slotId); } else { - registerProcessObserver(); + registerHomeVisibilityObserver(); } } break; @@ -1788,7 +1779,7 @@ public class StkAppService extends Service implements Runnable { unregisterUserActivityReceiver(); break; case IDLE_SCREEN_AVAILABLE_EVENT: - unregisterProcessObserver(AppInterface.CommandType.SET_UP_EVENT_LIST, slotId); + unregisterHomeVisibilityObserver(AppInterface.CommandType.SET_UP_EVENT_LIST, slotId); break; case LANGUAGE_SELECTION_EVENT: unregisterLocaleChangeReceiver(); @@ -1808,7 +1799,7 @@ public class StkAppService extends Service implements Runnable { registerUserActivityReceiver(); break; case IDLE_SCREEN_AVAILABLE_EVENT: - registerProcessObserver(); + registerHomeVisibilityObserver(); break; case LANGUAGE_SELECTION_EVENT: registerLocaleChangeReceiver(); @@ -1823,7 +1814,7 @@ public class StkAppService extends Service implements Runnable { if (mUserActivityReceiver == null) { mUserActivityReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { - if (WindowManagerPolicyConstants.ACTION_USER_ACTIVITY_NOTIFICATION.equals( + if (TelephonyIntents.ACTION_USER_ACTIVITY_NOTIFICATION.equals( intent.getAction())) { Message message = mServiceHandler.obtainMessage(OP_USER_ACTIVITY); mServiceHandler.sendMessage(message); @@ -1832,11 +1823,14 @@ public class StkAppService extends Service implements Runnable { } }; registerReceiver(mUserActivityReceiver, new IntentFilter( - WindowManagerPolicyConstants.ACTION_USER_ACTIVITY_NOTIFICATION)); + TelephonyIntents.ACTION_USER_ACTIVITY_NOTIFICATION)); try { - IWindowManager wm = IWindowManager.Stub.asInterface( - ServiceManager.getService(Context.WINDOW_SERVICE)); - wm.requestUserActivityNotification(); + ITelephony telephony = ITelephony.Stub.asInterface( + TelephonyFrameworkInitializer + .getTelephonyServiceManager() + .getTelephonyServiceRegisterer() + .get()); + telephony.requestUserActivityNotification(); } catch (RemoteException e) { CatLog.e(LOG_TAG, "failed to init WindowManager:" + e); } @@ -1850,37 +1844,25 @@ public class StkAppService extends Service implements Runnable { } } - private synchronized void registerProcessObserver() { - if (mProcessObserver == null) { - try { - IProcessObserver.Stub observer = new IProcessObserver.Stub() { - @Override - public void onForegroundActivitiesChanged(int pid, int uid, boolean fg) { - if (isScreenIdle()) { - Message message = mServiceHandler.obtainMessage(OP_IDLE_SCREEN); - mServiceHandler.sendMessage(message); - unregisterProcessObserver(); - } - } - - @Override - public void onForegroundServicesChanged(int pid, int uid, int fgServiceTypes) { - } - - @Override - public void onProcessDied(int pid, int uid) { + private synchronized void registerHomeVisibilityObserver() { + if (mHomeVisibilityObserver == null) { + mHomeVisibilityObserver = new HomeVisibilityObserver() { + @Override + public void onHomeVisibilityChanged(boolean isHomeActivityVisible) { + if (isHomeActivityVisible) { + Message message = mServiceHandler.obtainMessage(OP_IDLE_SCREEN); + mServiceHandler.sendMessage(message); + unregisterHomeVisibilityObserver(); } - }; - ActivityManagerNative.getDefault().registerProcessObserver(observer); - CatLog.d(LOG_TAG, "Started to observe the foreground activity"); - mProcessObserver = observer; - } catch (RemoteException e) { - CatLog.e(LOG_TAG, "Failed to register the process observer"); - } + } + }; + ActivityManager am = (ActivityManager) getSystemService(ACTIVITY_SERVICE); + am.registerHomeVisibilityObserver(mHomeVisibilityObserver); + CatLog.d(LOG_TAG, "Started to observe the foreground activity"); } } - private void unregisterProcessObserver(AppInterface.CommandType command, int slotId) { + private void unregisterHomeVisibilityObserver(AppInterface.CommandType command, int slotId) { // Check if there is any pending command which still needs the process observer // except for the current command and slot. for (int slot = 0; slot < mSimCount; slot++) { @@ -1903,18 +1885,15 @@ public class StkAppService extends Service implements Runnable { } } } - unregisterProcessObserver(); + unregisterHomeVisibilityObserver(); } - private synchronized void unregisterProcessObserver() { - if (mProcessObserver != null) { - try { - ActivityManagerNative.getDefault().unregisterProcessObserver(mProcessObserver); - CatLog.d(LOG_TAG, "Stopped to observe the foreground activity"); - mProcessObserver = null; - } catch (RemoteException e) { - CatLog.d(LOG_TAG, "Failed to unregister the process observer"); - } + private synchronized void unregisterHomeVisibilityObserver() { + if (mHomeVisibilityObserver != null) { + ActivityManager am = (ActivityManager) getSystemService(ACTIVITY_SERVICE); + am.unregisterHomeVisibilityObserver(mHomeVisibilityObserver); + CatLog.d(LOG_TAG, "Stopped to observe the foreground activity"); + mHomeVisibilityObserver = null; } } @@ -2021,7 +2000,7 @@ public class StkAppService extends Service implements Runnable { case IDLE_SCREEN_AVAILABLE_EVENT: // The process observer can be unregistered // as the idle screen has already been available. - unregisterProcessObserver(); + unregisterHomeVisibilityObserver(); break; default: break; @@ -2144,7 +2123,7 @@ public class StkAppService extends Service implements Runnable { } private void cancelIdleText(int slotId) { - unregisterProcessObserver(AppInterface.CommandType.SET_UP_IDLE_MODE_TEXT, slotId); + unregisterHomeVisibilityObserver(AppInterface.CommandType.SET_UP_IDLE_MODE_TEXT, slotId); mNotificationManager.cancel(getNotificationId(slotId)); mStkContext[slotId].mIdleModeTextCmd = null; mStkContext[slotId].mIdleModeTextVisible = false; |