Skip to content

Commit

Permalink
Telephony: Implement alternative method for manual network select
Browse files Browse the repository at this point in the history
* APK extracted from oneplus, decompiled, adapted and cleaned up. Translations imported from AOSP

To use it add TARGET_USES_ALTERNATIVE_MANUAL_NETWORK_SELECT := true on BoardConfig

Change-Id: I6ffdba466da2cb5d71d2ccff3115c1c30fe3e734
Signed-off-by: Josh Fox (XlxFoXxlX) <[email protected]>
  • Loading branch information
jhenrique09 authored and xlxfoxxlx committed Jul 29, 2019
1 parent 9e775da commit 560cf9a
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 4 deletions.
4 changes: 4 additions & 0 deletions Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ LOCAL_PRIVILEGED_MODULE := true

LOCAL_PROGUARD_FLAG_FILES := proguard.flags sip/proguard.flags

ifeq ($(TARGET_USES_ALTERNATIVE_MANUAL_NETWORK_SELECT),true)
LOCAL_REQUIRED_MODULES := CustomNetworkSettings
endif

include frameworks/base/packages/SettingsLib/common.mk

include $(BUILD_PACKAGE)
Expand Down
13 changes: 13 additions & 0 deletions prebuilts/Android.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
LOCAL_PATH := $(call my-dir)

ifeq ($(TARGET_USES_ALTERNATIVE_MANUAL_NETWORK_SELECT),true)
include $(CLEAR_VARS)
LOCAL_MODULE := CustomNetworkSettings
LOCAL_SRC_FILES := CustomNetworkSettings.apk
LOCAL_CERTIFICATE := platform
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := APPS
LOCAL_DEX_PREOPT := false
LOCAL_MODULE_SUFFIX := .apk
include $(BUILD_PREBUILT)
endif
Binary file added prebuilts/CustomNetworkSettings.apk
Binary file not shown.
4 changes: 4 additions & 0 deletions res/xml/gsm_umts_options.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
android:key="button_choose_network_key"
android:title="@string/choose_network_title"
android:fragment="com.android.phone.NetworkSelectSetting" />

<Preference
android:key="button_alternative_manual_network_select"
android:title="@string/choose_network_title" />
</com.android.phone.NetworkOperators>

<!--We want separate APN setting from reset of settings because-->
Expand Down
35 changes: 31 additions & 4 deletions src/com/android/phone/NetworkOperators.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,19 @@ public class NetworkOperators extends PreferenceCategory
private TwoStatePreference mAutoSelect;
private Preference mChooseNetwork;

// Alternative manual network select
private Preference mAlternativeManualNetworkSelect;
private static final String BUTTON_ALTERNATIVE_MANUAL_NETWORK_SELECT_KEY = "button_alternative_manual_network_select";
private static final String ACTION_ALTERNATIVE_MANUAL_NETWORK_SELECT = "org.pixelexperience.ALTERNATIVE_MANUAL_NETWORK_SELECT";

private int mSubId;
private ProgressDialog mProgressDialog;

// There's two sets of Auto-Select UI in this class.
// If {@code com.android.internal.R.bool.config_enableNewAutoSelectNetworkUI} set as true
// {@link mChooseNetwork} will be used, otherwise {@link mNetworkSelect} will be used.
boolean mEnableNewManualSelectNetworkUI;
boolean mAlternativeManualNetworkSelectAvailable;

public NetworkOperators(Context context, AttributeSet attrs) {
super(context, attrs);
Expand All @@ -83,15 +89,23 @@ public NetworkOperators(Context context) {
* Initialize NetworkOperators instance.
*/
public void initialize() {
mEnableNewManualSelectNetworkUI = getContext().getResources().getBoolean(
mAlternativeManualNetworkSelectAvailable = isAlternativeManualNetworkSelectAvailable();
mAlternativeManualNetworkSelect = findPreference(BUTTON_ALTERNATIVE_MANUAL_NETWORK_SELECT_KEY);
mEnableNewManualSelectNetworkUI = !mAlternativeManualNetworkSelectAvailable && getContext().getResources().getBoolean(
com.android.internal.R.bool.config_enableNewAutoSelectNetworkUI);
mAutoSelect = (TwoStatePreference) findPreference(BUTTON_AUTO_SELECT_KEY);
mChooseNetwork = findPreference(BUTTON_CHOOSE_NETWORK_KEY);
mNetworkSelect = (NetworkSelectListPreference) findPreference(BUTTON_NETWORK_SELECT_KEY);
if (mEnableNewManualSelectNetworkUI) {
if (mAlternativeManualNetworkSelectAvailable){
removePreference(mAutoSelect);
removePreference(mNetworkSelect);
removePreference(mChooseNetwork);
}else if (mEnableNewManualSelectNetworkUI) {
removePreference(mNetworkSelect);
removePreference(mAlternativeManualNetworkSelect);
} else {
removePreference(mChooseNetwork);
removePreference(mAlternativeManualNetworkSelect);
}
mProgressDialog = new ProgressDialog(getContext());
}
Expand Down Expand Up @@ -307,8 +321,21 @@ public void openChooseNetworkPage() {
getContext().startActivity(intent);
}

private void openAlternativeManualNetworkSelect() {
Intent intent = new Intent(ACTION_ALTERNATIVE_MANUAL_NETWORK_SELECT);
intent.putExtra("sub_id", mPhoneId);
getContext().startActivity(intent);
}

private boolean isAlternativeManualNetworkSelectAvailable() {
return new Intent(ACTION_ALTERNATIVE_MANUAL_NETWORK_SELECT).resolveActivity(getContext().getPackageManager()) != null;
}

protected boolean preferenceTreeClick(Preference preference) {
if (mEnableNewManualSelectNetworkUI) {
if (preference == mAlternativeManualNetworkSelect) {
openAlternativeManualNetworkSelect();
return true;
} else if (mEnableNewManualSelectNetworkUI) {
if (DBG) logd("enable New AutoSelectNetwork UI");
if (preference == mChooseNetwork) {
openChooseNetworkPage();
Expand All @@ -326,4 +353,4 @@ private void logd(String msg) {
private void loge(String msg) {
Log.e(LOG_TAG, "[NetworksList] " + msg);
}
}
}

0 comments on commit 560cf9a

Please sign in to comment.