diff options
-rw-r--r-- | core/java/android/app/Profile.java | 66 | ||||
-rw-r--r-- | core/java/android/widget/SearchView.java | 3 | ||||
-rw-r--r-- | core/res/res/values-it/strings.xml | 2 | ||||
-rw-r--r-- | core/res/res/values-tr/strings.xml | 6 | ||||
-rwxr-xr-x | core/res/res/values/config.xml | 9 | ||||
-rwxr-xr-x | core/res/res/values/strings.xml | 2 | ||||
-rwxr-xr-x | media/libstagefright/MPEG4Writer.cpp | 39 | ||||
-rw-r--r-- | packages/SystemUI/res/values-it/strings.xml | 5 | ||||
-rw-r--r-- | packages/SystemUI/res/values-ru/strings.xml | 6 | ||||
-rwxr-xr-x | policy/src/com/android/internal/policy/impl/LockScreen.java | 30 | ||||
-rwxr-xr-x | policy/src/com/android/internal/policy/impl/PhoneWindowManager.java | 15 | ||||
-rw-r--r-- | services/java/com/android/server/PowerManagerService.java | 18 | ||||
-rw-r--r-- | services/java/com/android/server/ProfileManagerService.java | 17 | ||||
-rw-r--r-- | telephony/java/com/android/internal/telephony/CallManager.java | 20 | ||||
-rw-r--r-- | telephony/java/com/android/internal/telephony/LGEQualcommUiccRIL.java | 16 | ||||
-rw-r--r-- | telephony/java/com/android/internal/telephony/Smdk4210RIL.java | 1297 |
16 files changed, 850 insertions, 701 deletions
diff --git a/core/java/android/app/Profile.java b/core/java/android/app/Profile.java index 4d29a03..54e187d 100644 --- a/core/java/android/app/Profile.java +++ b/core/java/android/app/Profile.java @@ -30,8 +30,10 @@ import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; import java.io.IOException; +import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.UUID; @@ -46,6 +48,8 @@ public final class Profile implements Parcelable, Comparable { private UUID mUuid; + private ArrayList<UUID> mSecondaryUuids = new ArrayList<UUID>(); + private Map<UUID, ProfileGroup> profileGroups = new HashMap<UUID, ProfileGroup>(); private ProfileGroup mDefaultGroup; @@ -172,6 +176,11 @@ public final class Profile implements Parcelable, Comparable { dest.writeString(mName); dest.writeInt(mNameResId); new ParcelUuid(mUuid).writeToParcel(dest, 0); + ArrayList<ParcelUuid> uuids = new ArrayList<ParcelUuid>(mSecondaryUuids.size()); + for (UUID u : mSecondaryUuids) { + uuids.add(new ParcelUuid(u)); + } + dest.writeParcelableArray(uuids.toArray(new Parcelable[uuids.size()]), flags); dest.writeInt(mStatusBarIndicator ? 1 : 0); dest.writeInt(mProfileType); dest.writeInt(mDirty ? 1 : 0); @@ -191,6 +200,10 @@ public final class Profile implements Parcelable, Comparable { mName = in.readString(); mNameResId = in.readInt(); mUuid = ParcelUuid.CREATOR.createFromParcel(in).getUuid(); + for (Parcelable parcel : in.readParcelableArray(null)) { + ParcelUuid u = (ParcelUuid) parcel; + mSecondaryUuids.add(u.getUuid()); + } mStatusBarIndicator = (in.readInt() == 1); mProfileType = in.readInt(); mDirty = (in.readInt() == 1); @@ -243,6 +256,25 @@ public final class Profile implements Parcelable, Comparable { return this.mUuid; } + public UUID[] getSecondaryUuids() { + return mSecondaryUuids.toArray(new UUID[mSecondaryUuids.size()]); + } + + public void setSecondaryUuids(List<UUID> uuids) { + mSecondaryUuids.clear(); + if (uuids != null) { + mSecondaryUuids.addAll(uuids); + mDirty = true; + } + } + + public void addSecondaryUuid(UUID uuid) { + if (uuid != null) { + mSecondaryUuids.add(uuid); + mDirty = true; + } + } + public boolean getStatusBarIndicator() { return mStatusBarIndicator; } @@ -329,6 +361,14 @@ public final class Profile implements Parcelable, Comparable { builder.append(TextUtils.htmlEncode(getUuid().toString())); builder.append("\">\n"); + builder.append("<uuids>"); + for (UUID u : mSecondaryUuids) { + builder.append("<uuid>"); + builder.append(TextUtils.htmlEncode(u.toString())); + builder.append("</uuid>"); + } + builder.append("</uuids>\n"); + builder.append("<profiletype>"); builder.append(getProfileType() == TOGGLE_TYPE ? "toggle" : "conditional"); builder.append("</profiletype>\n"); @@ -361,6 +401,29 @@ public final class Profile implements Parcelable, Comparable { mDirty = false; } + private static List<UUID> readSecondaryUuidsFromXml(XmlPullParser xpp, Context context) + throws XmlPullParserException, + IOException { + ArrayList<UUID> uuids = new ArrayList<UUID>(); + int event = xpp.next(); + while (event != XmlPullParser.END_TAG || !xpp.getName().equals("uuids")) { + if (event == XmlPullParser.START_TAG) { + String name = xpp.getName(); + if (name.equals("uuid")) { + try { + uuids.add(UUID.fromString(xpp.nextText())); + } catch (NullPointerException e) { + Log.w(TAG, "Null Pointer - invalid UUID"); + } catch (IllegalArgumentException e) { + Log.w(TAG, "UUID not recognized"); + } + } + } + event = xpp.next(); + } + return uuids; + } + /** @hide */ public static Profile fromXml(XmlPullParser xpp, Context context) throws XmlPullParserException, IOException { @@ -403,6 +466,9 @@ public final class Profile implements Parcelable, Comparable { while (event != XmlPullParser.END_TAG) { if (event == XmlPullParser.START_TAG) { String name = xpp.getName(); + if (name.equals("uuids")) { + profile.setSecondaryUuids(readSecondaryUuidsFromXml(xpp, context)); + } if (name.equals("statusbar")) { profile.setStatusBarIndicator(xpp.nextText().equals("yes")); } diff --git a/core/java/android/widget/SearchView.java b/core/java/android/widget/SearchView.java index 9d2ff2e..3e7cb77 100644 --- a/core/java/android/widget/SearchView.java +++ b/core/java/android/widget/SearchView.java @@ -1432,6 +1432,9 @@ public class SearchView extends LinearLayout implements CollapsibleActionView { // because the voice search activity will always need to insert "QUERY" into // it anyway. Bundle queryExtras = new Bundle(); + if(this.mAppSearchData != null) { + queryExtras.putParcelable(SearchManager.APP_DATA, this.mAppSearchData); + } // Now build the intent to launch the voice search. Add all necessary // extras to launch the voice recognizer, and then all the necessary extras diff --git a/core/res/res/values-it/strings.xml b/core/res/res/values-it/strings.xml index b8666bb..e8409ca 100644 --- a/core/res/res/values-it/strings.xml +++ b/core/res/res/values-it/strings.xml @@ -1312,5 +1312,7 @@ <string name="weather_SW">SW</string> <string name="weather_W">W</string> <string name="weather_NW">NW</string> + <string name="weather_no_data">Nessun dato</string> <string name="weather_tap_to_refresh">Tocca per aggiornare</string> + <string name="weather_refreshing">In aggiornamento</string> </resources> diff --git a/core/res/res/values-tr/strings.xml b/core/res/res/values-tr/strings.xml index 0dd906f..79cebb6 100644 --- a/core/res/res/values-tr/strings.xml +++ b/core/res/res/values-tr/strings.xml @@ -1298,8 +1298,8 @@ <string name="weather_30">Parçalı Bulutlu</string> <!-- Day --> <string name="weather_31">Açık</string> <!-- Night --> <string name="weather_32">Güneşli</string> - <string name="weather_33">Normal</string> <!-- Night --> - <string name="weather_34">Normal</string> <!-- Day --> + <string name="weather_33">Açık</string> <!-- Night --> + <string name="weather_34">Güneşli</string> <!-- Day --> <string name="weather_35">Karışık Yağmur ve Dolu</string> <string name="weather_36">Sıcak</string> <string name="weather_37">Sürekli Gökgürültülü Fırtına</string> @@ -1322,6 +1322,8 @@ <string name="weather_SW">GB</string> <string name="weather_W">B</string> <string name="weather_NW">KB</string> + <string name="weather_no_data">Veri yok</string> <string name="weather_tap_to_refresh">Yenile</string> + <string name="weather_refreshing">Güncelleniyor</string> <!-- #CM-MOD-END --> </resources> diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index caa1be1..4185659 100755 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -658,8 +658,9 @@ <!-- The VoiceMail default value is displayed to my own number if it is true --> <bool name="config_telephony_use_own_number_for_voicemail">false</bool> - <!-- Set additional audio parameters for incall audio --> - <!-- Examples: <item>realcall</item> <item>dualmic_enabled</item> <item>mic_boost</item> --> + <!-- Set additional audio parameters for incall audio + Usage: parameter=onstring=offstring + Examples: <item>realcall=on=off</item> <item>dualmic_enabled=true=false</item> <item>mic_boost=yes=no</item> --> <string-array name="config_telephony_set_audioparameters" translatable="false"> </string-array> @@ -827,4 +828,8 @@ config to 7. --> <integer name="config_deviceHardwareKeys">15</integer> + <!-- Timeout in MS for how long you have to long-press the back key to + kill the foreground app. --> + <integer name="config_backKillTimeout">2000</integer> + </resources> diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml index 7a49539..087aeb3 100755 --- a/core/res/res/values/strings.xml +++ b/core/res/res/values/strings.xml @@ -3441,7 +3441,7 @@ <!-- STK setup Call --> <string name="SetupCallDefault">Accept Call?</string> - <!--Application killed toast --> + <!-- Long-press back kill application --> <string name="app_killed_message">Application killed</string> <!-- Lock screen Weather - Weather codes --> diff --git a/media/libstagefright/MPEG4Writer.cpp b/media/libstagefright/MPEG4Writer.cpp index e8b8b44..b4c0524 100755 --- a/media/libstagefright/MPEG4Writer.cpp +++ b/media/libstagefright/MPEG4Writer.cpp @@ -47,9 +47,6 @@ static const uint8_t kNalUnitTypeSeqParamSet = 0x07; static const uint8_t kNalUnitTypePicParamSet = 0x08; static const int64_t kInitialDelayTimeUs = 700000LL; -// MPEG4 uses Jan 1, 1904 as epoch, not unix epoch -static const int64_t kTimestampConversion = 2082844800LL; - class MPEG4Writer::Track { public: Track(MPEG4Writer *owner, const sp<MediaSource> &source, size_t trackId); @@ -226,11 +223,11 @@ private: void writeDrefBox(); void writeDinfBox(); void writeDamrBox(); - void writeMdhdBox(int64_t now); + void writeMdhdBox(time_t now); void writeSmhdBox(); void writeVmhdBox(); void writeHdlrBox(); - void writeTkhdBox(int64_t now); + void writeTkhdBox(time_t now); void writeMp4aEsdsBox(); void writeMp4vEsdsBox(); void writeAudioFourCCBox(); @@ -714,14 +711,14 @@ status_t MPEG4Writer::stop() { } void MPEG4Writer::writeMvhdBox(int64_t durationUs) { - int64_t now = time(NULL) + kTimestampConversion; + time_t now = time(NULL); beginBox("mvhd"); - writeInt32(0x01000000); // version=1, flags=0 - writeInt64(now); // creation time - writeInt64(now); // modification time + writeInt32(0); // version=0, flags=0 + writeInt32(now); // creation time + writeInt32(now); // modification time writeInt32(mTimeScale); // mvhd timescale int32_t duration = (durationUs * mTimeScale + 5E5) / 1E6; - writeInt64(duration); + writeInt32(duration); writeInt32(0x10000); // rate: 1.0 writeInt16(0x100); // volume writeInt16(0); // reserved @@ -2366,7 +2363,7 @@ void MPEG4Writer::Track::writeTrackHeader(bool use32BitOffset) { LOGV("%s track time scale: %d", mIsAudio? "Audio": "Video", mTimeScale); - int64_t now = time(NULL) + kTimestampConversion; + time_t now = time(NULL); mOwner->beginBox("trak"); writeTkhdBox(now); mOwner->beginBox("mdia"); @@ -2579,20 +2576,20 @@ void MPEG4Writer::Track::writeMp4vEsdsBox() { mOwner->endBox(); // esds } -void MPEG4Writer::Track::writeTkhdBox(int64_t now) { +void MPEG4Writer::Track::writeTkhdBox(time_t now) { mOwner->beginBox("tkhd"); // Flags = 7 to indicate that the track is enabled, and // part of the presentation - mOwner->writeInt32(0x01000007); // version=1, flags=7 - mOwner->writeInt64(now); // creation time - mOwner->writeInt64(now); // modification time + mOwner->writeInt32(0x07); // version=0, flags=7 + mOwner->writeInt32(now); // creation time + mOwner->writeInt32(now); // modification time mOwner->writeInt32(mTrackId + 1); // track id starts with 1 mOwner->writeInt32(0); // reserved int64_t trakDurationUs = getDurationUs(); int32_t mvhdTimeScale = mOwner->getTimeScale(); int32_t tkhdDuration = (trakDurationUs * mvhdTimeScale + 5E5) / 1E6; - mOwner->writeInt64(tkhdDuration); // in mvhd timescale + mOwner->writeInt32(tkhdDuration); // in mvhd timescale mOwner->writeInt32(0); // reserved mOwner->writeInt32(0); // reserved mOwner->writeInt16(0); // layer @@ -2648,15 +2645,15 @@ void MPEG4Writer::Track::writeHdlrBox() { mOwner->endBox(); } -void MPEG4Writer::Track::writeMdhdBox(int64_t now) { +void MPEG4Writer::Track::writeMdhdBox(time_t now) { int64_t trakDurationUs = getDurationUs(); mOwner->beginBox("mdhd"); - mOwner->writeInt32(0x01000000); // version=1, flags=0 - mOwner->writeInt64(now); // creation time - mOwner->writeInt64(now); // modification time + mOwner->writeInt32(0); // version=0, flags=0 + mOwner->writeInt32(now); // creation time + mOwner->writeInt32(now); // modification time mOwner->writeInt32(mTimeScale); // media timescale int32_t mdhdDuration = (trakDurationUs * mTimeScale + 5E5) / 1E6; - mOwner->writeInt64(mdhdDuration); // use media timescale + mOwner->writeInt32(mdhdDuration); // use media timescale // Language follows the three letter standard ISO-639-2/T // 'e', 'n', 'g' for "English", for instance. // Each character is packed as the difference between its ASCII value and 0x60. diff --git a/packages/SystemUI/res/values-it/strings.xml b/packages/SystemUI/res/values-it/strings.xml index 433f135..b392d76 100644 --- a/packages/SystemUI/res/values-it/strings.xml +++ b/packages/SystemUI/res/values-it/strings.xml @@ -42,6 +42,11 @@ <string name="status_bar_settings_wifi_button" msgid="1733928151698311923">"Wi-Fi"</string> <string name="status_bar_settings_bluetooth_button">Bluetooth</string> <string name="status_bar_settings_airplane" msgid="4879879698500955300">"Modalità aereo"</string> + <string name="status_bar_settings_location">GPS</string> + <string name="status_bar_settings_flashlight">Torcia LED</string> + <string name="status_bar_settings_mobile_data">Dati mobili</string> + <string name="status_bar_settings_network_mode">2G/3G</string> + <string name="status_bar_settings_sound_mode">Suoneria</string> <string name="status_bar_settings_auto_rotation" msgid="3790482541357798421">"Rotazione automatica schermo"</string> <string name="status_bar_settings_mute_label" msgid="554682549917429396">"MUTE"</string> <string name="status_bar_settings_auto_brightness_label" msgid="511453614962324674">"AUTO"</string> diff --git a/packages/SystemUI/res/values-ru/strings.xml b/packages/SystemUI/res/values-ru/strings.xml index 99fc6f7..35d1ba6 100644 --- a/packages/SystemUI/res/values-ru/strings.xml +++ b/packages/SystemUI/res/values-ru/strings.xml @@ -41,7 +41,13 @@ <string name="battery_low_why" msgid="7279169609518386372">"Расход заряда батареи"</string> <string name="status_bar_settings_settings_button" msgid="3023889916699270224">"Настройки"</string> <string name="status_bar_settings_wifi_button" msgid="1733928151698311923">"Wi-Fi"</string> + <string name="status_bar_settings_bluetooth_button">Bluetooth</string> <string name="status_bar_settings_airplane" msgid="4879879698500955300">"Режим полета"</string> + <string name="status_bar_settings_location">GPS</string> + <string name="status_bar_settings_flashlight">Фонарик</string> + <string name="status_bar_settings_mobile_data">Передача данных</string> + <string name="status_bar_settings_network_mode">2G/3G</string> + <string name="status_bar_settings_sound_mode">Звук</string> <string name="status_bar_settings_auto_rotation" msgid="3790482541357798421">"Автоповорот экрана"</string> <string name="status_bar_settings_mute_label" msgid="554682549917429396">"ВЫКЛ."</string> <string name="status_bar_settings_auto_brightness_label" msgid="511453614962324674">"АВТО"</string> diff --git a/policy/src/com/android/internal/policy/impl/LockScreen.java b/policy/src/com/android/internal/policy/impl/LockScreen.java index c0ddac1..9c0c0b7b 100755 --- a/policy/src/com/android/internal/policy/impl/LockScreen.java +++ b/policy/src/com/android/internal/policy/impl/LockScreen.java @@ -45,7 +45,10 @@ import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.view.ViewParent; import android.widget.*; +import android.widget.ImageView.ScaleType; +import android.widget.LinearLayout.LayoutParams; import android.util.Log; import android.media.AudioManager; import android.provider.MediaStore; @@ -551,10 +554,29 @@ class LockScreen extends LinearLayout implements KeyguardScreen { } } else { try { - Context settingsContext = context.createPackageContext("com.android.settings", 0); - String wallpaperFile = settingsContext.getFilesDir() + "/lockwallpaper"; - Bitmap background = BitmapFactory.decodeFile(wallpaperFile); - layout.setBackgroundDrawable(new BitmapDrawable(background)); + layout.getParent(); + ViewParent parent = layout.getParent(); + if (parent != null) { + //change parent to show background correctly on scale + RelativeLayout rlout = new RelativeLayout(context); + ((ViewGroup) parent).removeView(layout); + layout.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); + ((ViewGroup) parent).addView(rlout); // change parent to new layout + rlout.addView(layout); + // create framelayout and add imageview to set background + FrameLayout flayout = new FrameLayout(context); + flayout.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); + ImageView mLockScreenWallpaperImage = new ImageView(flayout.getContext()); + mLockScreenWallpaperImage.setScaleType(ScaleType.CENTER_CROP); + flayout.addView(mLockScreenWallpaperImage, -1, -1); + Context settingsContext = context.createPackageContext("com.android.settings", 0); + String wallpaperFile = settingsContext.getFilesDir() + "/lockwallpaper"; + Bitmap background = BitmapFactory.decodeFile(wallpaperFile); + Drawable d = new BitmapDrawable(context.getResources(), background); + mLockScreenWallpaperImage.setImageDrawable(d); + // add background to lock screen. + rlout.addView(flayout,0); + } } catch (NameNotFoundException e) { } } diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java index cf06fbb..933a3a3 100755 --- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java @@ -367,6 +367,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { static final int DEFAULT_ACCELEROMETER_ROTATION = 0; int mAccelerometerDefault = DEFAULT_ACCELEROMETER_ROTATION; boolean mHasSoftInput = false; + int mBackKillTimeout; int mPointerLocationMode = 0; PointerLocationView mPointerLocationView = null; @@ -796,8 +797,8 @@ public class PhoneWindowManager implements WindowManagerPolicy { public void run() { try { performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false); - IActivityManager mgr = ActivityManagerNative.getDefault(); - List<RunningAppProcessInfo> apps = mgr.getRunningAppProcesses(); + IActivityManager am = ActivityManagerNative.getDefault(); + List<RunningAppProcessInfo> apps = am.getRunningAppProcesses(); for (RunningAppProcessInfo appInfo : apps) { int uid = appInfo.uid; // Make sure it's a foreground user application (not system, @@ -806,9 +807,9 @@ public class PhoneWindowManager implements WindowManagerPolicy { && appInfo.importance == RunningAppProcessInfo.IMPORTANCE_FOREGROUND) { Toast.makeText(mContext, R.string.app_killed_message, Toast.LENGTH_SHORT).show(); // Kill the entire pid - if (appInfo.pkgList!=null && (apps.size() > 0)){ - mgr.forceStopPackage(appInfo.pkgList[0]); - }else{ + if (appInfo.pkgList != null && (apps.size() > 0)) { + am.forceStopPackage(appInfo.pkgList[0]); + } else { Process.killProcess(appInfo.pid); } break; @@ -993,6 +994,8 @@ public class PhoneWindowManager implements WindowManagerPolicy { com.android.internal.R.integer.config_lidKeyboardAccessibility); mLidNavigationAccessibility = mContext.getResources().getInteger( com.android.internal.R.integer.config_lidNavigationAccessibility); + mBackKillTimeout = mContext.getResources().getInteger( + com.android.internal.R.integer.config_backKillTimeout); // register for dock events IntentFilter filter = new IntentFilter(); filter.addAction(UiModeManager.ACTION_ENTER_CAR_MODE); @@ -1894,7 +1897,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { if (Settings.Secure.getInt(mContext.getContentResolver(), Settings.Secure.KILL_APP_LONGPRESS_BACK, 0) == 1) { if (down && repeatCount == 0) { - mHandler.postDelayed(mBackLongPress, ViewConfiguration.getGlobalActionKeyTimeout()); + mHandler.postDelayed(mBackLongPress, mBackKillTimeout); } } } diff --git a/services/java/com/android/server/PowerManagerService.java b/services/java/com/android/server/PowerManagerService.java index 335af64..0878136 100644 --- a/services/java/com/android/server/PowerManagerService.java +++ b/services/java/com/android/server/PowerManagerService.java @@ -1825,7 +1825,7 @@ public class PowerManagerService extends IPowerManager.Stub } if (!mBootCompleted && !mAutoBrightnessButtonKeyboard) { - newState |= ALL_BRIGHT; + newState |= (mKeyboardVisible ? ALL_BRIGHT : SCREEN_BUTTON_BRIGHT); } boolean oldScreenOn = (mPowerState & SCREEN_ON_BIT) != 0; @@ -2422,7 +2422,11 @@ public class PowerManagerService extends IPowerManager.Stub // do not override brightness if the battery is low return state; } - if (!mKeyboardVisible) { + // Ignore mKeyboardVisible if KEYBOARD_BRIGHT_BIT is explicitly set, which + // it will only if the keyboard is visible at the time mPowerState is set. + // Otherwise, if mKeyboardVisible changes afterwards, it's possible for + // the backlight to mismatch mPowerState and remain off. + if (!mKeyboardVisible && (state & KEYBOARD_BRIGHT_BIT) == 0) { brightness = 0; } else if (mButtonBrightnessOverride >= 0) { brightness = mButtonBrightnessOverride; @@ -2817,14 +2821,10 @@ public class PowerManagerService extends IPowerManager.Stub int buttonValue = getAutoBrightnessValue(value, mLastButtonValue, (mCustomLightEnabled ? mCustomLightLevels : mAutoBrightnessLevels), (mCustomLightEnabled ? mCustomButtonValues : mButtonBacklightValues)); - int keyboardValue; - if (mKeyboardVisible) { - keyboardValue = getAutoBrightnessValue(value, mLastKeyboardValue, + int keyboardValue = getAutoBrightnessValue(value, mLastKeyboardValue, (mCustomLightEnabled ? mCustomLightLevels : mAutoBrightnessLevels), (mCustomLightEnabled ? mCustomKeyboardValues : mKeyboardBacklightValues)); - } else { - keyboardValue = 0; - } + mLightSensorScreenBrightness = lcdValue; mLightSensorButtonBrightness = buttonValue; mLightSensorKeyboardBrightness = keyboardValue; @@ -3327,7 +3327,7 @@ public class PowerManagerService extends IPowerManager.Stub setPowerState(SCREEN_BRIGHT); } else { // turn everything on - setPowerState(ALL_BRIGHT); + setPowerState(mKeyboardVisible ? ALL_BRIGHT : SCREEN_BUTTON_BRIGHT); } synchronized (mLocks) { diff --git a/services/java/com/android/server/ProfileManagerService.java b/services/java/com/android/server/ProfileManagerService.java index c99ba8d..aa769a5 100644 --- a/services/java/com/android/server/ProfileManagerService.java +++ b/services/java/com/android/server/ProfileManagerService.java @@ -276,11 +276,24 @@ public class ProfileManagerService extends IProfileManager.Stub { @Override public Profile getProfile(ParcelUuid profileParcelUuid) { UUID profileUuid = profileParcelUuid.getUuid(); - return mProfiles.get(profileUuid); + return getProfile(profileUuid); } public Profile getProfile(UUID profileUuid) { - return mProfiles.get(profileUuid); + // use primary UUID first + if (mProfiles.containsKey(profileUuid)) { + return mProfiles.get(profileUuid); + } + // if no match was found: try secondary UUID + for (Profile p : mProfiles.values()) { + for (UUID uuid : p.getSecondaryUuids()) { + if (profileUuid.equals(uuid)) { + return p; + } + } + } + // nothing found + return null; } @Override diff --git a/telephony/java/com/android/internal/telephony/CallManager.java b/telephony/java/com/android/internal/telephony/CallManager.java index 52c04aa..1f7b8f1 100644 --- a/telephony/java/com/android/internal/telephony/CallManager.java +++ b/telephony/java/com/android/internal/telephony/CallManager.java @@ -398,13 +398,25 @@ public final class CallManager { // Set additional audio parameters needed for incall audio String[] audioParams = context.getResources().getStringArray(com.android.internal.R.array.config_telephony_set_audioparameters); + String[] aPValues; + for (String parameter : audioParams) { + aPValues = parameter.split("="); + + if(aPValues[1] == null || aPValues[1].length() == 0) { + aPValues[1] = "on"; + } + + if(aPValues[2] == null || aPValues[2].length() == 0) { + aPValues[2] = "off"; + } + if (mode == AudioManager.MODE_IN_CALL) { - Log.d(LOG_TAG, "setAudioMode(): " + parameter + "=on"); - audioManager.setParameters(parameter + "=on"); + Log.d(LOG_TAG, "setAudioMode(): " + aPValues[0] + "=" + aPValues[1]); + audioManager.setParameters(aPValues[0] + "=" + aPValues[1]); } else if (mode == AudioManager.MODE_NORMAL) { - Log.d(LOG_TAG, "setAudioMode(): " + parameter + "=off"); - audioManager.setParameters(parameter + "=off"); + Log.d(LOG_TAG, "setAudioMode(): " + aPValues[0] + "=" + aPValues[2]); + audioManager.setParameters(aPValues[0] + "=" + aPValues[2]); } } diff --git a/telephony/java/com/android/internal/telephony/LGEQualcommUiccRIL.java b/telephony/java/com/android/internal/telephony/LGEQualcommUiccRIL.java index 2e3216e..98fe360 100644 --- a/telephony/java/com/android/internal/telephony/LGEQualcommUiccRIL.java +++ b/telephony/java/com/android/internal/telephony/LGEQualcommUiccRIL.java @@ -83,6 +83,20 @@ public class LGEQualcommUiccRIL extends QualcommSharedRIL implements CommandsInt @Override protected Object + responseSetupDataCall(Parcel p) { + DataCallState dataCall; + + boolean oldRil = needsOldRilFeature("datacall"); + + if (!oldRil) + return super.responseSetupDataCall(p); + + p.readString(); + return super.responseSetupDataCall(p); + + } + @Override + protected Object responseIccCardStatus(Parcel p) { IccCardApplication ca; @@ -163,7 +177,7 @@ public class LGEQualcommUiccRIL extends QualcommSharedRIL implements CommandsInt response[i] = -1; noLte = true; } - if (i == 8 && !noLte) { + if (i == 8 && !(noLte || oldRil)) { response[i] *= -1; } } diff --git a/telephony/java/com/android/internal/telephony/Smdk4210RIL.java b/telephony/java/com/android/internal/telephony/Smdk4210RIL.java index bffe375..106e0f8 100644 --- a/telephony/java/com/android/internal/telephony/Smdk4210RIL.java +++ b/telephony/java/com/android/internal/telephony/Smdk4210RIL.java @@ -1,649 +1,648 @@ -/*
- * Copyright (C) 2011 The CyanogenMod Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.internal.telephony;
-
-import static com.android.internal.telephony.RILConstants.*;
-import static android.telephony.TelephonyManager.NETWORK_TYPE_UNKNOWN;
-import static android.telephony.TelephonyManager.NETWORK_TYPE_EDGE;
-import static android.telephony.TelephonyManager.NETWORK_TYPE_GPRS;
-import static android.telephony.TelephonyManager.NETWORK_TYPE_UMTS;
-import static android.telephony.TelephonyManager.NETWORK_TYPE_HSDPA;
-import static android.telephony.TelephonyManager.NETWORK_TYPE_HSUPA;
-import static android.telephony.TelephonyManager.NETWORK_TYPE_HSPA;
-
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.content.res.Resources;
-import android.net.ConnectivityManager;
-import android.net.LocalSocket;
-import android.net.LocalSocketAddress;
-import android.net.NetworkInfo;
-import android.os.AsyncResult;
-import android.os.Handler;
-import android.os.HandlerThread;
-import android.os.Looper;
-import android.os.Message;
-import android.os.Parcel;
-import android.os.PowerManager;
-import android.os.SystemProperties;
-import android.os.PowerManager.WakeLock;
-import android.telephony.NeighboringCellInfo;
-import android.telephony.PhoneNumberUtils;
-import android.telephony.SmsManager;
-import android.telephony.SmsMessage;
-import android.text.TextUtils;
-import android.util.Log;
-
-import com.android.internal.telephony.gsm.SmsBroadcastConfigInfo;
-import com.android.internal.telephony.gsm.SuppServiceNotification;
-import com.android.internal.telephony.cdma.CdmaCallWaitingNotification;
-import com.android.internal.telephony.cdma.CdmaInformationRecords;
-
-import java.io.ByteArrayInputStream;
-import java.io.DataInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Collections;
-
-public class Smdk4210RIL extends RIL implements CommandsInterface {
-
- //SAMSUNG SMDK4210 STATES
- static final int RIL_REQUEST_DIAL_EMERGENCY = 10016;
- static final int RIL_UNSOL_STK_SEND_SMS_RESULT = 11002;
- static final int RIL_UNSOL_O2_HOME_ZONE_INFO = 11007;
- static final int RIL_UNSOL_DEVICE_READY_NOTI = 11008;
- static final int RIL_UNSOL_SAMSUNG_UNKNOWN_MAGIC_REQUEST_1 = 11010;
- static final int RIL_UNSOL_SAMSUNG_UNKNOWN_MAGIC_REQUEST_2 = 11011;
- static final int RIL_UNSOL_SAMSUNG_UNKNOWN_MAGIC_REQUEST_3 = 11012;
- static final int RIL_UNSOL_HSDPA_STATE_CHANGED = 11016;
- protected HandlerThread mSmdk4210Thread;
- protected ConnectivityHandler mSmdk4210Handler;
-
- public Smdk4210RIL(Context context, int networkMode, int cdmaSubscription) {
- super(context, networkMode, cdmaSubscription);
- }
-
- @Override
- public void setCurrentPreferredNetworkType() {
- if (RILJ_LOGD) riljLog("setCurrentPreferredNetworkType IGNORED");
- /* Google added this as a fix for crespo loosing network type after
- * taking an OTA. This messes up the data connection state for us
- * due to the way we handle network type change (disable data
- * then change then re-enable).
- */
- }
-
- private boolean NeedReconnect()
- {
- ConnectivityManager cm =
- (ConnectivityManager)mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
- NetworkInfo ni_active = cm.getActiveNetworkInfo();
-
- return ni_active != null && ni_active.getTypeName().equalsIgnoreCase( "mobile" ) &&
- ni_active.isConnected() && cm.getMobileDataEnabled();
- }
-
- @Override
- public void setPreferredNetworkType(int networkType , Message response) {
- /* Samsung modem implementation does bad things when a datacall is running
- * while switching the preferred networktype.
- */
- HandlerThread handlerThread;
- Looper looper;
-
- if(NeedReconnect())
- {
- if (mSmdk4210Handler == null) {
-
- handlerThread = new HandlerThread("mSmdk4210Thread");
- mSmdk4210Thread = handlerThread;
-
- mSmdk4210Thread.start();
-
- looper = mSmdk4210Thread.getLooper();
- mSmdk4210Handler = new ConnectivityHandler(mContext, looper);
- }
- mSmdk4210Handler.setPreferedNetworkType(networkType, response);
- } else {
- if (mSmdk4210Handler != null) {
- mSmdk4210Thread = null;
- mSmdk4210Handler = null;
- }
- sendPreferedNetworktype(networkType, response);
- }
-
- }
-
- //Sends the real RIL request to the modem.
- private void sendPreferedNetworktype(int networkType, Message response) {
- RILRequest rr = RILRequest.obtain(
- RILConstants.RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE, response);
-
- rr.mp.writeInt(1);
- rr.mp.writeInt(networkType);
-
- if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
- + " : " + networkType);
-
- send(rr);
- }
-
- /* private class that does the handling for the dataconnection
- * dataconnection is done async, so we send the request for disabling it,
- * wait for the response, set the prefered networktype and notify the
- * real sender with its result.
- */
- private class ConnectivityHandler extends Handler{
-
- private static final int MESSAGE_SET_PREFERRED_NETWORK_TYPE = 30;
- private Context mContext;
- private int mDesiredNetworkType;
- //the original message, we need it for calling back the original caller when done
- private Message mNetworktypeResponse;
- private ConnectivityBroadcastReceiver mConnectivityReceiver = new ConnectivityBroadcastReceiver();
-
- public ConnectivityHandler(Context context, Looper looper)
- {
- super (looper);
- mContext = context;
- }
-
- private void startListening() {
- IntentFilter filter = new IntentFilter();
- filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
- mContext.registerReceiver(mConnectivityReceiver, filter);
- }
-
- private synchronized void stopListening() {
- mContext.unregisterReceiver(mConnectivityReceiver);
- }
-
- public void setPreferedNetworkType(int networkType, Message response)
- {
- Log.d(LOG_TAG, "Mobile Dataconnection is online setting it down");
- mDesiredNetworkType = networkType;
- mNetworktypeResponse = response;
- ConnectivityManager cm =
- (ConnectivityManager)mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
- //start listening for the connectivity change broadcast
- startListening();
- cm.setMobileDataEnabled(false);
- }
-
- @Override
- public void handleMessage(Message msg) {
- switch(msg.what) {
- //networktype was set, now we can enable the dataconnection again
- case MESSAGE_SET_PREFERRED_NETWORK_TYPE:
- ConnectivityManager cm =
- (ConnectivityManager)mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
-
- Log.d(LOG_TAG, "preferred NetworkType set upping Mobile Dataconnection");
- cm.setMobileDataEnabled(true);
- //everything done now call back that we have set the networktype
- AsyncResult.forMessage(mNetworktypeResponse, null, null);
- mNetworktypeResponse.sendToTarget();
- mNetworktypeResponse = null;
- break;
- default:
- throw new RuntimeException("unexpected event not handled");
- }
- }
-
- private class ConnectivityBroadcastReceiver extends BroadcastReceiver {
-
- @Override
- public void onReceive(Context context, Intent intent) {
- String action = intent.getAction();
- if (!action.equals(ConnectivityManager.CONNECTIVITY_ACTION)) {
- Log.w(LOG_TAG, "onReceived() called with " + intent);
- return;
- }
- boolean noConnectivity =
- intent.getBooleanExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY, false);
-
- if (noConnectivity) {
- //Ok dataconnection is down, now set the networktype
- Log.w(LOG_TAG, "Mobile Dataconnection is now down setting preferred NetworkType");
- stopListening();
- sendPreferedNetworktype(mDesiredNetworkType, obtainMessage(MESSAGE_SET_PREFERRED_NETWORK_TYPE));
- mDesiredNetworkType = -1;
- }
- }
- }
- }
-
- @Override
- protected void processSolicited (Parcel p) {
- int serial, error;
- boolean found = false;
-
- serial = p.readInt();
- error = p.readInt();
-
- RILRequest rr;
-
- rr = findAndRemoveRequestFromList(serial);
-
- if (rr == null) {
- Log.w(LOG_TAG, "Unexpected solicited response! sn: "
- + serial + " error: " + error);
- return;
- }
-
- Object ret = null;
-
- if (error == 0 || p.dataAvail() > 0) {
- // either command succeeds or command fails but with data payload
- try {switch (rr.mRequest) {
-
- case RIL_REQUEST_GET_SIM_STATUS: ret = responseIccCardStatus(p); break;
- case RIL_REQUEST_ENTER_SIM_PIN: ret = responseInts(p); break;
- case RIL_REQUEST_ENTER_SIM_PUK: ret = responseInts(p); break;
- case RIL_REQUEST_ENTER_SIM_PIN2: ret = responseInts(p); break;
- case RIL_REQUEST_ENTER_SIM_PUK2: ret = responseInts(p); break;
- case RIL_REQUEST_CHANGE_SIM_PIN: ret = responseInts(p); break;
- case RIL_REQUEST_CHANGE_SIM_PIN2: ret = responseInts(p); break;
- case RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION: ret = responseInts(p); break;
- case RIL_REQUEST_GET_CURRENT_CALLS: ret = responseCallList(p); break;
- case RIL_REQUEST_DIAL: ret = responseVoid(p); break;
- case RIL_REQUEST_GET_IMSI: ret = responseString(p); break;
- case RIL_REQUEST_HANGUP: ret = responseVoid(p); break;
- case RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND: ret = responseVoid(p); break;
- case RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND: ret = responseVoid(p); break;
- case RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE: ret = responseVoid(p); break;
- case RIL_REQUEST_CONFERENCE: ret = responseVoid(p); break;
- case RIL_REQUEST_UDUB: ret = responseVoid(p); break;
- case RIL_REQUEST_LAST_CALL_FAIL_CAUSE: ret = responseInts(p); break;
- case RIL_REQUEST_SIGNAL_STRENGTH: ret = responseSignalStrength(p); break;
- case RIL_REQUEST_VOICE_REGISTRATION_STATE: ret = responseStrings(p); break;
- case RIL_REQUEST_DATA_REGISTRATION_STATE: ret = responseStrings(p); break;
- case RIL_REQUEST_OPERATOR: ret = responseStrings(p); break;
- case RIL_REQUEST_RADIO_POWER: ret = responseVoid(p); break;
- case RIL_REQUEST_DTMF: ret = responseVoid(p); break;
- case RIL_REQUEST_SEND_SMS: ret = responseSMS(p); break;
- case RIL_REQUEST_SEND_SMS_EXPECT_MORE: ret = responseSMS(p); break;
- case RIL_REQUEST_SETUP_DATA_CALL: ret = responseSetupDataCall(p); break;
- case RIL_REQUEST_SIM_IO: ret = responseICC_IO(p); break;
- case RIL_REQUEST_SEND_USSD: ret = responseVoid(p); break;
- case RIL_REQUEST_CANCEL_USSD: ret = responseVoid(p); break;
- case RIL_REQUEST_GET_CLIR: ret = responseInts(p); break;
- case RIL_REQUEST_SET_CLIR: ret = responseVoid(p); break;
- case RIL_REQUEST_QUERY_CALL_FORWARD_STATUS: ret = responseCallForward(p); break;
- case RIL_REQUEST_SET_CALL_FORWARD: ret = responseVoid(p); break;
- case RIL_REQUEST_QUERY_CALL_WAITING: ret = responseInts(p); break;
- case RIL_REQUEST_SET_CALL_WAITING: ret = responseVoid(p); break;
- case RIL_REQUEST_SMS_ACKNOWLEDGE: ret = responseVoid(p); break;
- case RIL_REQUEST_GET_IMEI: ret = responseString(p); break;
- case RIL_REQUEST_GET_IMEISV: ret = responseString(p); break;
- case RIL_REQUEST_ANSWER: ret = responseVoid(p); break;
- case RIL_REQUEST_DEACTIVATE_DATA_CALL: ret = responseVoid(p); break;
- case RIL_REQUEST_QUERY_FACILITY_LOCK: ret = responseInts(p); break;
- case RIL_REQUEST_SET_FACILITY_LOCK: ret = responseInts(p); break;
- case RIL_REQUEST_CHANGE_BARRING_PASSWORD: ret = responseVoid(p); break;
- case RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE: ret = responseInts(p); break;
- case RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC: ret = responseVoid(p); break;
- case RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL: ret = responseVoid(p); break;
- case RIL_REQUEST_QUERY_AVAILABLE_NETWORKS : ret = responseOperatorInfos(p); break;
- case RIL_REQUEST_DTMF_START: ret = responseVoid(p); break;
- case RIL_REQUEST_DTMF_STOP: ret = responseVoid(p); break;
- case RIL_REQUEST_BASEBAND_VERSION: ret = responseString(p); break;
- case RIL_REQUEST_SEPARATE_CONNECTION: ret = responseVoid(p); break;
- case RIL_REQUEST_SET_MUTE: ret = responseVoid(p); break;
- case RIL_REQUEST_GET_MUTE: ret = responseInts(p); break;
- case RIL_REQUEST_QUERY_CLIP: ret = responseInts(p); break;
- case RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE: ret = responseInts(p); break;
- case RIL_REQUEST_DATA_CALL_LIST: ret = responseDataCallList(p); break;
- case RIL_REQUEST_RESET_RADIO: ret = responseVoid(p); break;
- case RIL_REQUEST_OEM_HOOK_RAW: ret = responseRaw(p); break;
- case RIL_REQUEST_OEM_HOOK_STRINGS: ret = responseStrings(p); break;
- case RIL_REQUEST_SCREEN_STATE: ret = responseVoid(p); break;
- case RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION: ret = responseVoid(p); break;
- case RIL_REQUEST_WRITE_SMS_TO_SIM: ret = responseInts(p); break;
- case RIL_REQUEST_DELETE_SMS_ON_SIM: ret = responseVoid(p); break;
- case RIL_REQUEST_SET_BAND_MODE: ret = responseVoid(p); break;
- case RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE: ret = responseInts(p); break;
- case RIL_REQUEST_STK_GET_PROFILE: ret = responseString(p); break;
- case RIL_REQUEST_STK_SET_PROFILE: ret = responseVoid(p); break;
- case RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND: ret = responseString(p); break;
- case RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE: ret = responseVoid(p); break;
- case RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM: ret = responseInts(p); break;
- case RIL_REQUEST_EXPLICIT_CALL_TRANSFER: ret = responseVoid(p); break;
- case RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE: ret = responseVoid(p); break;
- case RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE: ret = responseGetPreferredNetworkType(p); break;
- case RIL_REQUEST_GET_NEIGHBORING_CELL_IDS: ret = responseVoid(p); break;
- case RIL_REQUEST_SET_LOCATION_UPDATES: ret = responseVoid(p); break;
- case RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE: ret = responseVoid(p); break;
- case RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE: ret = responseVoid(p); break;
- case RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE: ret = responseInts(p); break;
- case RIL_REQUEST_SET_TTY_MODE: ret = responseVoid(p); break;
- case RIL_REQUEST_QUERY_TTY_MODE: ret = responseInts(p); break;
- case RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE: ret = responseVoid(p); break;
- case RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE: ret = responseInts(p); break;
- case RIL_REQUEST_CDMA_FLASH: ret = responseVoid(p); break;
- case RIL_REQUEST_CDMA_BURST_DTMF: ret = responseVoid(p); break;
- case RIL_REQUEST_CDMA_SEND_SMS: ret = responseSMS(p); break;
- case RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE: ret = responseVoid(p); break;
- case RIL_REQUEST_GSM_GET_BROADCAST_CONFIG: ret = responseGmsBroadcastConfig(p); break;
- case RIL_REQUEST_GSM_SET_BROADCAST_CONFIG: ret = responseVoid(p); break;
- case RIL_REQUEST_GSM_BROADCAST_ACTIVATION: ret = responseVoid(p); break;
- case RIL_REQUEST_CDMA_GET_BROADCAST_CONFIG: ret = responseCdmaBroadcastConfig(p); break;
- case RIL_REQUEST_CDMA_SET_BROADCAST_CONFIG: ret = responseVoid(p); break;
- case RIL_REQUEST_CDMA_BROADCAST_ACTIVATION: ret = responseVoid(p); break;
- case RIL_REQUEST_CDMA_VALIDATE_AND_WRITE_AKEY: ret = responseVoid(p); break;
- case RIL_REQUEST_CDMA_SUBSCRIPTION: ret = responseStrings(p); break;
- case RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM: ret = responseInts(p); break;
- case RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM: ret = responseVoid(p); break;
- case RIL_REQUEST_DEVICE_IDENTITY: ret = responseStrings(p); break;
- case RIL_REQUEST_GET_SMSC_ADDRESS: ret = responseString(p); break;
- case RIL_REQUEST_SET_SMSC_ADDRESS: ret = responseVoid(p); break;
- case RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE: ret = responseVoid(p); break;
- case RIL_REQUEST_REPORT_SMS_MEMORY_STATUS: ret = responseVoid(p); break;
- case RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING: ret = responseVoid(p); break;
- case RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE: ret = responseInts(p); break;
- case RIL_REQUEST_ISIM_AUTHENTICATION: ret = responseString(p); break;
- default:
- throw new RuntimeException("Unrecognized solicited response: " + rr.mRequest);
- //break;
- }} catch (Throwable tr) {
- // Exceptions here usually mean invalid RIL responses
-
- Log.w(LOG_TAG, rr.serialString() + "< "
- + requestToString(rr.mRequest)
- + " exception, possible invalid RIL response", tr);
-
- if (rr.mResult != null) {
- AsyncResult.forMessage(rr.mResult, null, tr);
- rr.mResult.sendToTarget();
- }
- rr.release();
- return;
- }
- }
-
- if (error != 0) {
- //ugly fix for Samsung messing up SMS_SEND request fail in binary RIL
- if(!(error == -1 && rr.mRequest == RIL_REQUEST_SEND_SMS))
- {
- rr.onError(error, ret);
- rr.release();
- return;
- } else {
- try
- {
- ret = responseSMS(p);
- } catch (Throwable tr) {
- Log.w(LOG_TAG, rr.serialString() + "< "
- + requestToString(rr.mRequest)
- + " exception, Processing Samsung SMS fix ", tr);
- rr.onError(error, ret);
- rr.release();
- return;
- }
- }
- }
-
- if (RILJ_LOGD) riljLog(rr.serialString() + "< " + requestToString(rr.mRequest)
- + " " + retToString(rr.mRequest, ret));
-
- if (rr.mResult != null) {
- AsyncResult.forMessage(rr.mResult, ret, null);
- rr.mResult.sendToTarget();
- }
-
- rr.release();
- }
-
- @Override
- protected void
- processUnsolicited (Parcel p) {
- Object ret;
- int dataPosition = p.dataPosition();
- int response = p.readInt();
-
- switch (response) {
- case RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS: ret = responseString(p); break;
- case RIL_UNSOL_RIL_CONNECTED: ret = responseInts(p); break;
- // SAMSUNG STATES
- case RIL_UNSOL_SAMSUNG_UNKNOWN_MAGIC_REQUEST_1: ret = responseVoid(p); break;
- case RIL_UNSOL_SAMSUNG_UNKNOWN_MAGIC_REQUEST_2: ret = responseVoid(p); break;
- case RIL_UNSOL_SAMSUNG_UNKNOWN_MAGIC_REQUEST_3: ret = responseVoid(p); break;
-
- default:
- // Rewind the Parcel
- p.setDataPosition(dataPosition);
-
- // Forward responses that we are not overriding to the super class
- super.processUnsolicited(p);
- return;
- }
-
- switch (response) {
- case RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS:
- if (RILJ_LOGD) unsljLogRet(response, ret);
-
- if (mGsmBroadcastSmsRegistrant != null) {
- mGsmBroadcastSmsRegistrant
- .notifyRegistrant(new AsyncResult(null, ret, null));
- }
- break;
- case RIL_UNSOL_RIL_CONNECTED:
- if (RILJ_LOGD) unsljLogRet(response, ret);
-
- // Initial conditions
- setRadioPower(false, null);
- sendPreferedNetworktype(mPreferredNetworkType, null);
- setCdmaSubscriptionSource(mCdmaSubscription, null);
- notifyRegistrantsRilConnectionChanged(((int[])ret)[0]);
- break;
- // SAMSUNG STATES
- case RIL_UNSOL_SAMSUNG_UNKNOWN_MAGIC_REQUEST_1:
- case RIL_UNSOL_SAMSUNG_UNKNOWN_MAGIC_REQUEST_2:
- case RIL_UNSOL_SAMSUNG_UNKNOWN_MAGIC_REQUEST_3:
- break;
- }
- }
-
- /**
- * Notifiy all registrants that the ril has connected or disconnected.
- *
- * @param rilVer is the version of the ril or -1 if disconnected.
- */
- private void notifyRegistrantsRilConnectionChanged(int rilVer) {
- mRilVersion = rilVer;
- if (mRilConnectedRegistrants != null) {
- mRilConnectedRegistrants.notifyRegistrants(
- new AsyncResult (null, new Integer(rilVer), null));
- }
- }
-
- @Override
- protected Object
- responseCallList(Parcel p) {
- int num;
- int voiceSettings;
- ArrayList<DriverCall> response;
- DriverCall dc;
- int dataAvail = p.dataAvail();
- int pos = p.dataPosition();
- int size = p.dataSize();
-
- Log.d(LOG_TAG, "Parcel size = " + size);
- Log.d(LOG_TAG, "Parcel pos = " + pos);
- Log.d(LOG_TAG, "Parcel dataAvail = " + dataAvail);
-
- //Samsung changes
- num = p.readInt();
-
- Log.d(LOG_TAG, "num = " + num);
- response = new ArrayList<DriverCall>(num);
-
- for (int i = 0 ; i < num ; i++) {
-
- dc = new DriverCall();
-
- dc.state = DriverCall.stateFromCLCC(p.readInt());
- Log.d(LOG_TAG, "state = " + dc.state);
- dc.index = p.readInt();
- Log.d(LOG_TAG, "index = " + dc.index);
- dc.TOA = p.readInt();
- Log.d(LOG_TAG, "state = " + dc.TOA);
- dc.isMpty = (0 != p.readInt());
- Log.d(LOG_TAG, "isMpty = " + dc.isMpty);
- dc.isMT = (0 != p.readInt());
- Log.d(LOG_TAG, "isMT = " + dc.isMT);
- dc.als = p.readInt();
- Log.d(LOG_TAG, "als = " + dc.als);
- voiceSettings = p.readInt();
- dc.isVoice = (0 == voiceSettings) ? false : true;
- Log.d(LOG_TAG, "isVoice = " + dc.isVoice);
- dc.isVoicePrivacy = (0 != p.readInt());
- //Some Samsung magic data for Videocalls
- voiceSettings = p.readInt();
- //printing it to cosole for later investigation
- Log.d(LOG_TAG, "Samsung magic = " + voiceSettings);
- dc.number = p.readString();
- Log.d(LOG_TAG, "number = " + dc.number);
- int np = p.readInt();
- Log.d(LOG_TAG, "np = " + np);
- dc.numberPresentation = DriverCall.presentationFromCLIP(np);
- dc.name = p.readString();
- Log.d(LOG_TAG, "name = " + dc.name);
- dc.namePresentation = p.readInt();
- Log.d(LOG_TAG, "namePresentation = " + dc.namePresentation);
- int uusInfoPresent = p.readInt();
- Log.d(LOG_TAG, "uusInfoPresent = " + uusInfoPresent);
-
- if (uusInfoPresent == 1) {
- dc.uusInfo = new UUSInfo();
- dc.uusInfo.setType(p.readInt());
- dc.uusInfo.setDcs(p.readInt());
- byte[] userData = p.createByteArray();
- dc.uusInfo.setUserData(userData);
- Log
- .v(LOG_TAG, String.format("Incoming UUS : type=%d, dcs=%d, length=%d",
- dc.uusInfo.getType(), dc.uusInfo.getDcs(),
- dc.uusInfo.getUserData().length));
- Log.v(LOG_TAG, "Incoming UUS : data (string)="
- + new String(dc.uusInfo.getUserData()));
- Log.v(LOG_TAG, "Incoming UUS : data (hex): "
- + IccUtils.bytesToHexString(dc.uusInfo.getUserData()));
- } else {
- Log.v(LOG_TAG, "Incoming UUS : NOT present!");
- }
-
- // Make sure there's a leading + on addresses with a TOA of 145
- dc.number = PhoneNumberUtils.stringFromStringAndTOA(dc.number, dc.TOA);
-
- response.add(dc);
-
- if (dc.isVoicePrivacy) {
- mVoicePrivacyOnRegistrants.notifyRegistrants();
- Log.d(LOG_TAG, "InCall VoicePrivacy is enabled");
- } else {
- mVoicePrivacyOffRegistrants.notifyRegistrants();
- Log.d(LOG_TAG, "InCall VoicePrivacy is disabled");
- }
- }
-
- Collections.sort(response);
-
- return response;
- }
-
- @Override
- protected Object responseGetPreferredNetworkType(Parcel p) {
- int [] response = (int[]) responseInts(p);
-
- if (response.length >= 1) {
- // Since this is the response for getPreferredNetworkType
- // we'll assume that it should be the value we want the
- // vendor ril to take if we reestablish a connection to it.
- mPreferredNetworkType = response[0];
- }
-
- // When the modem responds Phone.NT_MODE_GLOBAL, it means Phone.NT_MODE_WCDMA_PREF
- if (response[0] == Phone.NT_MODE_GLOBAL) {
- Log.d(LOG_TAG, "Overriding network type response from GLOBAL to WCDMA preferred");
- response[0] = Phone.NT_MODE_WCDMA_PREF;
- }
-
- return response;
- }
-
- @Override
- protected Object
- responseOperatorInfos(Parcel p) {
- String strings[] = (String [])responseStrings(p);
- ArrayList<OperatorInfo> ret;
-
- if (strings.length % 5 != 0) {
- throw new RuntimeException(
- "RIL_REQUEST_QUERY_AVAILABLE_NETWORKS: invalid response. Got "
- + strings.length + " strings, expected multible of 5");
- }
-
- ret = new ArrayList<OperatorInfo>(strings.length / 5);
-
- for (int i = 0 ; i < strings.length ; i += 5) {
- ret.add (
- new OperatorInfo(
- strings[i+0],
- strings[i+1],
- strings[i+2],
- strings[i+3]));
- }
-
- return ret;
- }
-
- @Override
- protected Object
- responseSignalStrength(Parcel p) {
- int numInts = 12;
- int response[];
-
- /* TODO: Add SignalStrength class to match RIL_SignalStrength */
- response = new int[numInts];
- for (int i = 0 ; i < numInts ; i++) {
- response[i] = p.readInt();
- }
-
- // SamsungRIL is a v3 RIL, fill the rest with -1
- for (int i = 7; i < numInts; i++) {
- response[i] = -1;
- }
-
- /* Matching Samsung signal strength to asu.
- Method taken from Samsungs cdma/gsmSignalStateTracker */
- response[0] = ((response[0] & 0xFF00) >> 8) * 3; //gsmDbm
- response[1] = -1; //gsmEcio
- response[2] = (response[2] < 0)?-120:-response[2]; //cdmaDbm
- response[3] = (response[3] < 0)?-160:-response[3]; //cdmaEcio
- response[4] = (response[4] < 0)?-120:-response[4]; //evdoRssi
- response[5] = (response[5] < 0)?-1:-response[5]; //evdoEcio
- if (response[6] < 0 || response[6] > 8) {
- response[6] = -1;
- }
-
- return response;
- }
-
-}
+/* + * Copyright (C) 2011 The CyanogenMod Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.internal.telephony; + +import static com.android.internal.telephony.RILConstants.*; +import static android.telephony.TelephonyManager.NETWORK_TYPE_UNKNOWN; +import static android.telephony.TelephonyManager.NETWORK_TYPE_EDGE; +import static android.telephony.TelephonyManager.NETWORK_TYPE_GPRS; +import static android.telephony.TelephonyManager.NETWORK_TYPE_UMTS; +import static android.telephony.TelephonyManager.NETWORK_TYPE_HSDPA; +import static android.telephony.TelephonyManager.NETWORK_TYPE_HSUPA; +import static android.telephony.TelephonyManager.NETWORK_TYPE_HSPA; + +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.content.IntentFilter; +import android.content.res.Resources; +import android.net.ConnectivityManager; +import android.net.LocalSocket; +import android.net.LocalSocketAddress; +import android.net.NetworkInfo; +import android.os.AsyncResult; +import android.os.Handler; +import android.os.HandlerThread; +import android.os.Looper; +import android.os.Message; +import android.os.Parcel; +import android.os.PowerManager; +import android.os.SystemProperties; +import android.os.PowerManager.WakeLock; +import android.telephony.NeighboringCellInfo; +import android.telephony.PhoneNumberUtils; +import android.telephony.SmsManager; +import android.telephony.SmsMessage; +import android.text.TextUtils; +import android.util.Log; + +import com.android.internal.telephony.gsm.SmsBroadcastConfigInfo; +import com.android.internal.telephony.gsm.SuppServiceNotification; +import com.android.internal.telephony.cdma.CdmaCallWaitingNotification; +import com.android.internal.telephony.cdma.CdmaInformationRecords; + +import java.io.ByteArrayInputStream; +import java.io.DataInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Collections; + +public class Smdk4210RIL extends RIL implements CommandsInterface { + + //SAMSUNG SMDK4210 STATES + static final int RIL_REQUEST_DIAL_EMERGENCY = 10016; + static final int RIL_UNSOL_STK_SEND_SMS_RESULT = 11002; + static final int RIL_UNSOL_O2_HOME_ZONE_INFO = 11007; + static final int RIL_UNSOL_DEVICE_READY_NOTI = 11008; + static final int RIL_UNSOL_SAMSUNG_UNKNOWN_MAGIC_REQUEST_1 = 11010; + static final int RIL_UNSOL_SAMSUNG_UNKNOWN_MAGIC_REQUEST_2 = 11011; + static final int RIL_UNSOL_SAMSUNG_UNKNOWN_MAGIC_REQUEST_3 = 11012; + static final int RIL_UNSOL_HSDPA_STATE_CHANGED = 11016; + protected HandlerThread mSmdk4210Thread; + protected ConnectivityHandler mSmdk4210Handler; + + public Smdk4210RIL(Context context, int networkMode, int cdmaSubscription) { + super(context, networkMode, cdmaSubscription); + } + + @Override + public void setCurrentPreferredNetworkType() { + if (RILJ_LOGD) riljLog("setCurrentPreferredNetworkType IGNORED"); + /* Google added this as a fix for crespo loosing network type after + * taking an OTA. This messes up the data connection state for us + * due to the way we handle network type change (disable data + * then change then re-enable). + */ + } + + private boolean NeedReconnect() + { + ConnectivityManager cm = + (ConnectivityManager)mContext.getSystemService(Context.CONNECTIVITY_SERVICE); + NetworkInfo ni_active = cm.getActiveNetworkInfo(); + + return ni_active != null && ni_active.getTypeName().equalsIgnoreCase( "mobile" ) && + ni_active.isConnected() && cm.getMobileDataEnabled(); + } + + @Override + public void setPreferredNetworkType(int networkType , Message response) { + /* Samsung modem implementation does bad things when a datacall is running + * while switching the preferred networktype. + */ + HandlerThread handlerThread; + Looper looper; + + if(NeedReconnect()) + { + if (mSmdk4210Handler == null) { + + handlerThread = new HandlerThread("mSmdk4210Thread"); + mSmdk4210Thread = handlerThread; + + mSmdk4210Thread.start(); + + looper = mSmdk4210Thread.getLooper(); + mSmdk4210Handler = new ConnectivityHandler(mContext, looper); + } + mSmdk4210Handler.setPreferedNetworkType(networkType, response); + } else { + if (mSmdk4210Handler != null) { + mSmdk4210Thread = null; + mSmdk4210Handler = null; + } + sendPreferedNetworktype(networkType, response); + } + + } + + //Sends the real RIL request to the modem. + private void sendPreferedNetworktype(int networkType, Message response) { + RILRequest rr = RILRequest.obtain( + RILConstants.RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE, response); + + rr.mp.writeInt(1); + rr.mp.writeInt(networkType); + + if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest) + + " : " + networkType); + + send(rr); + } + + /* private class that does the handling for the dataconnection + * dataconnection is done async, so we send the request for disabling it, + * wait for the response, set the prefered networktype and notify the + * real sender with its result. + */ + private class ConnectivityHandler extends Handler{ + + private static final int MESSAGE_SET_PREFERRED_NETWORK_TYPE = 30; + private Context mContext; + private int mDesiredNetworkType; + //the original message, we need it for calling back the original caller when done + private Message mNetworktypeResponse; + private ConnectivityBroadcastReceiver mConnectivityReceiver = new ConnectivityBroadcastReceiver(); + + public ConnectivityHandler(Context context, Looper looper) + { + super (looper); + mContext = context; + } + + private void startListening() { + IntentFilter filter = new IntentFilter(); + filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); + mContext.registerReceiver(mConnectivityReceiver, filter); + } + + private synchronized void stopListening() { + mContext.unregisterReceiver(mConnectivityReceiver); + } + + public void setPreferedNetworkType(int networkType, Message response) + { + Log.d(LOG_TAG, "Mobile Dataconnection is online setting it down"); + mDesiredNetworkType = networkType; + mNetworktypeResponse = response; + ConnectivityManager cm = + (ConnectivityManager)mContext.getSystemService(Context.CONNECTIVITY_SERVICE); + //start listening for the connectivity change broadcast + startListening(); + cm.setMobileDataEnabled(false); + } + + @Override + public void handleMessage(Message msg) { + switch(msg.what) { + //networktype was set, now we can enable the dataconnection again + case MESSAGE_SET_PREFERRED_NETWORK_TYPE: + ConnectivityManager cm = + (ConnectivityManager)mContext.getSystemService(Context.CONNECTIVITY_SERVICE); + + Log.d(LOG_TAG, "preferred NetworkType set upping Mobile Dataconnection"); + cm.setMobileDataEnabled(true); + //everything done now call back that we have set the networktype + AsyncResult.forMessage(mNetworktypeResponse, null, null); + mNetworktypeResponse.sendToTarget(); + mNetworktypeResponse = null; + break; + default: + throw new RuntimeException("unexpected event not handled"); + } + } + + private class ConnectivityBroadcastReceiver extends BroadcastReceiver { + + @Override + public void onReceive(Context context, Intent intent) { + String action = intent.getAction(); + if (!action.equals(ConnectivityManager.CONNECTIVITY_ACTION)) { + Log.w(LOG_TAG, "onReceived() called with " + intent); + return; + } + boolean noConnectivity = + intent.getBooleanExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY, false); + + if (noConnectivity) { + //Ok dataconnection is down, now set the networktype + Log.w(LOG_TAG, "Mobile Dataconnection is now down setting preferred NetworkType"); + stopListening(); + sendPreferedNetworktype(mDesiredNetworkType, obtainMessage(MESSAGE_SET_PREFERRED_NETWORK_TYPE)); + mDesiredNetworkType = -1; + } + } + } + } + + @Override + protected void processSolicited (Parcel p) { + int serial, error; + boolean found = false; + + serial = p.readInt(); + error = p.readInt(); + + RILRequest rr; + + rr = findAndRemoveRequestFromList(serial); + + if (rr == null) { + Log.w(LOG_TAG, "Unexpected solicited response! sn: " + + serial + " error: " + error); + return; + } + + Object ret = null; + + if (error == 0 || p.dataAvail() > 0) { + // either command succeeds or command fails but with data payload + try {switch (rr.mRequest) { + + case RIL_REQUEST_GET_SIM_STATUS: ret = responseIccCardStatus(p); break; + case RIL_REQUEST_ENTER_SIM_PIN: ret = responseInts(p); break; + case RIL_REQUEST_ENTER_SIM_PUK: ret = responseInts(p); break; + case RIL_REQUEST_ENTER_SIM_PIN2: ret = responseInts(p); break; + case RIL_REQUEST_ENTER_SIM_PUK2: ret = responseInts(p); break; + case RIL_REQUEST_CHANGE_SIM_PIN: ret = responseInts(p); break; + case RIL_REQUEST_CHANGE_SIM_PIN2: ret = responseInts(p); break; + case RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION: ret = responseInts(p); break; + case RIL_REQUEST_GET_CURRENT_CALLS: ret = responseCallList(p); break; + case RIL_REQUEST_DIAL: ret = responseVoid(p); break; + case RIL_REQUEST_GET_IMSI: ret = responseString(p); break; + case RIL_REQUEST_HANGUP: ret = responseVoid(p); break; + case RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND: ret = responseVoid(p); break; + case RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND: ret = responseVoid(p); break; + case RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE: ret = responseVoid(p); break; + case RIL_REQUEST_CONFERENCE: ret = responseVoid(p); break; + case RIL_REQUEST_UDUB: ret = responseVoid(p); break; + case RIL_REQUEST_LAST_CALL_FAIL_CAUSE: ret = responseInts(p); break; + case RIL_REQUEST_SIGNAL_STRENGTH: ret = responseSignalStrength(p); break; + case RIL_REQUEST_VOICE_REGISTRATION_STATE: ret = responseStrings(p); break; + case RIL_REQUEST_DATA_REGISTRATION_STATE: ret = responseStrings(p); break; + case RIL_REQUEST_OPERATOR: ret = responseStrings(p); break; + case RIL_REQUEST_RADIO_POWER: ret = responseVoid(p); break; + case RIL_REQUEST_DTMF: ret = responseVoid(p); break; + case RIL_REQUEST_SEND_SMS: ret = responseSMS(p); break; + case RIL_REQUEST_SEND_SMS_EXPECT_MORE: ret = responseSMS(p); break; + case RIL_REQUEST_SETUP_DATA_CALL: ret = responseSetupDataCall(p); break; + case RIL_REQUEST_SIM_IO: ret = responseICC_IO(p); break; + case RIL_REQUEST_SEND_USSD: ret = responseVoid(p); break; + case RIL_REQUEST_CANCEL_USSD: ret = responseVoid(p); break; + case RIL_REQUEST_GET_CLIR: ret = responseInts(p); break; + case RIL_REQUEST_SET_CLIR: ret = responseVoid(p); break; + case RIL_REQUEST_QUERY_CALL_FORWARD_STATUS: ret = responseCallForward(p); break; + case RIL_REQUEST_SET_CALL_FORWARD: ret = responseVoid(p); break; + case RIL_REQUEST_QUERY_CALL_WAITING: ret = responseInts(p); break; + case RIL_REQUEST_SET_CALL_WAITING: ret = responseVoid(p); break; + case RIL_REQUEST_SMS_ACKNOWLEDGE: ret = responseVoid(p); break; + case RIL_REQUEST_GET_IMEI: ret = responseString(p); break; + case RIL_REQUEST_GET_IMEISV: ret = responseString(p); break; + case RIL_REQUEST_ANSWER: ret = responseVoid(p); break; + case RIL_REQUEST_DEACTIVATE_DATA_CALL: ret = responseVoid(p); break; + case RIL_REQUEST_QUERY_FACILITY_LOCK: ret = responseInts(p); break; + case RIL_REQUEST_SET_FACILITY_LOCK: ret = responseInts(p); break; + case RIL_REQUEST_CHANGE_BARRING_PASSWORD: ret = responseVoid(p); break; + case RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE: ret = responseInts(p); break; + case RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC: ret = responseVoid(p); break; + case RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL: ret = responseVoid(p); break; + case RIL_REQUEST_QUERY_AVAILABLE_NETWORKS : ret = responseOperatorInfos(p); break; + case RIL_REQUEST_DTMF_START: ret = responseVoid(p); break; + case RIL_REQUEST_DTMF_STOP: ret = responseVoid(p); break; + case RIL_REQUEST_BASEBAND_VERSION: ret = responseString(p); break; + case RIL_REQUEST_SEPARATE_CONNECTION: ret = responseVoid(p); break; + case RIL_REQUEST_SET_MUTE: ret = responseVoid(p); break; + case RIL_REQUEST_GET_MUTE: ret = responseInts(p); break; + case RIL_REQUEST_QUERY_CLIP: ret = responseInts(p); break; + case RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE: ret = responseInts(p); break; + case RIL_REQUEST_DATA_CALL_LIST: ret = responseDataCallList(p); break; + case RIL_REQUEST_RESET_RADIO: ret = responseVoid(p); break; + case RIL_REQUEST_OEM_HOOK_RAW: ret = responseRaw(p); break; + case RIL_REQUEST_OEM_HOOK_STRINGS: ret = responseStrings(p); break; + case RIL_REQUEST_SCREEN_STATE: ret = responseVoid(p); break; + case RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION: ret = responseVoid(p); break; + case RIL_REQUEST_WRITE_SMS_TO_SIM: ret = responseInts(p); break; + case RIL_REQUEST_DELETE_SMS_ON_SIM: ret = responseVoid(p); break; + case RIL_REQUEST_SET_BAND_MODE: ret = responseVoid(p); break; + case RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE: ret = responseInts(p); break; + case RIL_REQUEST_STK_GET_PROFILE: ret = responseString(p); break; + case RIL_REQUEST_STK_SET_PROFILE: ret = responseVoid(p); break; + case RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND: ret = responseString(p); break; + case RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE: ret = responseVoid(p); break; + case RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM: ret = responseInts(p); break; + case RIL_REQUEST_EXPLICIT_CALL_TRANSFER: ret = responseVoid(p); break; + case RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE: ret = responseVoid(p); break; + case RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE: ret = responseGetPreferredNetworkType(p); break; + case RIL_REQUEST_GET_NEIGHBORING_CELL_IDS: ret = responseVoid(p); break; + case RIL_REQUEST_SET_LOCATION_UPDATES: ret = responseVoid(p); break; + case RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE: ret = responseVoid(p); break; + case RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE: ret = responseVoid(p); break; + case RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE: ret = responseInts(p); break; + case RIL_REQUEST_SET_TTY_MODE: ret = responseVoid(p); break; + case RIL_REQUEST_QUERY_TTY_MODE: ret = responseInts(p); break; + case RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE: ret = responseVoid(p); break; + case RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE: ret = responseInts(p); break; + case RIL_REQUEST_CDMA_FLASH: ret = responseVoid(p); break; + case RIL_REQUEST_CDMA_BURST_DTMF: ret = responseVoid(p); break; + case RIL_REQUEST_CDMA_SEND_SMS: ret = responseSMS(p); break; + case RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE: ret = responseVoid(p); break; + case RIL_REQUEST_GSM_GET_BROADCAST_CONFIG: ret = responseGmsBroadcastConfig(p); break; + case RIL_REQUEST_GSM_SET_BROADCAST_CONFIG: ret = responseVoid(p); break; + case RIL_REQUEST_GSM_BROADCAST_ACTIVATION: ret = responseVoid(p); break; + case RIL_REQUEST_CDMA_GET_BROADCAST_CONFIG: ret = responseCdmaBroadcastConfig(p); break; + case RIL_REQUEST_CDMA_SET_BROADCAST_CONFIG: ret = responseVoid(p); break; + case RIL_REQUEST_CDMA_BROADCAST_ACTIVATION: ret = responseVoid(p); break; + case RIL_REQUEST_CDMA_VALIDATE_AND_WRITE_AKEY: ret = responseVoid(p); break; + case RIL_REQUEST_CDMA_SUBSCRIPTION: ret = responseStrings(p); break; + case RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM: ret = responseInts(p); break; + case RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM: ret = responseVoid(p); break; + case RIL_REQUEST_DEVICE_IDENTITY: ret = responseStrings(p); break; + case RIL_REQUEST_GET_SMSC_ADDRESS: ret = responseString(p); break; + case RIL_REQUEST_SET_SMSC_ADDRESS: ret = responseVoid(p); break; + case RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE: ret = responseVoid(p); break; + case RIL_REQUEST_REPORT_SMS_MEMORY_STATUS: ret = responseVoid(p); break; + case RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING: ret = responseVoid(p); break; + case RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE: ret = responseInts(p); break; + case RIL_REQUEST_ISIM_AUTHENTICATION: ret = responseString(p); break; + default: + throw new RuntimeException("Unrecognized solicited response: " + rr.mRequest); + //break; + }} catch (Throwable tr) { + // Exceptions here usually mean invalid RIL responses + + Log.w(LOG_TAG, rr.serialString() + "< " + + requestToString(rr.mRequest) + + " exception, possible invalid RIL response", tr); + + if (rr.mResult != null) { + AsyncResult.forMessage(rr.mResult, null, tr); + rr.mResult.sendToTarget(); + } + rr.release(); + return; + } + } + + if (error != 0) { + //ugly fix for Samsung messing up SMS_SEND request fail in binary RIL + if(!(error == -1 && rr.mRequest == RIL_REQUEST_SEND_SMS)) + { + rr.onError(error, ret); + rr.release(); + return; + } else { + try + { + ret = responseSMS(p); + } catch (Throwable tr) { + Log.w(LOG_TAG, rr.serialString() + "< " + + requestToString(rr.mRequest) + + " exception, Processing Samsung SMS fix ", tr); + rr.onError(error, ret); + rr.release(); + return; + } + } + } + + if (RILJ_LOGD) riljLog(rr.serialString() + "< " + requestToString(rr.mRequest) + + " " + retToString(rr.mRequest, ret)); + + if (rr.mResult != null) { + AsyncResult.forMessage(rr.mResult, ret, null); + rr.mResult.sendToTarget(); + } + + rr.release(); + } + + @Override + protected void + processUnsolicited (Parcel p) { + Object ret; + int dataPosition = p.dataPosition(); + int response = p.readInt(); + + switch (response) { + case RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS: ret = responseString(p); break; + case RIL_UNSOL_RIL_CONNECTED: ret = responseInts(p); break; + // SAMSUNG STATES + case RIL_UNSOL_SAMSUNG_UNKNOWN_MAGIC_REQUEST_1: ret = responseVoid(p); break; + case RIL_UNSOL_SAMSUNG_UNKNOWN_MAGIC_REQUEST_2: ret = responseVoid(p); break; + case RIL_UNSOL_SAMSUNG_UNKNOWN_MAGIC_REQUEST_3: ret = responseVoid(p); break; + + default: + // Rewind the Parcel + p.setDataPosition(dataPosition); + + // Forward responses that we are not overriding to the super class + super.processUnsolicited(p); + return; + } + + switch (response) { + case RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS: + if (RILJ_LOGD) unsljLogRet(response, ret); + + if (mGsmBroadcastSmsRegistrant != null) { + mGsmBroadcastSmsRegistrant + .notifyRegistrant(new AsyncResult(null, ret, null)); + } + break; + case RIL_UNSOL_RIL_CONNECTED: + if (RILJ_LOGD) unsljLogRet(response, ret); + + // Initial conditions + setRadioPower(false, null); + sendPreferedNetworktype(mPreferredNetworkType, null); + setCdmaSubscriptionSource(mCdmaSubscription, null); + notifyRegistrantsRilConnectionChanged(((int[])ret)[0]); + break; + // SAMSUNG STATES + case RIL_UNSOL_SAMSUNG_UNKNOWN_MAGIC_REQUEST_1: + case RIL_UNSOL_SAMSUNG_UNKNOWN_MAGIC_REQUEST_2: + case RIL_UNSOL_SAMSUNG_UNKNOWN_MAGIC_REQUEST_3: + break; + } + } + + /** + * Notifiy all registrants that the ril has connected or disconnected. + * + * @param rilVer is the version of the ril or -1 if disconnected. + */ + private void notifyRegistrantsRilConnectionChanged(int rilVer) { + mRilVersion = rilVer; + if (mRilConnectedRegistrants != null) { + mRilConnectedRegistrants.notifyRegistrants( + new AsyncResult (null, new Integer(rilVer), null)); + } + } + + @Override + protected Object + responseCallList(Parcel p) { + int num; + int voiceSettings; + ArrayList<DriverCall> response; + DriverCall dc; + int dataAvail = p.dataAvail(); + int pos = p.dataPosition(); + int size = p.dataSize(); + + Log.d(LOG_TAG, "Parcel size = " + size); + Log.d(LOG_TAG, "Parcel pos = " + pos); + Log.d(LOG_TAG, "Parcel dataAvail = " + dataAvail); + + //Samsung changes + num = p.readInt(); + + Log.d(LOG_TAG, "num = " + num); + response = new ArrayList<DriverCall>(num); + + for (int i = 0 ; i < num ; i++) { + + dc = new DriverCall(); + + dc.state = DriverCall.stateFromCLCC(p.readInt()); + Log.d(LOG_TAG, "state = " + dc.state); + dc.index = p.readInt(); + Log.d(LOG_TAG, "index = " + dc.index); + dc.TOA = p.readInt(); + Log.d(LOG_TAG, "state = " + dc.TOA); + dc.isMpty = (0 != p.readInt()); + Log.d(LOG_TAG, "isMpty = " + dc.isMpty); + dc.isMT = (0 != p.readInt()); + Log.d(LOG_TAG, "isMT = " + dc.isMT); + dc.als = p.readInt(); + Log.d(LOG_TAG, "als = " + dc.als); + voiceSettings = p.readInt(); + dc.isVoice = (0 == voiceSettings) ? false : true; + Log.d(LOG_TAG, "isVoice = " + dc.isVoice); + dc.isVoicePrivacy = (0 != p.readInt()); + //Some Samsung magic data for Videocalls + voiceSettings = p.readInt(); + //printing it to cosole for later investigation + Log.d(LOG_TAG, "Samsung magic = " + voiceSettings); + dc.number = p.readString(); + Log.d(LOG_TAG, "number = " + dc.number); + int np = p.readInt(); + Log.d(LOG_TAG, "np = " + np); + dc.numberPresentation = DriverCall.presentationFromCLIP(np); + dc.name = p.readString(); + Log.d(LOG_TAG, "name = " + dc.name); + dc.namePresentation = p.readInt(); + Log.d(LOG_TAG, "namePresentation = " + dc.namePresentation); + int uusInfoPresent = p.readInt(); + Log.d(LOG_TAG, "uusInfoPresent = " + uusInfoPresent); + + if (uusInfoPresent == 1) { + dc.uusInfo = new UUSInfo(); + dc.uusInfo.setType(p.readInt()); + dc.uusInfo.setDcs(p.readInt()); + byte[] userData = p.createByteArray(); + dc.uusInfo.setUserData(userData); + Log + .v(LOG_TAG, String.format("Incoming UUS : type=%d, dcs=%d, length=%d", + dc.uusInfo.getType(), dc.uusInfo.getDcs(), + dc.uusInfo.getUserData().length)); + Log.v(LOG_TAG, "Incoming UUS : data (string)=" + + new String(dc.uusInfo.getUserData())); + Log.v(LOG_TAG, "Incoming UUS : data (hex): " + + IccUtils.bytesToHexString(dc.uusInfo.getUserData())); + } else { + Log.v(LOG_TAG, "Incoming UUS : NOT present!"); + } + + // Make sure there's a leading + on addresses with a TOA of 145 + dc.number = PhoneNumberUtils.stringFromStringAndTOA(dc.number, dc.TOA); + + response.add(dc); + + if (dc.isVoicePrivacy) { + mVoicePrivacyOnRegistrants.notifyRegistrants(); + Log.d(LOG_TAG, "InCall VoicePrivacy is enabled"); + } else { + mVoicePrivacyOffRegistrants.notifyRegistrants(); + Log.d(LOG_TAG, "InCall VoicePrivacy is disabled"); + } + } + + Collections.sort(response); + + return response; + } + + @Override + protected Object responseGetPreferredNetworkType(Parcel p) { + int [] response = (int[]) responseInts(p); + + if (response.length >= 1) { + // Since this is the response for getPreferredNetworkType + // we'll assume that it should be the value we want the + // vendor ril to take if we reestablish a connection to it. + mPreferredNetworkType = response[0]; + } + + // When the modem responds Phone.NT_MODE_GLOBAL, it means Phone.NT_MODE_WCDMA_PREF + if (response[0] == Phone.NT_MODE_GLOBAL) { + Log.d(LOG_TAG, "Overriding network type response from GLOBAL to WCDMA preferred"); + response[0] = Phone.NT_MODE_WCDMA_PREF; + } + + return response; + } + + @Override + protected Object + responseOperatorInfos(Parcel p) { + String strings[] = (String [])responseStrings(p); + ArrayList<OperatorInfo> ret; + + if (strings.length % 5 != 0) { + throw new RuntimeException( + "RIL_REQUEST_QUERY_AVAILABLE_NETWORKS: invalid response. Got " + + strings.length + " strings, expected multible of 5"); + } + + ret = new ArrayList<OperatorInfo>(strings.length / 5); + + for (int i = 0 ; i < strings.length ; i += 5) { + ret.add ( + new OperatorInfo( + strings[i+0], + strings[i+1], + strings[i+2], + strings[i+3])); + } + + return ret; + } + + @Override + protected Object + responseSignalStrength(Parcel p) { + int numInts = 12; + int response[]; + + /* TODO: Add SignalStrength class to match RIL_SignalStrength */ + response = new int[numInts]; + for (int i = 0 ; i < numInts ; i++) { + response[i] = p.readInt(); + } + + // SamsungRIL is a v3 RIL, fill the rest with -1 + for (int i = 7; i < numInts; i++) { + response[i] = -1; + } + + /* Matching Samsung signal strength to asu. + Method taken from Samsungs cdma/gsmSignalStateTracker */ + response[0] = ((response[0] & 0xFF00) >> 8) * 3; //gsmDbm + response[1] = -1; //gsmEcio + response[2] = (response[2] < 0)?-120:-response[2]; //cdmaDbm + response[3] = (response[3] < 0)?-160:-response[3]; //cdmaEcio + response[4] = (response[4] < 0)?-120:-response[4]; //evdoRssi + response[5] = (response[5] < 0)?-1:-response[5]; //evdoEcio + if (response[6] < 0 || response[6] > 8) { + response[6] = -1; + } + + return response; + } +} |