Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix FC when trying to adjust radio band via *#*#4636#*#* dialer code #10

Open
wants to merge 13 commits into
base: android-5.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,27 @@ LOCAL_SRC_FILES := \
$(call all-java-files-under, src) \
src/com/android/settings/EventLogTags.logtags
LOCAL_SRC_FILES += $(call all-java-files-under, ../PerformanceControl/src)
LOCAL_SRC_FILES += $(call all-java-files-under, ../OmniGears/src)

LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
LOCAL_RESOURCE_DIR += packages/apps/PerformanceControl/res
LOCAL_RESOURCE_DIR += packages/apps/OmniGears/res

LOCAL_ASSET_DIR += packages/apps/PerformanceControl/assets

LOCAL_AAPT_FLAGS := --auto-add-overlay \
--extra-packages com.brewcrewfoo.performance \
--extra-packages org.omnirom.omnigears
--extra-packages com.brewcrewfoo.performance

LOCAL_PACKAGE_NAME := Settings
LOCAL_CERTIFICATE := platform
LOCAL_PRIVILEGED_MODULE := true

LOCAL_PROGUARD_FLAG_FILES := proguard.flags

LOCAL_AAPT_INCLUDE_ALL_RESOURCES := true
LOCAL_AAPT_FLAGS += --extra-packages com.koushikdutta.superuser:com.koushikdutta.widgets --auto-add-overlay

LOCAL_SRC_FILES += $(call all-java-files-under,../../../external/koush/Superuser/Superuser/src) $(call all-java-files-under,../../../external/koush/Widgets/Widgets/src)
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res $(LOCAL_PATH)/../../../external/koush/Widgets/Widgets/res $(LOCAL_PATH)/../../../external/koush/Superuser/Superuser/res

include frameworks/opt/setupwizard/navigationbar/common.mk

include $(BUILD_PACKAGE)
Expand Down
69 changes: 69 additions & 0 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,34 @@
<uses-permission android:name="android.permission.READ_SEARCH_INDEXABLES" />
<uses-permission android:name="android.permission.OEM_UNLOCK_STATE" />

<permission
android:name="cyanogenmod.permission.PROTECTED_APP"
android:protectionLevel="signatureOrSystem" />

<permission
android:name="android.permission.REQUEST_SUPERUSER"
android:protectionLevel="signature" />

<permission
android:name="android.permission.REPORT_SUPERUSER"
android:protectionLevel="signature" />

<permission-group
android:name="android.permission-group.SUPERUSER"
android:description="@string/superuser_description_more"
android:icon="@drawable/ic_action_permission"
android:label="@string/superuser"
android:priority="10000" />

<permission
android:name="android.permission.ACCESS_SUPERUSER"
android:description="@string/superuser_description_more"
android:icon="@drawable/ic_action_permission"
android:label="@string/superuser_description"
android:logo="@drawable/ic_action_permission"
android:permissionGroup="android.permission-group.SUPERUSER"
android:protectionLevel="dangerous" />

<application android:label="@string/settings_label"
android:icon="@mipmap/ic_launcher_settings"
android:taskAffinity=""
Expand All @@ -79,6 +107,47 @@
android:supportsRtl="true"
android:allowBackup="false">

<!-- Only system/su can open this activity -->
<!-- This activity will then call the MultitaskSuRequestActivity to create a new task stack -->
<activity
android:name=".cyanogenmod.superuser.RequestActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="@string/superuser"
android:launchMode="singleTask"
android:excludeFromRecents="true"
android:permission="android.permission.REQUEST_SUPERUSER"
android:process=":superuser"
android:taskAffinity="com.android.settings.superuser"
android:theme="@style/RequestThemeDark" />
<!-- Only system/su can open this activity -->
<!-- This is activity is started in multiuser mode when the user invoking su -->
<!-- is not the device owner (user id 0). -->
<activity
android:name=".cyanogenmod.superuser.NotifyActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="@string/superuser"
android:launchMode="singleTask"
android:excludeFromRecents="true"
android:permission="android.permission.REQUEST_SUPERUSER"
android:process=":superuser"
android:taskAffinity="com.android.settings.superuser"
android:theme="@style/RequestThemeDark" />

<!-- Multiple instances of this activity can be running for multiple su requests -->
<activity
android:name=".cyanogenmod.superuser.MultitaskSuRequestActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:excludeFromRecents="true"
android:exported="false"
android:label="@string/request"
android:process=":superuser"
android:taskAffinity="com.android.settings.superuser"
android:theme="@style/RequestThemeDark" />

<receiver
android:name=".cyanogenmod.superuser.SuReceiver"
android:permission="android.permission.REPORT_SUPERUSER" />

<!-- Settings -->

<activity android:name="Settings"
Expand Down
2 changes: 2 additions & 0 deletions proguard.flags
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

# Keep OmniGears stuff
-keep class org.omnirom.omnigears.*
-keep class com.koushikdutta.**
-keep class com.android.settings.cyanogenmod.superuser.**

# Keep click responders
-keepclassmembers class com.android.settings.inputmethod.UserDictionaryAddWordActivity {
Expand Down
2 changes: 1 addition & 1 deletion res/values/custom_strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
-->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<!-- About phone screen, setting option name-->
<string name="mod_version">Omni version</string>
<string name="mod_version">ErcOne version</string>
<string name="mod_version_default">Unknown</string>

<!-- Main list strings -->
Expand Down
9 changes: 9 additions & 0 deletions res/values/enhancement_vars.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
From CM11 Settings
-->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">

<!-- Hostname setting -->
<string name="device_hostname">Device hostname</string>
</resources>
8 changes: 8 additions & 0 deletions res/xml/dashboard_categories.xml
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,14 @@
android:icon="@drawable/ic_settings_print"
/>

<!-- Superuser -->
<dashboard-tile
android:id="@+id/superuser_settings"
android:title="@string/superuser"
android:fragment="com.android.settings.cyanogenmod.superuser.PolicyNativeFragment"
android:icon="@drawable/ic_action_permission"
/>

<!-- Development -->
<dashboard-tile
android:id="@+id/development_settings"
Expand Down
16 changes: 14 additions & 2 deletions res/xml/development_prefs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@

<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/development_settings_title">
<!--<com.android.settings.BugreportPreference
<com.android.settings.BugreportPreference
android:key="bugreport"
android:title="@*android:string/bugreport_title"
android:dialogTitle="@*android:string/bugreport_title" />-->
android:dialogTitle="@*android:string/bugreport_title" />

<PreferenceScreen
android:key="local_backup_password"
Expand Down Expand Up @@ -99,6 +99,18 @@
android:title="@string/bugreport_in_power"
android:summary="@string/bugreport_in_power_summary"/>

<!--Customizable host name entry-->
<com.android.settings.HostnamePreference
android:key="device_hostname"
android:title="@string/device_hostname"
android:dialogTitle="@string/device_hostname"
android:positiveButtonText="@string/wifi_save"
android:negativeButtonText="@string/wifi_cancel"
android:selectAllOnFocus="true"
android:imeOptions="actionDone"
android:inputType="textNoSuggestions"
android:persistent="false" />

<CheckBoxPreference
android:key="allow_mock_location"
android:title="@string/allow_mock_location"
Expand Down
67 changes: 40 additions & 27 deletions src/com/android/settings/BandMode.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,46 @@

/**
* Radio Band Mode Selection Class
*
* It will query baseband about all available band modes and display them
* in screen. It will display all six band modes if the query failed.
*
* After user select one band, it will send the selection to baseband.
*
* It will alter user the result of select operation and exit, no matter success
* or not.
*
*/
/**
* Radio Band Mode Selection Class
* This will query the device for all available band modes
* and display the options on the screen. If however it fails it will then
* display all the available band modes that are in the BAND_NAMES array.
* After the user selects a band, it will attempt to set the band mode
* regardless of the outcome. However if the bandmode will not work RIL.Java
* will catch it and throw a GENERIC_FAILURE or RADIO_NOT_AVAILABLE error
*/
public class BandMode extends Activity {
private static final String LOG_TAG = "phone";
private static final boolean DBG = false;

private static final int EVENT_BAND_SCAN_COMPLETED = 100;
private static final int EVENT_BAND_SELECTION_DONE = 200;

/*
* pulled from hardware/ril/include/telephony/ril.h and cleaned up a little
* there ought to be a better way to do this...
* make queryAvailableBandMode return something other than just an int array?
*/
private static final String[] BAND_NAMES = new String[] {
"Automatic",
"EURO Band",
"USA Band",
"JAPAN Band",
"AUS Band",
"AUS2 Band"
"Automatic",
"EURO Band (GSM-900/DCS-1800/WCDMA-IMT-2000)",
"USA Band (GSM-850/PCS-1900/WCDMA-850/WCDMA-PCS-1900)",
"JAPAN Band (WCDMA-800/WCDMA-IMT-2000)",
"AUS Band (GSM-900/DCS-1800/WCDMA-850/WCDMA-IMT-2000)",
"AUS2 Band (GSM-900/DCS-1800/WCDMA-850)",
"Cellular (800-MHz)",
"PCS (1900-MHz)",
"Band Class 3 (JTACS Band)",
"Band Class 4 (Korean PCS Band)",
"Band Class 5 (450-MHz Band)",
"Band Class 6 (2-GMHz IMT2000 Band)",
"Band Class 7 (Upper 700-MHz Band)",
"Band Class 8 (1800-MHz Band)",
"Band Class 9 (900-MHz Band)",
"Band Class 10 (Secondary 800-MHz Band)",
"Band Class 11 (400-MHz European PAMR Band)",
"Band Class 15 (AWS Band)",
"Band Class 16 (US 2.5-GHz Band)"
};

private ListView mBandList;
Expand Down Expand Up @@ -140,21 +156,18 @@ private void bandListLoaded(AsyncResult result) {

if (result.result != null) {
int bands[] = (int[])result.result;
int size = bands[0];

if (size > 0) {
for (int i=1; i<size; i++) {
item = new BandListItem(bands[i]);
mBandListAdapter.add(item);
if (DBG) log("Add " + item.toString());
}
addBandSuccess = true;

for (int i=0; i<bands.length; i++) {
item = new BandListItem(bands[i]);
mBandListAdapter.add(item);
if (DBG) log("Add " + item.toString());
}
addBandSuccess = true;
}

if (addBandSuccess == false) {
if (DBG) log("Error in query, add default list");
for (int i=0; i<Phone.BM_BOUNDARY; i++) {
for (int i=0; i<BAND_NAMES.length; i++) {
item = new BandListItem(i);
mBandListAdapter.add(item);
if (DBG) log("Add default " + item.toString());
Expand Down
111 changes: 111 additions & 0 deletions src/com/android/settings/HostnamePreference.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
package com.android.settings;

import android.content.Context;
import android.os.SystemProperties;
import android.preference.EditTextPreference;
import android.provider.Settings;
import android.text.InputFilter;
import android.text.Spanned;
import android.util.AttributeSet;
import android.util.Log;

public class HostnamePreference extends EditTextPreference {

private static final String TAG = "HostnamePreference";

private static final String PROP_HOSTNAME = "net.hostname";

private final String DEFAULT_HOSTNAME;

InputFilter mHostnameInputFilter = new InputFilter() {
@Override
public CharSequence filter(CharSequence source, int start, int end,
Spanned dest, int dstart, int dend) {

if (source.length() == 0)
return null;

// remove any character that is not alphanumeric, period, or hyphen
return source.subSequence(start, end).toString().replaceAll("[^-.a-zA-Z0-9]", "");
}
};

public HostnamePreference(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);

// determine the default hostname
String id = Settings.Secure.getString(getContext().getContentResolver(),
Settings.Secure.ANDROID_ID);
if (id != null && id.length() > 0) {
DEFAULT_HOSTNAME = "android-".concat(id);
} else {
DEFAULT_HOSTNAME = "";
}

setSummary(getText());
getEditText().setFilters(new InputFilter[] { mHostnameInputFilter });
getEditText().setHint(DEFAULT_HOSTNAME);
}

public HostnamePreference(Context context, AttributeSet attrs) {
this(context, attrs, com.android.internal.R.attr.editTextPreferenceStyle);
}

public HostnamePreference(Context context) {
this(context, null);
}

@Override
protected void onDialogClosed(boolean positiveResult) {
if (positiveResult) {
String hostname = getEditText().getText().toString();

// remove any preceding or succeeding periods or hyphens
hostname = hostname.replaceAll("(?:\\.|-)+$", "");
hostname = hostname.replaceAll("^(?:\\.|-)+", "");

if (hostname.length() == 0) {
if (DEFAULT_HOSTNAME.length() != 0) {
// if no hostname is given, use the default
hostname = DEFAULT_HOSTNAME;
} else {
// if no other name can be determined
// fall back on the current hostname
hostname = getText();
}
}
setText(hostname);
}
}

@Override
public void setText(String text) {
if (text == null) {
Log.e(TAG, "tried to set null hostname, request ignored");
return;
} else if (text.length() == 0) {
Log.w(TAG, "setting empty hostname");
} else {
Log.i(TAG, "hostname has been set: " + text);
}
SystemProperties.set(PROP_HOSTNAME, text);
persistHostname(text);
setSummary(text);
}

@Override
public String getText() {
return SystemProperties.get(PROP_HOSTNAME);
}

@Override
public void onSetInitialValue(boolean restoreValue, Object defaultValue) {
String hostname = getText();
persistHostname(hostname);
}

public void persistHostname(String hostname) {
Settings.Secure.putString(getContext().getContentResolver(),
Settings.Secure.DEVICE_HOSTNAME, hostname);
}
}
Loading