Android13系统源码内置App并通过AIDL调用获取内置存储卡的真实大小

news2024/9/20 19:28:40

jix 进行从事Android系统源码开发不得不在原有的系统上内置自己的App。通过内置App一般都需要调用些系统才能访问的系统级App。App的部署和调试需要依赖源码系统。通过命令 : mm 来实现。

第三方App想调用内置的app需要通过跨进程调用。

这里通过AIDL来实现跨进程调用。

首先声明AIDL文件,

Android源码工程的文件构成和格式和标准的app完全不一样。

为了方便调试,先在标准的App中调试通过。

再copy标准工程到源码App工程里。

声明的AIDL文件:

Callback.aidl

package com.android.kvservice;

interface Callback {
 oneway void onMessageReceived(int type, String value);
}

KvInterface.aidl

package com.android.kvservice;

import com.android.kvservice.Callback;

interface KvInterface {

     void registerCallback(Callback callback);

     void unregisterCallback(Callback callback);

     void sendMessage(int type, String value);
}

AIDL的文件夹放的位置

注意在build.gradle 里声明: aidl true

plugins {
    alias(libs.plugins.androidApplication)
    alias(libs.plugins.jetbrainsKotlinAndroid)
}

android {
    namespace 'com.yyy.xxx.service'
    compileSdk 34

    defaultConfig {
        applicationId "com.yyy.xxx.kvservice"
        minSdk 29
        targetSdk 34
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        vectorDrawables {
            useSupportLibrary true
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
    buildFeatures {
        compose true
        viewBinding true
        aidl true
    }
    composeOptions {
        kotlinCompilerExtensionVersion '1.5.1'
    }
    packaging {
        resources {
            excludes += '/META-INF/{AL2.0,LGPL2.1}'
        }
    }

}

dependencies {

    implementation libs.androidx.core.ktx
    implementation libs.androidx.lifecycle.runtime.ktx
    implementation libs.androidx.activity.compose
    implementation platform(libs.androidx.compose.bom)
    implementation libs.androidx.ui
    implementation libs.androidx.ui.graphics
    implementation libs.androidx.ui.tooling.preview
    implementation libs.androidx.material3
    testImplementation libs.junit
    androidTestImplementation libs.androidx.junit
    androidTestImplementation libs.androidx.espresso.core
    androidTestImplementation platform(libs.androidx.compose.bom)
    androidTestImplementation libs.androidx.ui.test.junit4
    debugImplementation libs.androidx.ui.tooling
    debugImplementation libs.androidx.ui.test.manifest
}

实现AIDL接口的地方



import android.content.Context;
import android.os.Binder;
import android.os.Build;
import android.os.RemoteCallbackList;
import android.os.RemoteException;
import android.os.StatFs;
import android.os.storage.StorageVolume;
import android.util.Log;
import android.os.storage.DiskInfo;
import android.os.storage.VolumeInfo;
import android.os.storage.StorageManager;
import android.app.usage.StorageStatsManager;

import com.android.kvservice.Callback;
import com.android.kvservice.KvInterface;
import com.android.server.kvservice.storage.StorageEntry;
import com.android.server.kvservice.storage.StorageUtils;

import java.util.List;


public class KVService extends KvInterface.Stub {

    /**
     * 获取系统全部内存大小,包括隐藏的内存
     */
//    public static final int GET_SYSTEM_STORGE_TOTAL = 1;
    public static final int GET_ALL_STORGE = 1;

    /**
     *
     */
    public static final int GET_SYSTEM_STORGE_REMAIN = 2;

    public static final int GET_SDCARD_TOTAL = 3;
    public static final int GET_SDCARD_REMAIN = 4;


    private static final String TAG = KVService.class.getSimpleName();
    private RemoteCallbackList<Callback> mCallbackList = new RemoteCallbackList<>();

    private Context mContext;
    private Object lack = new Object();
    private StorageManager storageManager = null;

    public KVService(Context context) {
        this.mContext = context;
        storageManager = (StorageManager) context.getSystemService(Context.STORAGE_SERVICE);
        Log.d(TAG, "henryservice init");
    }

    @Override
    public void registerCallback(Callback callback) {
        boolean result = mCallbackList.register(callback);
        Log.d(TAG, "register pid:" + Binder.getCallingPid()
                + " uid:" + Binder.getCallingUid() + " result:" + result);

    }

    @Override
    public void unregisterCallback(Callback callback) {
        boolean result = mCallbackList.unregister(callback);
        Log.d(TAG, "unregister pid:" + Binder.getCallingPid()
                + " uid:" + Binder.getCallingUid() + " result:" + result);

    }

    @Override
    public void sendMessage(int type, String value) throws RemoteException {
        String result = new String("no-data");
        if (type == GET_ALL_STORGE) {
//           ....
        }

        Log.e(TAG, "rev the type : =========== " + type);
        Log.e(TAG, "rev the value : =========== " + value);
        sendEventToRemote(type, result);
    }

    public void sendEventToRemote(int type, String value) {
        synchronized (lack) {
            int count = mCallbackList.getRegisteredCallbackCount();
            Log.d(TAG, "remote callback count:" + count);
            if (count > 0) {
                // 注意: 遍历过程如果存在多线程操作, 需要加锁, 不然可能会抛出异常
                final int size = mCallbackList.beginBroadcast();
                for (int i = 0; i < size; i++) {
                    Callback cb = mCallbackList.getBroadcastItem(i);
                    try {
                        if (cb != null) {
                            cb.onMessageReceived(type, value);
                        }
                    } catch (RemoteException e) {
                        e.printStackTrace();
                        Log.d(TAG, "remote exception:" + e.getMessage());
                    }
                }
                mCallbackList.finishBroadcast();
            }
        }
    }


}

实现Service的地方:

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;

import androidx.annotation.Nullable;

import com.android.kvservice.Callback;
import com.android.kvservice.KvInterface;
import com.android.server.kvservice.KVService;

public class KService extends Service {
    private KVService kvService = null;

    @Override
    public void onCreate() {
        super.onCreate();
        if (kvService == null) {
            kvService = new KVService(this);
        }
    }

    @Nullable
    @Override
    public IBinder onBind(Intent intent) {
        return binder;
    }

    private final KvInterface.Stub binder = new KvInterface.Stub() {
        @Override
        public void registerCallback(Callback callback) throws RemoteException {
            Log.e("KService", " registerCallback ============ ");
            kvService.registerCallback(callback);
            Log.e("KService", " registerCallback ============ end");
        }

        @Override
        public void unregisterCallback(Callback callback) throws RemoteException {
            Log.e("KService", " unregisterCallback ============ ");
            kvService.unregisterCallback(callback);
            Log.e("KService", " unregisterCallback ============ end");
        }

        @Override
        public void sendMessage(int type, String value) throws RemoteException {
            kvService.sendMessage(type, value);
            Log.e("KService", " sendMessage ============ end");
        }
    };
}

本地调用Service的代码。


import android.app.Activity;
import android.app.Service;
import android.content.ComponentName;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;
import android.view.View;
import android.widget.Button;

import androidx.annotation.Nullable;

import com.android.kvservice.Callback;
import com.android.kvservice.KvInterface;
import com.android.server.kvservice.KVService;

public class MainActivity extends Activity {
    //    private MainBinding binding;
    private KvInterface kvInterface;
    private Button btnStart;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        binding = MainBinding.inflate(getLayoutInflater());
//        setContentView(binding.getRoot());
        setContentView(R.layout.main);
        btnStart = findViewById(R.id.btnStart);
        btnStart.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                if (kvInterface == null) {
                    bindToService();
                }
            }
        });
        Button btnSend = findViewById(R.id.btnSend);
        btnSend.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Log.e("TAG", "send 111");
                registerCallback();
                if (kvInterface != null) {
                    try {
                        Log.e("TAG", "send 222");
                        kvInterface.sendMessage(1, "");
                    } catch (RemoteException e) {
                        e.printStackTrace();
                    }
                }
            }
        });
    }

    private boolean register = false;
    private Callback.Stub callback = new Callback.Stub() {

        @Override
        public void onMessageReceived(int type, String value) throws RemoteException {
            Log.e("MainActivity", "rev the type:: ==== " + type);
            Log.e("MainActivity", "rev the value:: ==== " + value);
        }
    };

    private void registerCallback() {
        if (!register) {
            register = true;
            try {
                if (kvInterface != null) {
                    kvInterface.registerCallback(callback);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        try {
            if (kvInterface != null) {
                kvInterface.unregisterCallback(callback);
            }
        } catch (RemoteException e) {
            throw new RuntimeException(e);
        }
    }

    private ServiceConnection serviceConnection = new ServiceConnection() {

        @Override
        public void onServiceConnected(ComponentName name, IBinder service) {
            kvInterface = KvInterface.Stub.asInterface(service);
        }

        @Override
        public void onServiceDisconnected(ComponentName name) {
            kvInterface = null;
        }
    };

    private void bindToService() {
//        bindService(new Intent("com.kingview.qti.service.KService"), serviceConnection, Service.BIND_AUTO_CREATE);
        bindService(new Intent(this, KService.class), serviceConnection, Service.BIND_AUTO_CREATE);
        Log.e("TAG","bindToService ======================");
    }
}

为了第三方App调用,需要再配置文件中做以下声明:

  <service
            android:name="com.kingview.qti.service.KService"
            android:enabled="true"
            android:exported="true"
            android:process="com.kingview.qti.service.kservice">
            <intent-filter>
                <action android:name="com.kingview.service.kservice" />
            </intent-filter>
        </service>

第三方App调用AIDL服务的代码,发现调用Action并没有什么用,特别注意要输入完整的包名:

  private fun bindToService() {
        val intent = Intent()
        intent.setComponent(
            ComponentName(
                "com.kingview.qti.service",
                "com.kingview.qti.service.KService"
            )
        )
        bindService(
            intent,
            serviceConnection,
            BIND_AUTO_CREATE
        )
//        Log.e("StorageTestActivity", " bindToService ====================== ")
    }

注册远程回调

 private fun registerCallback() {
        if (!register) {
            register = true
            try {
                if (kvInterface != null) {
                    kvInterface!!.registerCallback(callback)
                }
                kvInterface?.sendMessage(1, "")
            } catch (e: Exception) {
                e.printStackTrace()
            }
        }
    }

反注册callback和 解绑Service。


    override fun onDestroy() {
        super.onDestroy()
        kvInterface?.unregisterCallback(callback)
        unbindService(serviceConnection)
    }

监听实现的操作是这样实现的:

 @Volatile
    private var register = false
    private val callback: Callback = object : Callback.Stub() {
        @Throws(RemoteException::class)
        override fun onMessageReceived(type: Int, value: String) {
            Log.e("StorageTestActivity", "rev the type:: ==== $type")
            Log.e("StorageTestActivity", "rev the value:: ==== $value")
            //解析数据,并显示到界面上
            if (testKey == KVApplication.TEST_STORAGE) {
                val strs = value.split("#").filter { v ->
                    v.trim() != ""
                }
                for (v in strs) {
                    val bean = Gson().fromJson<StorageBean>(v, StorageBean::class.java)
                    if (bean.description.contains("internal_storage")) {
                        val total = bean.total.toLong() / 1000f / 1000f / 1000f;
                        val used = bean.used.toLong() / 1000f / 1000f / 1000f;
                        val remain = total - used
                        binding.txtStatus.post {
                            binding.txtSize.text = " Size: ${total} GB ; Remain ${remain} GB. \n "
                        }
                    }
                }
            }
        }
    }

通过以上操作你可能会发现,依然无法调用远程的Service。你需要再AndroidManifest里声明一个权限。

 <uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"
        tools:ignore="QueryAllPackagesPermission" />

将App放置在源码工程的的 package/apps/里创建一个文件夹如:XYZService

src/ res/ Androidmanifast.xml 都要从标准App工程里copy出来。

 Android.bp这样写,包含了AIDL文件 :

//
// Copyright (C) 2013 Google Inc.
//

package {
    default_applicable_licenses: ["packages_apps_kvservice_license"],
}

// Added automatically by a large-scale-change
// See: http://go/android-license-faq
license {
    name: "packages_apps_kvservice_license",
    visibility: [":__subpackages__"],
    license_kinds: [
        "SPDX-license-identifier-BSD",
    ],
    // large-scale-change unable to identify any license_text files
}

android_app {
    name: "XYZServiceTest",
    defaults: ["platform_app_defaults"],
    platform_apis: true,
    certificate: "platform",
    system_ext_specific: true,
    privileged: true,
    srcs: [
        "src/**/*.java",
        "src/**/*.aidl",
    ],

     aidl: {
        local_include_dirs: ["src/aidl"],
    },
    manifest: "AndroidManifest.xml",
    resource_dirs: [
        "res",
    ],
    // privileged: true,
    // sdk_version: "33",

    // sdk_version: "current",
    // certificate: "platform",
    // platform_apis: true,
    // product_specific: true,

    static_libs: [
        "androidx.core_core",
        // "androidx.annotation:annotation:1.3.0",
        "guava",
    ],
}

 通过阅读Setting源码移植的代码如下:

    public static List<StorageEntry> getAllStorageEntries(Context context,
                                                          StorageManager storageManager) {
        final List<StorageEntry> storageEntries = new ArrayList<>();
        storageEntries.addAll(storageManager.getVolumes().stream()
                .filter(volumeInfo -> isStorageSettingsInterestedVolume(volumeInfo))
                .map(volumeInfo -> new StorageEntry(context, volumeInfo))
                .collect(Collectors.toList()));
        storageEntries.addAll(storageManager.getDisks().stream()
                .filter(disk -> isDiskUnsupported(disk))
                .map(disk -> new StorageEntry(disk))
                .collect(Collectors.toList()));
        storageEntries.addAll(storageManager.getVolumeRecords().stream()
                .filter(volumeRecord -> isVolumeRecordMissed(storageManager, volumeRecord))
                .map(volumeRecord -> new StorageEntry(volumeRecord))
                .collect(Collectors.toList()));
        return storageEntries;
    }

public class StorageEntry implements Comparable<StorageEntry>, Parcelable  {
    private final VolumeInfo mVolumeInfo;
    private final DiskInfo mUnsupportedDiskInfo;
    private final VolumeRecord mMissingVolumeRecord;

    private final String mVolumeInfoDescription;

    public StorageEntry(@NonNull Context context, @NonNull VolumeInfo volumeInfo) {
        mVolumeInfo = volumeInfo;
        mUnsupportedDiskInfo = null;
        mMissingVolumeRecord = null;

        if (isDefaultInternalStorage()) {
            // Shows "This device" for default internal storage.
            mVolumeInfoDescription = "storage_default_internal_storage";
        } else {
            mVolumeInfoDescription = context.getSystemService(StorageManager.class)
                    .getBestVolumeDescription(mVolumeInfo);
        }
    }

    public StorageEntry(@NonNull DiskInfo diskInfo) {
        mVolumeInfo = null;
        mUnsupportedDiskInfo = diskInfo;
        mMissingVolumeRecord = null;
        mVolumeInfoDescription = null;
    }

    public StorageEntry(@NonNull VolumeRecord volumeRecord) {
        mVolumeInfo = null;
        mUnsupportedDiskInfo = null;
        mMissingVolumeRecord = volumeRecord;
        mVolumeInfoDescription = null;
    }

    private StorageEntry(Parcel in) {
        mVolumeInfo = in.readParcelable(VolumeInfo.class.getClassLoader());
        mUnsupportedDiskInfo = in.readParcelable(DiskInfo.class.getClassLoader());
        mMissingVolumeRecord = in.readParcelable(VolumeRecord.class.getClassLoader());
        mVolumeInfoDescription = in.readString();
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel out, int flags) {
        out.writeParcelable(mVolumeInfo, 0 /* parcelableFlags */);
        out.writeParcelable(mUnsupportedDiskInfo, 0 /* parcelableFlags */);
        out.writeParcelable(mMissingVolumeRecord, 0 /* parcelableFlags */);
        out.writeString(mVolumeInfoDescription);
    }

    public static final Parcelable.Creator<StorageEntry> CREATOR =
            new Parcelable.Creator<StorageEntry>() {
                public StorageEntry createFromParcel(Parcel in) {
                    return new StorageEntry(in);
                }

                public StorageEntry[] newArray(int size) {
                    return new StorageEntry[size];
                }
            };

    @Override
    public boolean equals(Object o) {
        if (o == this) {
            return true;
        }
        if (!(o instanceof StorageEntry)) {
            return false;
        }

        final StorageEntry StorageEntry = (StorageEntry) o;
        if (isVolumeInfo()) {
            return mVolumeInfo.equals(StorageEntry.mVolumeInfo);
        }
        if (isDiskInfoUnsupported()) {
            return mUnsupportedDiskInfo.equals(StorageEntry.mUnsupportedDiskInfo);
        }
        return mMissingVolumeRecord.equals(StorageEntry.mMissingVolumeRecord);
    }

    @Override
    public int hashCode() {
        if (isVolumeInfo()) {
            return mVolumeInfo.hashCode();
        }
        if (isDiskInfoUnsupported()) {
            return mUnsupportedDiskInfo.hashCode();
        }
        return mMissingVolumeRecord.hashCode();
    }

    @Override
    public String toString() {
        if (isVolumeInfo()) {
            return mVolumeInfo.toString();
        }
        if (isDiskInfoUnsupported()) {
            return mUnsupportedDiskInfo.toString();
        }
        return mMissingVolumeRecord.toString();
    }

    @Override
    public int compareTo(StorageEntry other) {
        if (isDefaultInternalStorage() && !other.isDefaultInternalStorage()) {
            return -1;
        }
        if (!isDefaultInternalStorage() && other.isDefaultInternalStorage()) {
            return 1;
        }

        if (isVolumeInfo() && !other.isVolumeInfo()) {
            return -1;
        }
        if (!isVolumeInfo() && other.isVolumeInfo()) {
            return 1;
        }

        if (isPrivate() && !other.isPrivate()) {
            return -1;
        }
        if (!isPrivate() && other.isPrivate()) {
            return 1;
        }

        if (isMounted() && !other.isMounted()) {
            return -1;
        }
        if (!isMounted() && other.isMounted()) {
            return 1;
        }

        if (!isVolumeRecordMissed() && other.isVolumeRecordMissed()) {
            return -1;
        }
        if (isVolumeRecordMissed() && !other.isVolumeRecordMissed()) {
            return 1;
        }

        if (getDescription() == null) {
            return 1;
        }
        if (other.getDescription() == null) {
            return -1;
        }
        return getDescription().compareTo(other.getDescription());
    }

    /**
     * Returns default internal storage.
     */
    public static StorageEntry getDefaultInternalStorageEntry(Context context) {
        return new StorageEntry(context, context.getSystemService(StorageManager.class)
                .findVolumeById(VolumeInfo.ID_PRIVATE_INTERNAL));
    }

    /**
     * If it's a VolumeInfo.
     */
    public boolean isVolumeInfo() {
        return mVolumeInfo != null;
    }

    /**
     * If it's an unsupported DiskInfo.
     */
    public boolean isDiskInfoUnsupported() {
        return mUnsupportedDiskInfo != null;
    }

    /**
     * If it's a missing VolumeRecord.
     */
    public boolean isVolumeRecordMissed() {
        return mMissingVolumeRecord != null;
    }

    /**
     * If it's a default internal storage.
     */
    public boolean isDefaultInternalStorage() {
        if (isVolumeInfo()) {
            return mVolumeInfo.getType() == VolumeInfo.TYPE_PRIVATE
                    && TextUtils.equals(mVolumeInfo.getId(), VolumeInfo.ID_PRIVATE_INTERNAL);
        }
        return false;
    }

    /**
     * If it's a mounted storage.
     */
    public boolean isMounted() {
        return mVolumeInfo == null ? false : (mVolumeInfo.getState() == VolumeInfo.STATE_MOUNTED
                || mVolumeInfo.getState() == VolumeInfo.STATE_MOUNTED_READ_ONLY);
    }

    /**
     * If it's an unmounted storage.
     */
    public boolean isUnmounted() {
        return mVolumeInfo == null ? false : (mVolumeInfo.getState() == VolumeInfo.STATE_UNMOUNTED);
    }

    /**
     * If it's an unmountable storage.
     */
    public boolean isUnmountable() {
        return mVolumeInfo == null ? false : mVolumeInfo.getState() == VolumeInfo.STATE_UNMOUNTABLE;
    }

    /**
     * If it's a private storage.
     */
    public boolean isPrivate() {
        return mVolumeInfo == null ? false : mVolumeInfo.getType() == VolumeInfo.TYPE_PRIVATE;
    }

    /**
     * If it's a public storage.
     */
    public boolean isPublic() {
        return mVolumeInfo == null ? false : mVolumeInfo.getType() == VolumeInfo.TYPE_PUBLIC;
    }

    /**
     * Returns description.
     */
    public String getDescription() {
        if (isVolumeInfo()) {
            return mVolumeInfoDescription;
        }
        if (isDiskInfoUnsupported()) {
            return mUnsupportedDiskInfo.getDescription();
        }
        return mMissingVolumeRecord.getNickname();
    }

    /**
     * Returns ID.
     */
    public String getId() {
        if (isVolumeInfo()) {
            return mVolumeInfo.getId();
        }
        if (isDiskInfoUnsupported()) {
            return mUnsupportedDiskInfo.getId();
        }
        return mMissingVolumeRecord.getFsUuid();
    }

    /**
     * Returns disk ID.
     */
    public String getDiskId() {
        if (isVolumeInfo()) {
            return mVolumeInfo.getDiskId();
        }
        if (isDiskInfoUnsupported()) {
            return mUnsupportedDiskInfo.getId();
        }
        return null;
    }

    /**
     * Returns fsUuid.
     */
    public String getFsUuid() {
        if (isVolumeInfo()) {
            return mVolumeInfo.getFsUuid();
        }
        if (isDiskInfoUnsupported()) {
            return null;
        }
        return mMissingVolumeRecord.getFsUuid();
    }

    /**
     * Returns root file if it's a VolumeInfo.
     */
    public File getPath() {
        return mVolumeInfo == null ? null : mVolumeInfo.getPath();
    }

    /**
     * Returns VolumeInfo of the StorageEntry.
     */
    public VolumeInfo getVolumeInfo() {
        return mVolumeInfo;
    }
}

Setting关于计算存储卡的代码在

StorageUsageProgressBarPreferenceController 

StorageDashboardFragment文件

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2080621.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

RK3568平台(平台总线篇)SPI驱动框架分析

一.SPI 子系统框架 可以将上面这一 SPI 子系统划分为三个层次,分别为用户空间、内核空间和硬件层,内核空间就包括 SPI 设备驱动层、SPI 核心层和 SPI 适配器驱动层,而本章的主要内容就是介绍 SPI 子系统框架中的内核空间。 SPI 适配器驱动层: SPI 适配器驱动层是 SPI 子系…

【STM32】SPI

SPI又是另一个超级常见的外设通信方式。 大部分图片来源&#xff1a;正点原子HAL库课程 专栏目录&#xff1a;记录自己的嵌入式学习之路-CSDN博客 目录 1 基本概念 1.1 与IIC的区别 1.2 引脚 1.3 移位原理 1.4 四种工作模式 2 NOR Flash 2.1 25Q12…

论文《Graph Structural Attack by Perturbing Spectral Distance》笔记

【SPAC 2022 KDD】大多数现有攻击方法在空间域中操作图&#xff0c;而对傅里叶域中图卷积的脆弱性研究较少。作者提出了一种名为SPectral AttaCk&#xff08;SPAC&#xff09;的攻击方法&#xff0c;通过最大化谱距离来实施攻击&#xff0c;并提出了一种有效的近似方法来降低特…

R语言股价跳跃点识别:隐马尔可夫hmm和 GARCH-Jump对sp500金融时间序列分析

全文链接&#xff1a;https://tecdat.cn/?p37479 分析师&#xff1a;Yue Ji 在突发事件发生后&#xff0c;股价会相应的发生较大幅度的上涨或下跌&#xff0c;称为跳跃现象&#xff0c;跳跃现象会给金融投资带来极大风险&#xff0c;因而对跳跃点的识别对于风控而言是很重要的…

web渗透:SQL注入漏洞WAF绕过

目录 如何检测和防范SQL注入攻击中的编码伪装&#xff1f; 检测SQL注入攻击中的编码伪装 防范SQL注入攻击中的编码伪装 WAF在处理SQL注入时为什么有时会对大小写不敏感&#xff1f; SQL注入中的联合查询注入有哪些常见的攻击方式&#xff1f; 在绕过Web应用防火墙&#xf…

实时计算Flink:推动行业变革的新时代引擎(附金融/汽车/物流/零售案例)

实时计算Flink&#xff1a;推动行业变革的新时代引擎&#xff08;附金融/汽车/物流/零售案例&#xff09; 前言实时计算Flink 前言 在当今数字化高速发展的时代&#xff0c;数据的价值愈发凸显&#xff0c;而实时计算技术则成为了挖掘数据价值的关键利器。阿里云实时计算 Flin…

道格拉斯-普克 Douglas-Peuker(DP算法) python php实现

废话不多说&#xff0c;直接开干&#xff01; 最近在做一个车联网项目&#xff0c;有一个场景是车辆定时上报当前所在经纬度等位置信息上报给平台&#xff0c;平台通过web页面在高德地图上展示车辆行驶路径。 说明 道格拉斯-普克算法 (Douglas–Peucker algorithm&#xff0c;亦…

Leetcode面试经典150题-17.电话号码的字母组合

突然发现回溯题最近考的好多&#xff0c;其实没啥技术含量 解法都在代码里&#xff0c;不懂就留言或者私信 class Solution {public static final char[][] digitsCharArr {{},{},{a,b,c},/**数字2可以代表的字符 */{d,e,f},{g,h,i},{j,k,l},{m,n,o},{p,q,r,s},{t,u,v},{w,x…

【数据结构入门】二叉树之堆排序及链式二叉树

目录 前言 一、堆排序 1.概念 2.堆排序思想 3.具体步骤 4.实现 5.复杂度 二、堆的应用——TopK问题 三、链式二叉树 1.二叉树创建 2.二叉树遍历 1&#xff09;前序、中序以及后序遍历 2&#xff09;层序遍历 3.结点个数以及高度 1&#xff09;结点个数&#xff1a…

阿里巴巴中间件canal的搭建和使用以及linux命令下使用mail发送html格式的邮件

一、阿里巴巴中间件canal的搭建和使用 canal可以用来监控数据库数据的变化(binlog日志)&#xff0c;从而获得指定数据的变化。canal是应阿里巴巴存在杭州和美国的双机房部署&#xff0c;存在跨机房同步的业务需求时开始逐步的尝试基于数据库的日志解析&#xff0c;获取增量变更…

Netty三

Netty TCP拆包粘包 二次编码方式 常用二次解码器 网络应用程序基本步骤 数据结构设计 完善客户端 客户端实例 Netty编程易错点

C++ 设计模式——适配者模式

C 设计模式——适配者模式 C 设计模式——适配者模式1. 主要组成成分2. 逐步构建适配者模式2.1 目标抽象类定义2.2 源类实现2.3 适配器类实现2.4 客户端 3. 适配者模式 UML 图适配者模式 UML 图解析 5. 类适配者6. 适配者模式的优点7. 适配者模式的缺点8. 适配者模式适用场景总…

永久去除windows11推荐产品的软件

永久去除windows11推荐产品的软件 去除windows11 推荐的项目&#xff0c;并用来固定软件 要求 22621及以上版本 企业版&#xff0c;专业教育版&#xff0c;教育版&#xff08;可以自行找工具切换&#xff0c;无需重装系统,非常方便的。&#xff09; [软件原创作者]&#xff…

【Python】Python 函数综合指南——从基础到高阶

文章目录 Python 函数综合指南1. 函数介绍1.1 什么是函数&#xff1f;1.2 定义函数示例&#xff1a;1.3 调用函数1.4 函数参数1.4.1 必需参数1.4.2 默认参数1.4.3 关键字参数1.4.4 可变长度参数 2. Python 内置函数2.1 字符串处理函数示例&#xff1a; 2.2 数学函数示例&#x…

音视频相关

ffmpeg 安装 1. 源码安装 git clone https://git.ffmpeg.org/ffmpeg.git 2. 配置 编译 安装 ./configure --prefix/usr/local/ffmpeg --enable-debug3 --enable-shared --disable-static --disable-x86asm --enable-ffplaymake -jnproc && make install Q: 没有ff…

C++ 基础学习

提示并输入一个字符串&#xff0c;统计该字符串中字母个数、数字个数、空格个数、其他字符的个数 #include <iostream>using namespace std;int main() {cout<<"请输入字符串:";string str;getline(cin,str);int num0;int alp0;int spa0;int other0;int …

大语言模型-GPT3-Language Models are Few-Shot Learners

一、背景信息&#xff1a; GPT3是于2020 年由OpenAI 发布的预训练语言模型。 GPT3在自然语言处理&#xff08;NLP&#xff09;任务中表现出色&#xff0c;可以生成连贯的文本、回答问题、进行对话等。 GPT3的网络架构继续沿用GPT1、GPT2的是多层Transformer Decoder改的结构。…

论文笔记:GEO-BLEU: Similarity Measure for Geospatial Sequences

22 sigspatial 1 intro 提出了一种空间轨迹相似性度量的方法比较了两种传统相似度度量的不足 DTW 基本特征是它完全对齐序列以进行测量&#xff0c;而不考虑它们之间共享的局部特征这适用于完全对齐的序列&#xff0c;但不适用于逐步对齐没有太多意义的序列BLEU 适用于不完全…

MVSEP-MDX23容器构建详细教程

一、介绍 模型GitHub网址&#xff1a;MVSEP-MDX23-music-separation-model/README.md 在 main ZFTurbo/MVSEP-MDX23-音乐分离模型 GitHub 上 在音视频领域&#xff0c;把已经发布的混音歌曲或者音频文件逆向分离一直是世界性的课题。音波混合的物理特性导致在没有原始工程文件…

股指期货的交易规则有哪些?

股指期货作为一种金融衍生品&#xff0c;其合约条款和交易规则是投资者必须了解的重要内容。以下是关于股指期货合约条款及交易规则的详细解释&#xff1a; 一、合约乘数 沪深300指数期货合约的乘数为每点人民币300元。 中证500股指期货合约的乘数为每点200元。 上证50股指…