SetupWizard: Fix AccessibilityController regression and service leak
Change-Id: Ic8e419792d2468b937feb08d6678608c936d9f98
This commit is contained in:
parent
c117b980c4
commit
508cfbb0f3
@ -23,8 +23,7 @@
|
|||||||
|
|
||||||
<LinearLayout android:orientation="vertical"
|
<LinearLayout android:orientation="vertical"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent">
|
||||||
android:clickable="true">
|
|
||||||
|
|
||||||
<FrameLayout android:id="@+id/content"
|
<FrameLayout android:id="@+id/content"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -88,7 +88,8 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks
|
|||||||
mSetupData.load(savedInstanceState.getBundle("data"));
|
mSetupData.load(savedInstanceState.getBundle("data"));
|
||||||
}
|
}
|
||||||
if (EnableAccessibilityController.canEnableAccessibilityViaGesture(this)) {
|
if (EnableAccessibilityController.canEnableAccessibilityViaGesture(this)) {
|
||||||
mEnableAccessibilityController = new EnableAccessibilityController(this);
|
mEnableAccessibilityController =
|
||||||
|
EnableAccessibilityController.getInstance(getApplicationContext());
|
||||||
mRootView.setOnTouchListener(new View.OnTouchListener() {
|
mRootView.setOnTouchListener(new View.OnTouchListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouch(View v, MotionEvent event) {
|
public boolean onTouch(View v, MotionEvent event) {
|
||||||
@ -119,9 +120,6 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks
|
|||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
if (mEnableAccessibilityController != null) {
|
|
||||||
mEnableAccessibilityController.onDestroy();
|
|
||||||
}
|
|
||||||
mSetupData.unregisterListener(this);
|
mSetupData.unregisterListener(this);
|
||||||
unregisterReceiver(mSetupData);
|
unregisterReceiver(mSetupData);
|
||||||
}
|
}
|
||||||
@ -273,7 +271,10 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks
|
|||||||
Settings.Global.putInt(getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 1);
|
Settings.Global.putInt(getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 1);
|
||||||
Settings.Secure.putInt(getContentResolver(), Settings.Secure.USER_SETUP_COMPLETE, 1);
|
Settings.Secure.putInt(getContentResolver(), Settings.Secure.USER_SETUP_COMPLETE, 1);
|
||||||
((SetupWizardApp)AppGlobals.getInitialApplication()).enableStatusBar();
|
((SetupWizardApp)AppGlobals.getInitialApplication()).enableStatusBar();
|
||||||
SetupWizardUtils.disableSetupWizards(this);
|
|
||||||
finish();
|
finish();
|
||||||
|
if (mEnableAccessibilityController != null) {
|
||||||
|
mEnableAccessibilityController.onDestroy();
|
||||||
|
}
|
||||||
|
SetupWizardUtils.disableSetupWizards(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,9 @@ public class EnableAccessibilityController {
|
|||||||
private float mSecondPointerDownX;
|
private float mSecondPointerDownX;
|
||||||
private float mSecondPointerDownY;
|
private float mSecondPointerDownY;
|
||||||
|
|
||||||
public EnableAccessibilityController(Context context) {
|
private static EnableAccessibilityController sInstance;
|
||||||
|
|
||||||
|
private EnableAccessibilityController(Context context) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mUserManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
|
mUserManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
|
||||||
mTts = new TextToSpeech(context, new TextToSpeech.OnInitListener() {
|
mTts = new TextToSpeech(context, new TextToSpeech.OnInitListener() {
|
||||||
@ -114,6 +116,13 @@ public class EnableAccessibilityController {
|
|||||||
R.dimen.accessibility_touch_slop);
|
R.dimen.accessibility_touch_slop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static EnableAccessibilityController getInstance(Context context) {
|
||||||
|
if (sInstance == null) {
|
||||||
|
sInstance = new EnableAccessibilityController(context);
|
||||||
|
}
|
||||||
|
return sInstance;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean canEnableAccessibilityViaGesture(Context context) {
|
public static boolean canEnableAccessibilityViaGesture(Context context) {
|
||||||
AccessibilityManager accessibilityManager = AccessibilityManager.getInstance(context);
|
AccessibilityManager accessibilityManager = AccessibilityManager.getInstance(context);
|
||||||
// Accessibility is enabled and there is an enabled speaking
|
// Accessibility is enabled and there is an enabled speaking
|
||||||
@ -123,11 +132,10 @@ public class EnableAccessibilityController {
|
|||||||
AccessibilityServiceInfo.FEEDBACK_SPOKEN).isEmpty()) {
|
AccessibilityServiceInfo.FEEDBACK_SPOKEN).isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// If the global gesture is enabled and there is a speaking service
|
|
||||||
|
// If there is a speaking service
|
||||||
// installed we are good to go, otherwise there is nothing to do.
|
// installed we are good to go, otherwise there is nothing to do.
|
||||||
return Settings.Global.getInt(context.getContentResolver(),
|
return getInstalledSpeakingAccessibilityServices(context).isEmpty();
|
||||||
Settings.Global.ENABLE_ACCESSIBILITY_GLOBAL_GESTURE_ENABLED, 0) == 1
|
|
||||||
&& !getInstalledSpeakingAccessibilityServices(context).isEmpty();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<AccessibilityServiceInfo> getInstalledSpeakingAccessibilityServices(
|
private static List<AccessibilityServiceInfo> getInstalledSpeakingAccessibilityServices(
|
||||||
|
@ -162,11 +162,11 @@ public class SetupWizardUtils {
|
|||||||
new ComponentName(info.activityInfo.packageName, info.activityInfo.name);
|
new ComponentName(info.activityInfo.packageName, info.activityInfo.name);
|
||||||
pm.setComponentEnabledSetting(componentName,
|
pm.setComponentEnabledSetting(componentName,
|
||||||
PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
|
PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
|
||||||
PackageManager.DONT_KILL_APP);
|
0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pm.setComponentEnabledSetting(context.getComponentName(),
|
pm.setComponentEnabledSetting(context.getComponentName(),
|
||||||
PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
|
PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 0);
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user