@@ -189,6 +189,22 @@ public void onSomePackagesChanged() {
189189 }
190190 }
191191
192+ @ Override
193+ public void onPackageRemoved (String packageName , int uid ) {
194+ synchronized (mLock ) {
195+ Iterator <ComponentName > it = mEnabledServices .iterator ();
196+ while (it .hasNext ()) {
197+ ComponentName comp = it .next ();
198+ String compPkg = comp .getPackageName ();
199+ if (compPkg .equals (packageName )) {
200+ it .remove ();
201+ updateEnabledAccessibilitySerivcesSettingLocked (mEnabledServices );
202+ return ;
203+ }
204+ }
205+ }
206+ }
207+
192208 @ Override
193209 public boolean onHandleForceStop (Intent intent , String [] packages ,
194210 int uid , boolean doit ) {
@@ -209,18 +225,7 @@ public boolean onHandleForceStop(Intent intent, String[] packages,
209225 }
210226 }
211227 if (changed ) {
212- it = mEnabledServices .iterator ();
213- StringBuilder str = new StringBuilder ();
214- while (it .hasNext ()) {
215- if (str .length () > 0 ) {
216- str .append (':' );
217- }
218- str .append (it .next ().flattenToShortString ());
219- }
220- Settings .Secure .putString (mContext .getContentResolver (),
221- Settings .Secure .ENABLED_ACCESSIBILITY_SERVICES ,
222- str .toString ());
223- manageServicesLocked ();
228+ updateEnabledAccessibilitySerivcesSettingLocked (mEnabledServices );
224229 }
225230 return false ;
226231 }
@@ -252,6 +257,21 @@ public void onReceive(Context context, Intent intent) {
252257
253258 super .onReceive (context , intent );
254259 }
260+
261+ private void updateEnabledAccessibilitySerivcesSettingLocked (
262+ Set <ComponentName > enabledServices ) {
263+ Iterator <ComponentName > it = enabledServices .iterator ();
264+ StringBuilder str = new StringBuilder ();
265+ while (it .hasNext ()) {
266+ if (str .length () > 0 ) {
267+ str .append (':' );
268+ }
269+ str .append (it .next ().flattenToShortString ());
270+ }
271+ Settings .Secure .putString (mContext .getContentResolver (),
272+ Settings .Secure .ENABLED_ACCESSIBILITY_SERVICES ,
273+ str .toString ());
274+ }
255275 };
256276
257277 // package changes
0 commit comments