【转】中国移动光猫网关samba文件共享

转载自:中国移动光猫网关samba文件共享


家里拉了中国移动的光纤,送了光猫,带有USB口,可以做文件共享和USB打印机共享

进入光猫的超级管理界面(进入的方法和用户名密码请自行百度。。。),看到光猫可以用作FTP服务器和samba服务器

其中FTP服务器是默认关闭的

samba服务器是默认开启的,用户名密码都是useradmin

使用愉快!


1、 移动光猫账号: CMCCAdmin 密码:aDm8H%MdA
2、 华为的:telecomadmin 密码:admintelecom
3、 中国电信超级账号:telecomadmin 密码:nE7jA%5m

Windows中类似于ps和kill的命令及使用方法

转载自:Win11中类似于ps和kill的命令行及使用方法


最近由于开发需要,在win11下安装nginx,启动、进程查找和停止是一个麻烦的事情,还好,win11下也有类似于linux下ps和kill的命令行工具,编写成批处理,十分好用。下面简单介绍使用方法。

tasklist

tasklist | findstr “nginx”
在linux下习惯于使用ps -ef|grep,在win11下也有对应的功能。这个无需多言,熟悉ps -ef|grep “nginx”的地球人都知道

taskkill

taskkill /f /t /im nginx.exe
在linux下习惯于使用kill -9,在win11下也有对应的功能。直接上图吧。

Win10开启系统休眠

 

1、按键盘上的Windows按钮以打开“开始”菜单或“开始”屏幕。

2、搜索 cmd。在搜索结果列表中,右键单击命令提示符,然后单击以管理员身份运行。

3、显示“用户帐户控制”提示时,请单击是。

4、在命令提示符处,键入 powercfg -h on,然后按 Enter。

5、键入 exit,然后按 Enter 以关闭命令提示符窗口。

注:Win10关闭系统休眠后,会导致“快速启动”功能失效。

【转】Android中关于Deviceid的那些事

转载自:Android中关于Deviceid的那些事


Android 中获取设备id一直是老生常谈的事情,先说下名词解释

    • Device ID:设备ID。
    • IMEI:International Mobile Equipment Identity,国际移动设备身份码的缩写。是由15位数字组成的“电子串号”,它与每台手机一一对应,每个IMEI在世界上都是唯一的。
    • IDFA:Identifier For Advertising,iOS独有的广告标识符。
    • UDID:Unique Device Identifier,唯一设备标识码。
    • UUID:Universally Unique Identifier,通用唯一识别码。目前最广泛应用的UUID,是微软公司的全局唯一标识符GUID。其目的是让分布式系统中的所有元素,都能有唯一的辨识信息,而不需要通过中央控制端来做辨识信息的指定。
    • ANDROID_ID:在 Android 8.0(API 级别 26)和更高版本的平台上,一个 64 位数字(表示为十六进制字符串),对于应用签名密钥、用户和设备的每个组合都是唯一的值。

今天我们先说一下获取deviceId的方法:

/**
 * 获取deviceId(手机唯一的标识)
 *
 * @param context
 * @return
 */
@SuppressLint({"HardwareIds"})
public static String getDeviceId(Context context) {
    String deviceId;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
        deviceId = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
    } else {
        if (ActivityCompat.checkSelfPermission(context, Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) {
            return "";
        }
        TelephonyManager mTelephony = (TelephonyManager) context.getSystemService(TELEPHONY_SERVICE);
        if (mTelephony.getDeviceId() != null) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
                deviceId = mTelephony.getImei();
            } else {
                deviceId = mTelephony.getDeviceId();
            }
        } else {
            deviceId = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
        }
    }
    return deviceId;
}

【转】下载apk并启动安装

转载自:下载apk并启动安装


本篇实现现在网络上的apk并启动安装程序。

权限

写入权限和网络访问权限

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.INTERNET" />

变量

    private DownloadManager downloadManager = null; //下载管理器
    private long mTaskId; // 任务id
    private String fileName; //下载下来文件保存时候的文件名称
    
    fileName = System.currentTimeMillis() + ".apk";
        downloadManager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
        String url = "http://111.202.99.13/imtt.dd.qq.com/16891/2A76B7A9A8E841F0D8C1E74AD65FCB3F.apk?mkey=57c3dd3fc5355f8e&f=6c25&c=0&fsname=com.tencent.mobileqq_6.5.3_398.apk&csr=4d5s&p=.apk";
        downloadAPK(url);

下载apk

上面代码调用了downloadAPK方法。
其中用到了文件保存位置,也可以使用缓存目录替换。

    // 使用系统下载器下载
    private void downloadAPK(String versionUrl) {
        // 创建下载任务
        DownloadManager.Request request = new DownloadManager.Request(
                Uri.parse(versionUrl));
        request.setAllowedOverRoaming(false);// 漫游网络是否可以下载

        // 设置文件类型,可以在下载结束后自动打开该文件
        MimeTypeMap mimeTypeMap = MimeTypeMap.getSingleton();
        String mimeString = mimeTypeMap.getMimeTypeFromExtension(MimeTypeMap
                .getFileExtensionFromUrl(versionUrl));
        request.setMimeType(mimeString);

        // 在通知栏中显示,默认就是显示的
        request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE);
        request.setVisibleInDownloadsUi(true);

        // sdcard的目录下的download文件夹,必须设置
        request.setDestinationInExternalPublicDir("/download/", fileName);
        // request.setDestinationInExternalFilesDir(),也可以自己制定下载路径

        // 将下载请求加入下载队列
        downloadManager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
        // 加入下载队列后会给该任务返回一个long型的id,
        // 通过该id可以取消任务,重启任务等等
        mTaskId = downloadManager.enqueue(request);

        // 注册广播接收者,监听下载状态
        registerReceiver(receiver, new IntentFilter(
                DownloadManager.ACTION_DOWNLOAD_COMPLETE));
    }

广播接收

上面代码用到了receiver

    // 广播接受者,接收下载状态
    private BroadcastReceiver receiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            checkDownloadStatus();// 检查下载状态
        }
    };

    // 检查下载状态
    private void checkDownloadStatus() {
        DownloadManager.Query query = new DownloadManager.Query();
        query.setFilterById(mTaskId);// 筛选下载任务,传入任务ID,可变参数
        Cursor c = downloadManager.query(query);
        if (c.moveToFirst()) {
            int status = c.getInt(c
                    .getColumnIndex(DownloadManager.COLUMN_STATUS));
            switch (status) {
                case DownloadManager.STATUS_PAUSED:
                    Log.i("download", ">>>下载暂停");
                case DownloadManager.STATUS_PENDING:
                    Log.i("download", ">>>下载延迟");
                case DownloadManager.STATUS_RUNNING:
                    Log.i("download", ">>>正在下载");
                    break;
                case DownloadManager.STATUS_SUCCESSFUL:
                    Log.i("download", ">>>下载完成");
                    // 下载完成安装APK
                    String downloadPath = Environment
                            .getExternalStoragePublicDirectory(
                                    Environment.DIRECTORY_DOWNLOADS)
                            .getAbsolutePath()
                            + File.separator + fileName;
                    installAPK(new File(downloadPath));
                    break;
                case DownloadManager.STATUS_FAILED:
                    Log.e("download", ">>>下载失败");
                    break;
            }
        }
    }

下载完成

上面代码用到了installAPK,作用是下载完成后开始安装。

    // 下载到本地后执行安装
    protected void installAPK(File file) {
        if (!file.exists())
            return;
        Intent intent = new Intent(Intent.ACTION_VIEW);
        Uri uri = Uri.parse("file://" + file.toString());
        intent.setDataAndType(uri, "application/vnd.android.package-archive");
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(intent);
    }

如果要静默安装,上面的方法是不行的,设备必须root。可以参考这里

【转】Build-tool 32.0.0 is missing DX

转载自:Unity 打包安卓apk失败“Build-tool 31.0.0 is missing DX”或“Build-tool 32.0.0 is missing DX”


Unity 打包安卓apk失败。“Build-tool 31.0.0 is missing DX”“Build-tool 32.0.0 is missing DX”

Build Tool 31 以后从SDK内删除了dx工具,使用d8工具来替代dx工具。

解决方法有:

  1. build tool版本改为30。( 将*.gradle文件中的buildToolsVersion 改为30)
  2. 把build-tools\30.0.0目录下的dx.bat和lib/dx.jar文件,复制到build-tools\32.0.0目录。
  3. 把build-tools\32.0.0目录下的d8.bat和lib/d8.jar文件,分别复制改名为dx.bat以及lib/dx.jar。
  4. 升级Android Gradle 版本到7.0以上