修改代码适配 android 8.1
authorSnickerSun <scy@incartech.cn>
Fri, 6 Aug 2021 09:34:52 +0000 (17:34 +0800)
committerSnickerSun <scy@incartech.cn>
Fri, 6 Aug 2021 09:34:52 +0000 (17:34 +0800)
已完成: GPS,LBS,WiFi,AlarmManager , AT指令
未完成: 蓝牙ble扫描 还未 适配完毕, apn 还不能设置,心率,体温 还不能测试。

20 files changed:
app/build.gradle
app/libs/8.1_framework_full_debug.jar [new file with mode: 0644]
app/libs/8.1_telephony-common_full_debug.jar [new file with mode: 0644]
app/src/main/AndroidManifest.xml
app/src/main/java/com/enqualcomm/support/CoreService.java
app/src/main/java/com/enqualcomm/support/GPSActivity.java
app/src/main/java/com/enqualcomm/support/adapter/BTHelper.java
app/src/main/java/com/enqualcomm/support/service/HeartRateManager.java
app/src/main/java/com/enqualcomm/support/utils/APNUtil.java
app/src/main/java/com/enqualcomm/support/utils/AlarmHelper.java
app/src/main/java/com/enqualcomm/support/utils/ApnEditor.java
app/src/main/java/com/enqualcomm/support/utils/CellInfoUtil.java
app/src/main/java/com/enqualcomm/support/utils/IATUtils.java [new file with mode: 0644]
app/src/main/java/com/enqualcomm/support/utils/ICAudioManager.java
app/src/main/java/com/enqualcomm/support/utils/ImageUtil.java
app/src/main/java/com/enqualcomm/support/utils/SimSignalUtil.java
app/src/main/java/com/enqualcomm/support/utils/TemperatureUtil.java
app/src/main/java/com/ic/jni/AtCMD.java [new file with mode: 0644]
build.gradle
local.properties

index b84b7c4..852fb4f 100644 (file)
@@ -7,8 +7,8 @@ static def getApkBaseName() {
 }
 
 android {
-    compileSdkVersion 25
-    buildToolsVersion "25.0.1"
+    compileSdkVersion 29
+    buildToolsVersion "29.0.3"
     def currentVersionCode = getVersionCode()
     def currentVersionName = releaseTime()
     defaultConfig {
@@ -83,9 +83,12 @@ android {
 //    }
 }
 dependencies {
-    compileOnly files('libs/telephony-common-full-debug.jar')
-    compileOnly files('libs/frameworks-full-debug.jar')
-    compileOnly files('libs/frameworks-2-full-debug.jar')
+//    compileOnly files('libs/telephony-common-full-debug.jar')
+//    compileOnly files('libs/frameworks-full-debug.jar')
+//    compileOnly files('libs/frameworks-2-full-debug.jar')
+    compileOnly files('libs/8.1_telephony-common_full_debug.jar')
+    compileOnly files('libs/8.1_framework_full_debug.jar')
+
 
     implementation 'com.android.support.constraint:constraint-layout:1.1.3'
     //compile fileTree(include: ['*.jar', '*.aar'], dir: 'libs')
diff --git a/app/libs/8.1_framework_full_debug.jar b/app/libs/8.1_framework_full_debug.jar
new file mode 100644 (file)
index 0000000..5d0e384
Binary files /dev/null and b/app/libs/8.1_framework_full_debug.jar differ
diff --git a/app/libs/8.1_telephony-common_full_debug.jar b/app/libs/8.1_telephony-common_full_debug.jar
new file mode 100644 (file)
index 0000000..6d84a9f
Binary files /dev/null and b/app/libs/8.1_telephony-common_full_debug.jar differ
index 3a2a862..fe78fb2 100644 (file)
@@ -48,6 +48,8 @@
     <!-- <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"></uses-permission> -->
     <!-- 用于获取wifi的获取权限,wifi信息会用来进行网络定位 -->
     <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
+
+    <uses-permission android:name="android.permission.CONTROL_LOCATION_UPDATES" />
     <!-- 用于访问网络,网络定位需要上网 -->
     <!-- <uses-permission android:name="android.permission.INTERNET"></uses-permission> -->
     <!-- 用于读取手机当前的状态 -->
@@ -80,7 +82,7 @@
     <uses-permission android:name="android.permission.READ_LOGS"></uses-permission>
 
     <uses-permission android:name="android.permission.READ_CONTACTS"></uses-permission>
-
+    <uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
 
     <uses-feature android:name="android.hardware.camera" />
     <uses-feature android:name="android.hardware.camera.autofocus" />
index ff9e0c4..8604f4d 100644 (file)
@@ -3,6 +3,8 @@ package com.enqualcomm.support;
 import android.app.ActivityManager;
 import android.app.AlarmManager;
 import android.app.Notification;
+import android.app.NotificationChannel;
+import android.app.NotificationManager;
 import android.app.PendingIntent;
 import android.app.Service;
 import android.content.BroadcastReceiver;
@@ -14,6 +16,7 @@ import android.content.IntentFilter;
 import android.database.Cursor;
 import android.media.AudioManager;
 import android.net.Uri;
+import android.os.Build;
 import android.os.Handler;
 import android.os.HandlerThread;
 import android.os.IBinder;
@@ -132,6 +135,7 @@ public class CoreService extends Service {
 
     private static final int GRAY_SERVICE_ID = android.os.Process.myPid();
 
+    public static String CHANNEL_ID_STRING = CoreService.class.getPackage().getName();
     private static final String MY_WAKE_LOCKTAG = CoreService.class.getSimpleName();
 
     public static final int interval = 60000;
@@ -869,11 +873,22 @@ public class CoreService extends Service {
 
         this.locationClient.init();
         //设置本service为前台运行,不被会被清理
-        Notification notification = new Notification();
-        notification.flags = Notification.FLAG_ONGOING_EVENT;
-        notification.flags |= Notification.FLAG_NO_CLEAR;
-        notification.flags |= Notification.FLAG_FOREGROUND_SERVICE;
-        startForeground(GRAY_SERVICE_ID, notification);
+
+        //适配8.0service
+        NotificationManager notificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);
+        NotificationChannel mChannel = null;
+        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
+            mChannel = new NotificationChannel(CHANNEL_ID_STRING, " ", NotificationManager.IMPORTANCE_HIGH);
+            notificationManager.createNotificationChannel(mChannel);
+            Notification notification = new Notification.Builder(getApplicationContext(), CHANNEL_ID_STRING).build();
+            notification.flags = Notification.FLAG_ONGOING_EVENT;
+            notification.flags |= Notification.FLAG_NO_CLEAR;
+            notification.flags |= Notification.FLAG_FOREGROUND_SERVICE;
+            startForeground(GRAY_SERVICE_ID, notification);
+        }
+
+
+
 
         //注册接收  时间和tiimezone 变更消息
         IntentFilter intentFilter = new IntentFilter();
@@ -987,9 +1002,14 @@ public class CoreService extends Service {
         //有新消息就发送出去
         ContentResolver resolver = runtime.getContextProxy().getResolver();
         WeTalkMsgObserver weTalkMsgObserver = new WeTalkMsgObserver(mHandler, resolver);
-        resolver.registerContentObserver(
-                Uri.parse(WeTalkMessageProvider.MESSAGES_SEND), true, weTalkMsgObserver
-        );
+        try {
+            resolver.registerContentObserver(
+                    Uri.parse(WeTalkMessageProvider.MESSAGES_SEND), true, weTalkMsgObserver
+            );
+        }catch (Exception e){
+            ICLogger.e(e.getMessage(),e);
+        }
+
         //启动结束设置标志位,让心率和体温检测可以正常执行。
         server_starting = false;
 
@@ -1658,9 +1678,33 @@ public class CoreService extends Service {
 
         /*给 API >= 18 的平台上用的灰色保活手段*/
         public int onStartCommand(Intent param1Intent, int param1Int1, int param1Int2) {
-            startForeground(GRAY_SERVICE_ID, new Notification());
-            stopForeground(true);
-            stopSelf();
+
+//            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
+//                Notification.Builder builder = new Notification.Builder(this);
+//
+//                builder.setSmallIcon(R.mipmap.ic_launcher);
+//
+//                builder.setContentTitle("KeepAppAlive");
+//
+//                builder.setContentText("DaemonService is runing...");
+//
+//                startForeground(GRAY_SERVICE_ID, builder.build());
+
+// 如果觉得常驻通知栏体验不好
+
+// 可以通过启动CancelNoticeService,将通知移除,oom_adj值不变
+
+//                Intent intent = new Intent(this, CoreService.class);
+//
+//                startService(intent);
+//
+//            } else {
+//                startForeground(GRAY_SERVICE_ID, new Notification());
+//
+//            }
+//            startForeground(GRAY_SERVICE_ID, new Notification());
+//            stopForeground(true);
+//            stopSelf();
             return super.onStartCommand(param1Intent, param1Int1, param1Int2);
         }
     }
index 7eec8db..2801c34 100644 (file)
@@ -4,7 +4,11 @@ import android.app.Activity;
 import android.graphics.Color;\r
 import android.graphics.Rect;\r
 import android.os.Bundle;\r
+import android.os.Handler;\r
+import android.os.HandlerThread;\r
+import android.os.Message;\r
 import android.os.PowerManager;\r
+import android.support.annotation.NonNull;\r
 import android.support.v7.app.AppCompatActivity;\r
 import android.support.v7.widget.LinearLayoutManager;\r
 import android.support.v7.widget.RecyclerView;\r
@@ -31,7 +35,8 @@ public class GPSActivity extends Activity implements location_callback {
     private TextView mSearchCount;\r
     private boolean showmessage=false;\r
     final LocationSnrAdapter adapter = new LocationSnrAdapter(testSnrEntriyDate(null));\r
-\r
+    private Handler mHandler = null;\r
+    ICLocation.GPS_locationStatus g_gps_status=null;\r
     @Override\r
     protected void onCreate(Bundle savedInstanceState) {\r
         super.onCreate(savedInstanceState);\r
@@ -52,31 +57,48 @@ public class GPSActivity extends Activity implements location_callback {
         mStar.setText("0 in 0/ inMap 0");\r
         mHoop.setText("0.0米");\r
         mSearchCount.setText("0秒");\r
+        if (mHandler == null) {\r
+            mHandler = new Handler(this.getMainLooper(),new Handler.Callback(){\r
+                @Override\r
+                public boolean handleMessage(@NonNull Message msg) {\r
+                    if (g_gps_status !=null) {\r
+                        List<ICLocation.GpsSatellitePriv> gpslist = g_gps_status.numSatelliteList;\r
+                        adapter.updateLocationValue(testSnrEntriyDate(gpslist));\r
+                        String fixed = new StringBuilder().append(g_gps_status.locating_status > 0 ?\r
+                                "Fixed " : "notFixed ").append(TimeUtil.getLocalTime2()).toString();\r
+                        String satlites = new StringBuilder("used ").append(g_gps_status.used_gps_numbs).append(" in ")\r
+                                .append(g_gps_status.numSatelliteList.size()).append("/ inMap ").append(g_gps_status.satlite_numbss).toString();\r
+                        String locationTime = new StringBuilder().append(g_gps_status.search_time_cost).append("秒").toString();\r
+                        String hdop = new StringBuilder().append(String.valueOf(g_gps_status.hdop)).append("米").toString();\r
+                        mFix.setText(fixed);\r
+                        if (mFix.getText().toString().contains("notFixed")) {\r
+                            mFix.setBackgroundColor(Color.RED);\r
+                            mFix.setTextColor(Color.WHITE);\r
+                        } else {\r
+                            mFix.setBackgroundColor(Color.GREEN);\r
+                            mFix.setTextColor(Color.BLACK);\r
+                        }\r
+                        mStar.setText(satlites);\r
+                        mHoop.setText(hdop);\r
+                        mSearchCount.setText(locationTime);\r
+                    }\r
+                    return false;\r
+                }\r
+            }\r
+            );\r
+        }\r
+\r
         getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);\r
     }\r
 \r
+\r
     @Override\r
     public void on_locating_changed(ICLocation.GPS_locationStatus gps_status) {\r
 \r
-        List<ICLocation.GpsSatellitePriv> gpslist =gps_status.numSatelliteList;\r
-        adapter.updateLocationValue(testSnrEntriyDate(gpslist));\r
-        String fixed=new StringBuilder().append(gps_status.locating_status>0?\r
-                "Fixed ":"notFixed ").append(TimeUtil.getLocalTime2()).toString();\r
-        String satlites=new StringBuilder("used ").append(gps_status.used_gps_numbs).append(" in ")\r
-                .append(gps_status.numSatelliteList.size()).append("/ inMap ").append(gps_status.satlite_numbss).toString();\r
-        String locationTime=new StringBuilder().append(gps_status.search_time_cost).append("秒").toString();\r
-        String hdop=new StringBuilder().append(String.valueOf(gps_status.hdop)).append("米").toString();\r
-        mFix.setText(fixed);\r
-        if (mFix.getText().toString().contains("notFixed")){\r
-            mFix.setBackgroundColor(Color.RED);\r
-            mFix.setTextColor(Color.WHITE);\r
-        }else{\r
-            mFix.setBackgroundColor(Color.GREEN);\r
-            mFix.setTextColor(Color.BLACK);\r
-        }\r
-        mStar.setText(satlites);\r
-        mHoop.setText(hdop);\r
-        mSearchCount.setText(locationTime);\r
+        g_gps_status = gps_status;\r
+\r
+        mHandler.sendEmptyMessage(1);\r
+\r
     }\r
 \r
     public class SpacesItemDecoration extends RecyclerView.ItemDecoration {\r
index c063b8d..2e4f81c 100644 (file)
@@ -178,19 +178,19 @@ public class BTHelper {
 
     //停止自定义广播
     public void stopGattAdvertising() {
-        if (mBtAdapter.isEnabled())
-            mBtAdapter.stopAdvertising(advcb);
+        //if (mBtAdapter.isEnabled())
+          //  mBtAdapter.stopAdvertising(advcb);
 
     }
 
     //开启自定义广播数据,前两字会被丢弃
     public void enableGattAdvertising(String serverData) {
         byte[] serviceData = serverData.getBytes();
-        if (mBtAdapter.isEnabled())
-            mBtAdapter.startAdvertising(advcb, serviceData);
+        //if (mBtAdapter.isEnabled())
+          //  mBtAdapter.startAdvertising(advcb, serviceData);
     }
 
-    public class advcallback implements BluetoothAdapter.AdvertiseCallback {
+    public class advcallback implements BluetoothAdapter.LeScanCallback {
 
 
         public void onAdvertiseStart(int status) {
@@ -203,6 +203,12 @@ public class BTHelper {
             ICLogger.i("-- onAdvertiseStop --");
 
         }
+
+        @Override
+        public void onLeScan(BluetoothDevice device, int rssi, byte[] scanRecord) {
+            ICLogger.i("-- onLeScan --" + rssi);
+
+        }
     }
 
     private class BLeScanCallback implements LeScanCallback {
index c28f405..0fc81b5 100644 (file)
@@ -131,6 +131,7 @@ public class HeartRateManager extends AbstractInvokeHandlerService {
         //绑定远程服务
         Intent intent = new Intent();
         intent.setAction(ACTION_HEART_RATE);
+        intent.setPackage(ICApplication.sContext.getPackageName());
         ICApplication.sContext.bindService(intent, mRemoteConnection, Context.BIND_AUTO_CREATE);
     }
 
index 35efdc7..d292c30 100644 (file)
@@ -6,15 +6,15 @@ import android.content.Context;
 import android.database.Cursor;
 import android.net.Uri;
 import android.provider.Telephony;
-import android.sim.Sim;
+//import android.sim.Sim;
 import android.telephony.TelephonyManager;
 import android.util.Log;
 import android.widget.Toast;
 
 import com.android.internal.telephony.Phone;
-import com.android.internal.telephony.PhoneFactory;
+//import com.android.internal.telephony.PhoneFactory;
 import com.enqualcomm.support.bean.ApnSetting;
-import android.sim.SimManager;
+//import android.sim.SimManager;
 
 import java.lang.reflect.Method;
 
index a6bb83b..42de0e0 100644 (file)
@@ -19,17 +19,17 @@ public class AlarmHelper {
 \r
     private static final long ONE_WEEK = 604800000L;\r
 \r
-    private static Method setImpl;\r
+//    private static Method setImpl;\r
 \r
     static {\r
-        try {\r
-            setImpl = AlarmManager.class.getDeclaredMethod("setImpl", new Class[]{int.class, long.class, long.class, long.class, PendingIntent.class, android.os.WorkSource.class});\r
-            setImpl.setAccessible(true);\r
-\r
-        } catch (Exception e) {\r
-            e.printStackTrace();\r
-            ICLogger.e(e.getMessage(), e);\r
-        }\r
+//        try {\r
+//            setImpl = AlarmManager.class.getDeclaredMethod("setImpl", new Class[]{int.class, long.class, long.class, long.class, PendingIntent.class, android.os.WorkSource.class});\r
+//            setImpl.setAccessible(true);\r
+//\r
+//        } catch (Exception e) {\r
+//            e.printStackTrace();\r
+//            ICLogger.e(e.getMessage(), e);\r
+//        }\r
     }\r
 \r
     //设置闹铃\r
index bedd829..633bc74 100644 (file)
@@ -38,7 +38,7 @@ import android.preference.PreferenceActivity;
 import android.preference.PreferenceScreen;
 import android.provider.Settings;
 import android.provider.Telephony;
-import android.sim.SimManager;
+//import android.sim.SimManager;
 import android.telephony.TelephonyManager;
 import android.text.Editable;
 import android.text.Selection;
@@ -221,7 +221,7 @@ public class ApnEditor {
         mBearerArray = mRes.getStringArray(R.array.bearer_entries);
 
 
-        mAPNUri = Telephony.Carriers.getContentUri(mPhoneId, null);
+//        mAPNUri = Telephony.Carriers.getContentUri(mPhoneId, null);
         mUri = mAPNUri;
 
         mTelephonyManager = (TelephonyManager) mContext.getSystemService(TELEPHONY_SERVICE);
@@ -237,9 +237,9 @@ public class ApnEditor {
         // values.put(APN_ID, mSelectedKey);
         // resolver.update(PREFERAPN_URI, values, null, null);
         values.put("apn_id", key);
-        resolver.update(
-                Telephony.Carriers.getContentUri(0, Telephony.Carriers.PATH_PREFERAPN),
-                values, null, null);
+//        resolver.update(
+//                Telephony.Carriers.getContentUri(0, Telephony.Carriers.PATH_PREFERAPN),
+//                values, null, null);
         /* @} */
     }
 
@@ -250,18 +250,18 @@ public class ApnEditor {
         // Cursor cursor = getContentResolver().query(PREFERAPN_URI, new
         // String[] {"_id"},
         // null, null, Telephony.Carriers.DEFAULT_SORT_ORDER);
-        Cursor cursor = mContext.getContentResolver().query(
-                Telephony.Carriers.getContentUri(0, Telephony.Carriers.PATH_PREFERAPN),
-                new String[] {
-                        "_id"
-                },
-                null, null, Telephony.Carriers.DEFAULT_SORT_ORDER);
+//        Cursor cursor = mContext.getContentResolver().query(
+//                Telephony.Carriers.getContentUri(0, Telephony.Carriers.PATH_PREFERAPN),
+//                new String[] {
+//                        "_id"
+//                },
+//                null, null, Telephony.Carriers.DEFAULT_SORT_ORDER);
         /* @} */
-        if (cursor.getCount() > 0) {
-            cursor.moveToFirst();
-            key = cursor.getString(0);
-        }
-        cursor.close();
+//        if (cursor.getCount() > 0) {
+//            cursor.moveToFirst();
+//            key = cursor.getString(0);
+//        }
+//        cursor.close();
         ICLogger.d(" get default apnkey "+key);
         return key;
     }
@@ -354,22 +354,22 @@ public class ApnEditor {
 
     public String getCurrentAPN(){
 
-        String where;
-        String mccmnc;
-        if (TelephonyManager.isMultiSim()) {
-            mccmnc = android.os.SystemProperties.get(TelephonyManager.getProperty(
-                    TelephonyProperties.PROPERTY_ICC_OPERATOR_NUMERIC, mPhoneId), "");
-            // APNs are listed based on the MCC+MNC.
-            // Get the value from appropriate Telephony Property based on the
-            // subscription.
-            where = "numeric=\"" + mccmnc + "\"";
-
-        } else {
-            mccmnc = android.os.SystemProperties.get(
-                    TelephonyProperties.PROPERTY_ICC_OPERATOR_NUMERIC, "");
-            where = "numeric=\"" + mccmnc + "\"";
-
-        }
+        String where="";
+        String mccmnc="";
+//        if (TelephonyManager.isMultiSim()) {
+//            mccmnc = android.os.SystemProperties.get(TelephonyManager.getProperty(
+//                    TelephonyProperties.PROPERTY_ICC_OPERATOR_NUMERIC, mPhoneId), "");
+//            // APNs are listed based on the MCC+MNC.
+//            // Get the value from appropriate Telephony Property based on the
+//            // subscription.
+//            where = "numeric=\"" + mccmnc + "\"";
+//
+//        } else {
+//            mccmnc = android.os.SystemProperties.get(
+//                    TelephonyProperties.PROPERTY_ICC_OPERATOR_NUMERIC, "");
+//            where = "numeric=\"" + mccmnc + "\"";
+//
+//        }
         where += " and name!='CMCC DM'";
 
         Log.d(TAG,"where = " + where + ",mccmnc =" + mccmnc);
@@ -398,8 +398,7 @@ public class ApnEditor {
 
     public boolean resetAPNtoDefault(){
         // resolver.delete(DEFAULTAPN_URI, null, null);
-       int rows =  mContext.getContentResolver().delete(Telephony.Carriers.getContentUri(mPhoneId,
-                Telephony.Carriers.PATH_RESTORE),null,null);
+       int rows =  0;//mContext.getContentResolver().delete(Telephony.Carriers.getContentUri(mPhoneId,Telephony.Carriers.PATH_RESTORE),null,null);
         return rows>=0;
     }
     public boolean addVPN(String apnName, String apn, String mcc, String mnc, String user, String passwd) {
@@ -496,16 +495,16 @@ public class ApnEditor {
                 // String numeric =
                 // SystemProperties.get(TelephonyProperties.PROPERTY_ICC_OPERATOR_NUMERIC);
                 String numeric;
-                if (TelephonyManager.isMultiSim()) {
-                    // APNs are automatically added with MCC+MNC.
-                    // Get the value from appropriate Telephony Property based
-                    // on the mPhoneId.
-                    numeric = SystemProperties
-                            .get(TelephonyManager.getProperty(TelephonyProperties.PROPERTY_ICC_OPERATOR_NUMERIC, mPhoneId));
-
-                } else {
+//                if (TelephonyManager.isMultiSim()) {
+//                    // APNs are automatically added with MCC+MNC.
+//                    // Get the value from appropriate Telephony Property based
+//                    // on the mPhoneId.
+//                    numeric = SystemProperties
+//                            .get(TelephonyManager.getProperty(TelephonyProperties.PROPERTY_ICC_OPERATOR_NUMERIC, mPhoneId));
+
+//                } else {
                     numeric = SystemProperties.get(TelephonyProperties.PROPERTY_ICC_OPERATOR_NUMERIC);
-                }
+//                }
                 /* @} */
                 // MCC is first 3 chars and then in 2 - 3 chars of MNC
                 if (numeric != null && numeric.length() > 4) {
@@ -658,7 +657,7 @@ public class ApnEditor {
 
             int mDDS = 0;
             try {
-                mDDS = Settings.System.getInt(mContext.getContentResolver(), Settings.System.MULTI_SIM_DATA_CALL);
+//                mDDS = Settings.System.getInt(mContext.getContentResolver(), Settings.System.MULTI_SIM_DATA_CALL);
             } catch (Exception e) {
                 ICLogger.e( "Exception Reading Dual Sim Data Subscription Value.", e);
             }
index 32f775b..4fc7d97 100644 (file)
@@ -1,6 +1,7 @@
 package com.enqualcomm.support.utils;
 
 import android.content.Context;
+import android.content.IClipboard;
 import android.os.Build;
 import android.os.Handler;
 import android.os.Message;
@@ -21,15 +22,15 @@ import android.telephony.TelephonyManager;
 import android.telephony.cdma.CdmaCellLocation;
 import android.telephony.gsm.GsmCellLocation;
 
-import com.android.internal.telephony.CallManager;
-import com.android.internal.telephony.CallStateException;
-import com.android.internal.telephony.Phone;
-import com.android.internal.telephony.PhoneFactory;
+//import com.android.internal.telephony.CallManager;
+//import com.android.internal.telephony.CallStateException;
+//import com.android.internal.telephony.Phone;
+//import com.android.internal.telephony.PhoneFactory;
 import com.enqualcomm.support.Config;
 import com.enqualcomm.support.GSensorListener;
 import com.enqualcomm.support.adapter.LBSHelper;
 import com.enqualcomm.support.bean.Runtime;
-import com.sprd.internal.telephony.SprdCallManager;
+//import com.sprd.internal.telephony.SprdCallManager;
 
 import java.lang.reflect.Method;
 import java.util.Collections;
@@ -79,27 +80,27 @@ public class CellInfoUtil {
 //        }
 //      }
 //    });
-    Single.just(null).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<Object>() {
-      public void call(Object param1Object) {
-
-        PhoneFactory.makeDefaultPhones(context);
-
-        Phone p = PhoneFactory.getDefaultPhone();
-
-        SprdCallManager cm = (SprdCallManager)SprdCallManager.getInstance();
-
-        cm.registerPhone(p);
-
-        Phone phone = cm.getDefaultPhone();
-
-        try {
-          phone.dial(dialnumber);
-        } catch (Exception e) {
-          ICLogger.PrintExceptionStackTrace(e);
-          ICLogger.e(e.getMessage(),e);
-        }
-      }
-    });
+//    Single.just(null).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<Object>() {
+//      public void call(Object param1Object) {
+//
+//        PhoneFactory.makeDefaultPhones(context);
+//
+//        Phone p = PhoneFactory.getDefaultPhone();
+//
+//        SprdCallManager cm = (SprdCallManager)SprdCallManager.getInstance();
+//
+//        cm.registerPhone(p);
+//
+//        Phone phone = cm.getDefaultPhone();
+//
+//        try {
+//          phone.dial(dialnumber);
+//        } catch (Exception e) {
+//          ICLogger.PrintExceptionStackTrace(e);
+//          ICLogger.e(e.getMessage(),e);
+//        }
+//      }
+//    });
 
   }
   public static int getSignal(TelephonyManager tm , Runtime runtime){
@@ -245,12 +246,11 @@ public class CellInfoUtil {
           int size=1;
             if (neighboringCell_list != null && !neighboringCell_list.isEmpty()) {
               sortByRssi(neighboringCell_list);
-
+              ICLogger.i("signal CellInfo size "+neighboringCell_list.size());
               Iterator cell = neighboringCell_list.iterator();
 
-
               while(cell.hasNext()) {
-                NeighboringCellInfo mNeighboringCellInfo = (NeighboringCellInfo)cell.next();
+               NeighboringCellInfo mNeighboringCellInfo = (NeighboringCellInfo)cell.next();
                 if (mNeighboringCellInfo.getLac() == -1) {
                   break;
                 }
diff --git a/app/src/main/java/com/enqualcomm/support/utils/IATUtils.java b/app/src/main/java/com/enqualcomm/support/utils/IATUtils.java
new file mode 100644 (file)
index 0000000..d13f030
--- /dev/null
@@ -0,0 +1,42 @@
+package com.enqualcomm.support.utils;
+
+import android.os.ServiceManager;
+import android.util.Log;
+
+import com.ic.jni.AtCMD;
+
+
+public class IATUtils {
+    private static final String TAG = "IATUtils";
+    private static String strTmp = null;
+    public static String AT_FAIL = "AT FAILED";
+    public static String AT_OK = "OK";
+    public static int mPhoneCount = 0;
+
+
+    public static String sendATCmd(String cmd, String serverName) {
+
+
+        strTmp = "error service can't get";
+        try {
+            String result = sendAtCmd(cmd);
+            Log.d(TAG, "result = " + result);
+            return result;
+        } catch (Exception se) {
+            Log.d("AT Exception", se.toString());
+            strTmp += " 8541 ";
+        }
+        return strTmp;
+
+    }
+
+    private static String sendAtCmd(String cmd){
+        String result="";
+        if(AtCMD.loadlibrary_success) {
+            result = AtCMD.native_sendATCmd(0, cmd);
+        }else{
+            result="library load failed!";
+        }
+        return result;
+    }
+}
index d65d078..b74e76a 100644 (file)
@@ -35,8 +35,7 @@ public class ICAudioManager {
         ICLogger.i("======setVolumnMute");
 //        saved_volumn = audioManager.getStreamMaxVolume(AudioManager.STREAM_VOICE_CALL);
         if (audioManager != null) {
-            audioManager.setMasterMute(true);
-
+//            audioManager.setMasterMute(true);
             audioManager.setStreamMute(AudioManager.STREAM_VOICE_CALL, true);
             audioManager.setSpeakerphoneOn(false);
         }
@@ -49,7 +48,7 @@ public class ICAudioManager {
         ICLogger.i("======restoreVolumn "+saved_volumn);
         AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
         if (audioManager != null) {
-            audioManager.setMasterMute(false);
+//            audioManager.setMasterMute(false);
 
             audioManager.setStreamMute(AudioManager.STREAM_VOICE_CALL, false);
             audioManager.setSpeakerphoneOn(true);
@@ -63,7 +62,7 @@ public class ICAudioManager {
         ICLogger.i("======setVoiceCallMaxVolumn ");
         AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
         if (audioManager != null) {
-            audioManager.setMasterMute(false);
+//            audioManager.setMasterMute(false);
             int currentvolume=audioManager.getStreamVolume(AudioManager.STREAM_VOICE_CALL);
             int maxvolume=audioManager.getStreamMaxVolume(AudioManager.STREAM_VOICE_CALL);
             audioManager.setStreamVolume(AudioManager.STREAM_VOICE_CALL,maxvolume,0);
index da1d607..0f66964 100644 (file)
@@ -38,7 +38,8 @@ public class ImageUtil {
         //在画布上绘制水印图片
         canvas.drawBitmap(watermark, paddingLeft, paddingTop, null);
         // 保存
-        canvas.save(Canvas.ALL_SAVE_FLAG);
+//        canvas.save(Canvas.ALL_SAVE_FLAG);
+        canvas.save();
         // 存储
         canvas.restore();
         return newb;
index ae7d8e0..05edf86 100644 (file)
@@ -169,28 +169,18 @@ public class SimSignalUtil {
     }
 
     public static void send_at_to_reset_simcard(Runtime runtime) {
-
-        Intent intent = new Intent("com.eqc.intent.action.getTelephony.lbs");
-        intent.putExtra("command", "AT+SFUN=2"); //重新初始化sim卡
-        intent.putExtra("arg2", "");
-        (runtime.getContextProxy()).context.sendBroadcast(intent);
-        ICLogger.i("send_at_to_reset_simcard ");
+        String ret=IATUtils.sendATCmd("AT+SFUN=2","");
+        ICLogger.i("send_at_to_reset_simcard "+ret);
     }
 
     public static void send_at_to_update_lbs(Runtime runtime) {
-        Intent intent = new Intent("com.eqc.intent.action.getTelephony.lbs");
-        intent.putExtra("command", "AT+CREG=2");
-        intent.putExtra("arg2", "");
-        (runtime.getContextProxy()).context.sendBroadcast(intent);
-        ICLogger.i("send_at_to_update_lbs ");
+        String ret=IATUtils.sendATCmd("AT+CREG=2","");
+        ICLogger.i("send_at_to_update_lbs "+ret);
     }
 
     public static void send_at_cmd(Runtime runtime, String cmd) {
-        Intent intent = new Intent("com.eqc.intent.action.getTelephony.lbs");
-        intent.putExtra("command", cmd);
-        intent.putExtra("arg2", "");
-        (runtime.getContextProxy()).context.sendBroadcast(intent);
-        ICLogger.i("send_at_cmd " + cmd);
+        String ret=IATUtils.sendATCmd(cmd,"");
+        ICLogger.i("send_at_cmd "+cmd+" \r\nreply: "+ret);
     }
 
     public static void send_at_setImei0(Runtime runtime, String imei) {
index 6a78796..67feb8b 100644 (file)
@@ -36,6 +36,7 @@ public class TemperatureUtil {
     private TemperatureUtil() {
         Intent intent = new Intent();
         intent.setAction(ACTION_TEMPERATURE);
+        intent.setPackage(ICApplication.sContext.getPackageName());
         //绑定远程服务
         ICApplication.sContext.bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
     }
diff --git a/app/src/main/java/com/ic/jni/AtCMD.java b/app/src/main/java/com/ic/jni/AtCMD.java
new file mode 100644 (file)
index 0000000..3e235a9
--- /dev/null
@@ -0,0 +1,27 @@
+package com.ic.jni;
+
+import android.util.Log;
+
+public class AtCMD {
+    public static boolean loadlibrary_success=false;
+    static {
+        try {
+            System.loadLibrary("jni_atcmd");
+            loadlibrary_success =true;
+        } catch (UnsatisfiedLinkError e) {
+            Log.d("ValidationToolsNative", " #loadLibrary jni_validationtools failed  ");
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * send AT cmd to modem 
+     *
+     * @return (String: the return value of send cmd, "OK":sucess, "ERROR":fail)
+     */
+    public static native String native_sendATCmd(int phoneId, String cmd);
+
+    public static native boolean native_hashValueWrited();
+
+    public static native int native_get_rootflag();
+}
\ No newline at end of file
index e9f3aa3..aed77c3 100644 (file)
@@ -37,7 +37,8 @@ allprojects {
         tasks.withType(JavaCompile) {
 //            options.compilerArgs.add('-Xbootclasspath/p:app\\libs\\telephony-common-full-debug.jar')
 //            options.compilerArgs.add('-Xbootclasspath/p:app\\libs\\frameworks-full-debug.jar')
-            options.compilerArgs << '-Xbootclasspath/p:app\\libs\\frameworks-full-debug.jar;app\\libs\\telephony-common-full-debug.jar'
+//            options.compilerArgs << '-Xbootclasspath/p:app\\libs\\frameworks-full-debug.jar;app\\libs\\telephony-common-full-debug.jar'
+            options.compilerArgs << '-Xbootclasspath/p:app\\libs\\8.1_framework_full_debug.jar;app\\libs\\8.1_telephony-common_full_debug.jar'
         }
     }
 }
index 8bb0634..db57af9 100644 (file)
@@ -4,5 +4,5 @@
 # Location of the SDK. This is only used by Gradle.\r
 # For customization when using a Version Control System, please read the\r
 # header note.\r
-#Fri Jul 02 14:52:39 CST 2021\r
-sdk.dir=E\:\\Android\\Sdk\r
+#Thu Jul 22 07:04:36 CST 2021\r
+sdk.dir=C\:\\Users\\incar\\AppData\\Local\\Android\\Sdk\r