--- /dev/null
+package com.enqualcomm.support.provider;
+
+import android.content.ContentProvider;
+import android.content.ContentValues;
+import android.content.UriMatcher;
+import android.database.Cursor;
+import android.database.sqlite.SQLiteDatabase;
+import android.net.Uri;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+
+/**
+ * 音视频通话,通讯录列表
+ */
+public class ICMembersProvider extends ContentProvider {
+
+ private static UriMatcher sUriMatcher;
+ private static final int MATH_CODE_TABLE = 1;
+
+ public static final String PATH = "members";
+ //public static final String AUTHORITY = "com.ic.fzd.members";
+ public static final String AUTHORITY = "com.ic.provider.member";
+ public static final String MEMBERS = "content://" + AUTHORITY + "/" + PATH;
+
+ static {
+ sUriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
+ sUriMatcher.addURI(AUTHORITY, PATH, MATH_CODE_TABLE);
+ }
+
+ private ICDatabaseHelper mDatabase;
+
+ @Override
+ public boolean onCreate() {
+ mDatabase = new ICDatabaseHelper(getContext());
+ return false;
+ }
+
+ /**
+ * 查询数据
+ *
+ * @param uri
+ * @param projection
+ * @param selection
+ * @param selectionArgs
+ * @param sortOrder
+ * @return
+ */
+ @Nullable
+ @Override
+ public Cursor query(@NonNull Uri uri,
+ @Nullable String[] projection,
+ @Nullable String selection,
+ @Nullable String[] selectionArgs,
+ @Nullable String sortOrder) {
+ //匹配规则
+ int match = sUriMatcher.match(uri);
+ SQLiteDatabase readableDatabase = mDatabase.getReadableDatabase();
+ if (match == MATH_CODE_TABLE) {
+ return readableDatabase.query(ICDatabaseHelper.tMembers,
+ projection,
+ selection,
+ selectionArgs,
+ null, null, sortOrder);
+ }
+ return null;
+ }
+
+ @Nullable
+ @Override
+ public String getType(@NonNull Uri uri) {
+ return null;
+ }
+
+ @Nullable
+ @Override
+ public Uri insert(@NonNull Uri uri,
+ @Nullable ContentValues values) {
+ int match = sUriMatcher.match(uri);
+ if (match == MATH_CODE_TABLE) {
+ SQLiteDatabase writableDatabase = mDatabase.getWritableDatabase();
+ //判断是否有存在吧,确保唯一,删除再添加吧,否则也是添加不进去的
+ writableDatabase.delete(ICDatabaseHelper.tMembers,
+ ICDatabaseHelper.mId + "=?", new String[]{
+ values.getAsString(ICDatabaseHelper.mId)
+ });
+ long insert = writableDatabase.insert(ICDatabaseHelper.tMembers, null, values);
+ getContext().getContentResolver().notifyChange(uri, null);
+ return Uri.parse(AUTHORITY + "/" + PATH + "/" + insert);
+ }
+ return null;
+ }
+
+ @Override
+ public int delete(@NonNull Uri uri,
+ @Nullable String selection,
+ @Nullable String[] selectionArgs) {
+ int match = sUriMatcher.match(uri);
+ if (match == MATH_CODE_TABLE) {
+ SQLiteDatabase writableDatabase = mDatabase.getWritableDatabase();
+ int delete = writableDatabase.delete(ICDatabaseHelper.tMembers, selection, selectionArgs);
+ if (delete > 0 && getContext() != null) {
+ getContext().getContentResolver().notifyChange(uri, null);
+ }
+ return delete;
+ }
+ return 0;
+ }
+
+ @Override
+ public int update(@NonNull Uri uri,
+ @Nullable ContentValues values,
+ @Nullable String selection,
+ @Nullable String[] selectionArgs) {
+ int match = sUriMatcher.match(uri);
+ if (match == MATH_CODE_TABLE) {
+ SQLiteDatabase writableDatabase = mDatabase.getWritableDatabase();
+ int update = writableDatabase.update(ICDatabaseHelper.tMembers, values, selection, selectionArgs);
+ if (update > 0 && getContext() != null) {
+ getContext().getContentResolver().notifyChange(uri, null);
+ }
+ return update;
+ }
+ return 0;
+ }
+}
import com.enqualcomm.support.bean.voicePacket;
import com.enqualcomm.support.provider.ICAlarmProvider;
import com.enqualcomm.support.provider.ICDatabaseHelper;
+import com.enqualcomm.support.provider.ICMembersProvider;
import com.enqualcomm.support.service.HeartRateManager;
import com.enqualcomm.support.service.SilentManager;
import com.enqualcomm.support.utils.CellInfoUtil;
//设置通讯录,白名单(10个)
public void handleBP14(Connection connection, String cmd, Runtime runtime) {
-// IWBP14,867155030001063,357444,9b44529b|13554820016,,,,,,,,,
-/**
- * IWBP14,353456789012345,080835,
- * D3590D54|135xxxxxxxxxx,
- * D3590D54|135xxxxxxxxxx,
- * D3590D54|135xxxxxxxxxx,
- * D3590D54|135xxxxxxxxxx,
- * D3590D54|135xxxxxxxxxx,
- * D3590D54|135xxxxxxxxxx,
- * D3590D54|135xxxxxxxxxx,
- * D3590D54|135xxxxxxxxxx,
- * D3590D54|135xxxxxxxxxx,
- * D3590D54|135xxxxxxxxxx#
- */
+ //IWBP14,867155030001063,357444,9b44529b|13554820016,,,,,,,,,
+ /**
+ * IWBP14,353456789012345,080835,
+ * D3590D54|135xxxxxxxxxx,
+ * D3590D54|135xxxxxxxxxx,
+ * D3590D54|135xxxxxxxxxx,
+ * D3590D54|135xxxxxxxxxx,
+ * D3590D54|135xxxxxxxxxx,
+ * D3590D54|135xxxxxxxxxx,
+ * D3590D54|135xxxxxxxxxx,
+ * D3590D54|135xxxxxxxxxx,
+ * D3590D54|135xxxxxxxxxx,
+ * D3590D54|135xxxxxxxxxx#
+ */
String[] cmdlist = cmd.split(CMDSPLIT);
String[] phnums = new String[]{"", "", "", "", "", "", "", "", "", ""};
StringBuffer sb = new StringBuffer().append("recv phone Numbs ");
String[] tmp = phnums[i].split("\\|");
if (tmp.length == 2) {
String name = Util.decodeUnicode2Utf8(tmp[0]);
- String phonem = tmp[1];
- ICLogger.i("phnums[" + i + "]=" + phnums[i] + ",split = " + tmp.length + " , name=" + name + ",-" + phonem);
- contactArray.add(new Contact(Contact.CATEGORY_CALL, name, phonem));
+ String phoneNum = tmp[1];
+ //保存到数据库中
+ ICLogger.i(i / 2 + " 姓名 " + name + ", 电话 " + phoneNum);
+ contactArray.add(new Contact(Contact.CATEGORY_CALL, name, phoneNum));
+ ContentValues contentValues = new ContentValues();
+ contentValues.put(ICDatabaseHelper.fType, ICDatabaseHelper.MemberType.WHITE_LIST);
+ contentValues.put(ICDatabaseHelper.fPhoneNum, phoneNum);
+ contentValues.put(ICDatabaseHelper.fID, phoneNum);
+ contentValues.put(ICDatabaseHelper.fUserName, name);
+ contentValues.put(ICDatabaseHelper.fCreateTime, System.currentTimeMillis());
+ contentValues.put(ICDatabaseHelper.fUpdateTime, System.currentTimeMillis());
+ //保存联系人列表,类型为白名单
+ runtime.getContextProxy().getResolver().insert(Uri.parse(ICMembersProvider.MEMBERS), contentValues);
} else {
- ICLogger.i("phnums[" + i + "]=" + phnums[i] + ",split = " + tmp.length);
-
+ ICLogger.i("phoneNumber[" + i + "]=" + phnums[i] + ",split = " + tmp.length);
}
}
-// contactArray.add(new Contact(Contact.CATEGORY_GROUP,"All","666"));
-// contactArray.add(new Contact(Contact.CATEGORY_PARTNER,"PARTNER","666"));
-// contactArray.add(new Contact(Contact.CATEGORY_CARE,"CARE","666"));
-// contactArray.add(new Contact(Contact.CATEGORY_VOLTE,"VOLTE","666"));
-
- runtime.getDbHelper().saveContacts(contactArray, false, false, true, false, false, false);
-
} else {
ICLogger.i(" BP14 format error!");
}
-
}
.append(", alarmtype=").append(alarmtype)
.toString()
);
-
+ //TODO:
alarmlist.add(new Alarm("ST" + alarmtime.substring(0, 2) + "." + alarmtime.substring(2), "W" + repeat, "CON", alarmswitch == 1 ? "ON" : "OFF", "闹铃"));
} else {
}
}//循环获取alarm数据结束
- runtime.getDbHelper().saveAlarm(alarmlist);
-
- //do clean and set alarm things
} catch (Exception e) {
ICLogger.e(e.getMessage(), e);
}
}
-
public void handleBPSQ(String cmd, Connection connection, Runtime runtime) {
//IWBPSQ,353456789012345,080835,1,60#
//说明: