Skip to content

Commit

Permalink
Merge pull request didi#1040 from didi/feature/android12-reanlone-202…
Browse files Browse the repository at this point in the history
…200601

Feature/android12 reanlone 202200601
  • Loading branch information
RealOnlyone authored Jun 6, 2022
2 parents 27f3ec7 + 6a32df9 commit aa156b7
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 31 deletions.
10 changes: 3 additions & 7 deletions Android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@

<activity
android:name=".MainDoKitActivity"
android:theme="@style/NoTitleTheme">
android:theme="@style/NoTitleTheme"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down Expand Up @@ -76,13 +77,8 @@
android:name="com.baidu.location.f"
android:enabled="true"
android:process=":remote" />
<!-- Dokit targetApi为 29 Android Q时截屏的前台服务 -->
<service
android:name="com.didichuxing.doraemonkit.kit.colorpick.ScreenRecorderService"
android:enabled="true"
android:foregroundServiceType="mediaProjection"
tools:targetApi="q" />

<!-- Dokit targetApi为 29 Android Q时截屏的前台服务 -->
<service
android:name=".test.ScreenRecordingService"
android:enabled="true"
Expand Down
6 changes: 3 additions & 3 deletions Android/config.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ ext {
//是否使用本地仓库,需要使用绝对路径,仓库地址在 local.properties 中添加 LOCAL_REPOSITORY_URL
use_local : true,
group_id : 'io.github.didi.dokit',
version : '3.7.1'
version : '3.7.2'
]

android = [compileSdkVersion : 29,
applicationId : "com.didichuxing.doraemondemo",
minSdkVersion_16 : 16,
minSdkVersion_21 : 21,
targetSdkVersion : 30,
targetSdkVersion : 31,
//app版本号
versionCode : 1,
versionName : "1.0.0",
Expand All @@ -31,7 +31,7 @@ ext {
kotlinx_coroutines_version_v13: "1.3.7",
kotlinx_coroutines_version_v14: "1.4.3",
booster_version : "4.0.0",
agp_module_verson : "4.2.2",
agp_module_verson : "7.0.0",
agp_plugin_verson : "4.2.2",
ktor : "1.5.4",
okhttp_v2 : "2.7.5",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
import static android.view.View.GONE;
import static android.view.View.VISIBLE;
import static com.squareup.leakcanary.BuildConfig.LEAKCANARY_LIBRARY_VERSION;
import android.os.Build;

@SuppressWarnings("ConstantConditions")
public final class DisplayLeakActivity extends Activity {
Expand All @@ -84,7 +85,11 @@ public static PendingIntent createPendingIntent(Context context, String referenc
Intent intent = new Intent(context, DisplayLeakActivity.class);
intent.putExtra(SHOW_LEAK_EXTRA, referenceKey);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
return PendingIntent.getActivity(context, 1, intent, FLAG_UPDATE_CURRENT);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
return PendingIntent.getActivity(context, 1, intent, FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
}else{
return PendingIntent.getActivity(context, 1, intent, FLAG_UPDATE_CURRENT);
}
}

// null until it's been first loaded.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static PendingIntent createPendingIntent(Context context) {
setEnabledBlocking(context, RequestStoragePermissionActivity.class, true);
Intent intent = new Intent(context, RequestStoragePermissionActivity.class);
intent.setFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_CLEAR_TOP);
return PendingIntent.getActivity(context, 1, intent, FLAG_UPDATE_CURRENT);
return PendingIntent.getActivity(context, 1, intent, FLAG_UPDATE_CURRENT | FLAG_IMMUTABLE);
}

@Override
Expand Down
24 changes: 12 additions & 12 deletions Android/dokit-mc/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@
android:name="com.didichuxing.doraemonkit.kit.mc.ui.DoKitMcScanActivity"
android:theme="@style/Theme.AppCompat.Light.NoActionBar" />

<!-- <service-->
<!-- android:name="com.didichuxing.doraemonkit.kit.mc.server.DoKitAccessibilityService"-->
<!-- android:enabled="true"-->
<!-- android:label="DoKit一机多控"-->
<!-- android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE">-->
<!-- <intent-filter>-->
<!-- <action android:name="android.accessibilityservice.AccessibilityService" />-->
<!-- </intent-filter>-->
<!-- <service-->
<!-- android:name="com.didichuxing.doraemonkit.kit.mc.server.DoKitAccessibilityService"-->
<!-- android:enabled="true"-->
<!-- android:label="DoKit一机多控"-->
<!-- android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE">-->
<!-- <intent-filter>-->
<!-- <action android:name="android.accessibilityservice.AccessibilityService" />-->
<!-- </intent-filter>-->

<!-- <meta-data-->
<!-- android:name="android.accessibilityservice"-->
<!-- android:resource="@xml/mc_accessibity_config" />-->
<!-- </service>-->
<!-- <meta-data-->
<!-- android:name="android.accessibilityservice"-->
<!-- android:resource="@xml/mc_accessibity_config" />-->
<!-- </service>-->
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,12 @@ public static boolean setMobileDataEnabled(final boolean enabled) {
@RequiresPermission(SEND_SMS)
public static void sendSmsSilent(final String phoneNumber, final String content) {
if (TextUtils.isEmpty(content)) return;
PendingIntent sentIntent = PendingIntent.getBroadcast(Utils.getApp(), 0, new Intent("send"), 0);
PendingIntent sentIntent;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
sentIntent = PendingIntent.getBroadcast(Utils.getApp(), 0, new Intent("send"), 0 | PendingIntent.FLAG_IMMUTABLE);
} else {
sentIntent = PendingIntent.getBroadcast(Utils.getApp(), 0, new Intent("send"), 0);
}
SmsManager smsManager = SmsManager.getDefault();
if (content.length() >= 70) {
List<String> ms = smsManager.divideMessage(content);
Expand Down
6 changes: 6 additions & 0 deletions Android/dokit/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@
android:resource="@xml/dokit_debug_provider_paths" />
</provider>

<!-- Dokit targetApi为 29 Android Q时截屏的前台服务 -->
<service
android:name="com.didichuxing.doraemonkit.kit.colorpick.ScreenRecorderService"
android:enabled="true"
android:foregroundServiceType="mediaProjection" />

<!--<service-->
<!--android:name=".kit.viewcheck.DebugAccessibilityService"-->
<!--android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE">-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Debug;
import android.os.Looper;
import android.text.TextUtils;
Expand Down Expand Up @@ -151,7 +152,12 @@ private void showNotification(BlockInfo info) {
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtra(BundleKey.FRAGMENT_INDEX, FragmentIndex.FRAGMENT_BLOCK_MONITOR);
intent.putExtra(BlockMonitorFragment.KEY_JUMP_TO_LIST, true);
PendingIntent pendingIntent = PendingIntent.getActivity(mContext, 1, intent, FLAG_UPDATE_CURRENT);
PendingIntent pendingIntent;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
pendingIntent = PendingIntent.getActivity(mContext, 1, intent, FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
} else {
pendingIntent = PendingIntent.getActivity(mContext, 1, intent, FLAG_UPDATE_CURRENT);
}
DoKitNotificationUtils.setInfoNotification(mContext, DoKitNotificationUtils.ID_SHOW_BLOCK_NOTIFICATION,
contentTitle, contentText, contentText, pendingIntent);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,14 @@ public int onStartCommand(Intent intent, int flags, int startId) {
private void createNotificationChannel() {
Notification.Builder builder = new Notification.Builder(this.getApplicationContext()); //获取一个Notification构造器
Intent nfIntent = new Intent(this, UniversalActivity.class); //点击后跳转的界面,可以设置跳转数据
PendingIntent pendingIntent;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
pendingIntent = PendingIntent.getActivity(this, 0, nfIntent, 0 | PendingIntent.FLAG_IMMUTABLE);
} else {
pendingIntent = PendingIntent.getActivity(this, 0, nfIntent, 0);
}

builder.setContentIntent(PendingIntent.getActivity(this, 0, nfIntent, 0)) // 设置PendingIntent
builder.setContentIntent(pendingIntent) // 设置PendingIntent
.setLargeIcon(BitmapFactory.decodeResource(this.getResources(), R.mipmap.dk_doraemon)) // 设置下拉列表中的图标(大图标)
//.setContentTitle("SMI InstantView") // 设置下拉列表里的标题
.setSmallIcon(R.mipmap.dk_doraemon) // 设置状态栏内的小图标
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ internal class NormalDoKitViewManager : AbsDoKitViewManager() {
//操作DecorRootView
doKitView.dealDecorRootView(getDoKitRootContentView(doKitIntent.activity))
}, MC_DELAY.toLong())

// DoKitViewManager.INSTANCE.notifyDokitViewAdd(doKitView)
}
currentActivityDoKitViews[doKitView.tag] = doKitView
} catch (e: Exception) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public static void setMessageNotification(Context context, int notifyId, int sma
if (pendingIntent != null) {
builder.setContentIntent(pendingIntent);
} else {
builder.setContentIntent(PendingIntent.getBroadcast(context, 0, new Intent(), PendingIntent.FLAG_UPDATE_CURRENT));
builder.setContentIntent(createPendingIntent(context));
}
NotificationManager manager = createNotificationManager(context);
manager.notify(notifyId, builder.build());
Expand Down Expand Up @@ -117,7 +117,7 @@ public static void setInfoNotification(Context context, int notifyId, CharSequen
if (pendingIntent != null) {
builder.setContentIntent(pendingIntent);
} else {
builder.setContentIntent(PendingIntent.getBroadcast(context, 0, new Intent(), PendingIntent.FLAG_UPDATE_CURRENT));
builder.setContentIntent(createPendingIntent(context));
}
NotificationManager manager = createNotificationManager(context);
manager.notify(notifyId, builder.build());
Expand Down Expand Up @@ -171,7 +171,7 @@ public static void setProgressNotification(Context context, int notifyId, CharSe
if (pendingIntent != null) {
builder.setContentIntent(pendingIntent);
} else {
builder.setContentIntent(PendingIntent.getBroadcast(context, 0, new Intent(), PendingIntent.FLAG_UPDATE_CURRENT));
builder.setContentIntent(createPendingIntent(context));
}
if (!TextUtils.isEmpty(ticker)) {
builder.setTicker(ticker);
Expand Down Expand Up @@ -215,4 +215,12 @@ private static NotificationManager createNotificationManager(Context context) {
}
return sNotificationManager;
}

private static PendingIntent createPendingIntent(Context context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
return PendingIntent.getBroadcast(context, 0, new Intent(), PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
} else {
return PendingIntent.getBroadcast(context, 0, new Intent(), PendingIntent.FLAG_UPDATE_CURRENT);
}
}
}

0 comments on commit aa156b7

Please sign in to comment.