diff --git a/extern/MicroGUiTools b/extern/MicroGUiTools index a65d5df..1e8926e 160000 --- a/extern/MicroGUiTools +++ b/extern/MicroGUiTools @@ -1 +1 @@ -Subproject commit a65d5dfba834a32b2b45023f2c3e3a98533c7601 +Subproject commit 1e8926edd95dc155d57c1306d7b13448cd895740 diff --git a/unifiednlp-base/src/main/java/org/microg/nlp/ui/AbstractBackendPreference.java b/unifiednlp-base/src/main/java/org/microg/nlp/ui/AbstractBackendPreference.java index 1634ca0..a8208d4 100644 --- a/unifiednlp-base/src/main/java/org/microg/nlp/ui/AbstractBackendPreference.java +++ b/unifiednlp-base/src/main/java/org/microg/nlp/ui/AbstractBackendPreference.java @@ -26,6 +26,7 @@ import android.os.IBinder; import android.preference.DialogPreference; import android.util.AttributeSet; +import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -33,6 +34,7 @@ import android.widget.CheckBox; import android.widget.ListView; import android.widget.TextView; +import android.widget.Toast; import org.microg.nlp.Preferences; import org.microg.nlp.R; @@ -199,27 +201,33 @@ public void onClick(View v) { } protected void enableBackend(BackendInfo backendInfo) { - if (backendInfo.getMeta(METADATA_BACKEND_INIT_ACTIVITY) != null) { - getContext().startActivity(createExternalIntent(backendInfo, METADATA_BACKEND_INIT_ACTIVITY)); - } else { - Intent intent = buildBackendIntent(); - intent.setPackage(backendInfo.serviceInfo.packageName); - intent.setClassName(backendInfo.serviceInfo.packageName, backendInfo.serviceInfo.name); - getContext().bindService(intent, new ServiceConnection() { - @Override - public void onServiceConnected(ComponentName name, IBinder service) { - Intent i = getBackendInitIntent(service); - if (i != null) { - getContext().startActivity(i); + try { + if (backendInfo.getMeta(METADATA_BACKEND_INIT_ACTIVITY) != null) { + getContext().startActivity(createExternalIntent(backendInfo, METADATA_BACKEND_INIT_ACTIVITY)); + } else { + Intent intent = buildBackendIntent(); + intent.setPackage(backendInfo.serviceInfo.packageName); + intent.setClassName(backendInfo.serviceInfo.packageName, backendInfo.serviceInfo.name); + getContext().bindService(intent, new ServiceConnection() { + @Override + public void onServiceConnected(ComponentName name, IBinder service) { + Intent i = getBackendInitIntent(service); + if (i != null) { + getContext().startActivity(i); + } + getContext().unbindService(this); } - getContext().unbindService(this); - } - @Override - public void onServiceDisconnected(ComponentName name) { + @Override + public void onServiceDisconnected(ComponentName name) { - } - }, BIND_AUTO_CREATE); + } + }, BIND_AUTO_CREATE); + } + } catch (Exception e) { + backendInfo.enabled = false; + Toast.makeText(getContext(), "Error initializing backend", Toast.LENGTH_SHORT).show(); + resetAdapter(); } } diff --git a/unifiednlp-base/src/main/java/org/microg/nlp/ui/SettingsActivity.java b/unifiednlp-base/src/main/java/org/microg/nlp/ui/SettingsActivity.java index de5ee77..d4b5155 100644 --- a/unifiednlp-base/src/main/java/org/microg/nlp/ui/SettingsActivity.java +++ b/unifiednlp-base/src/main/java/org/microg/nlp/ui/SettingsActivity.java @@ -28,12 +28,17 @@ import org.microg.nlp.R; import org.microg.tools.selfcheck.NlpOsCompatChecks; import org.microg.tools.selfcheck.NlpStatusChecks; +import org.microg.tools.selfcheck.PermissionCheckGroup; import org.microg.tools.selfcheck.SelfCheckGroup; import org.microg.tools.ui.AbstractAboutFragment; import org.microg.tools.ui.AbstractSelfCheckFragment; import java.util.List; +import static android.Manifest.permission.ACCESS_COARSE_LOCATION; +import static android.os.Build.VERSION.SDK_INT; +import static android.os.Build.VERSION_CODES.LOLLIPOP_MR1; + public class SettingsActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { @@ -94,6 +99,9 @@ public static class MySelfCheckFragment extends AbstractSelfCheckFragment { @Override protected void prepareSelfCheckList(List checks) { + if (SDK_INT > LOLLIPOP_MR1) { + checks.add(new PermissionCheckGroup(ACCESS_COARSE_LOCATION)); + } checks.add(new NlpOsCompatChecks()); checks.add(new NlpStatusChecks()); }